init push

This commit is contained in:
2026-07-16 22:16:45 +07:00
commit 8b068bdb10
1021 changed files with 332816 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package flight
import (
"time"
"gorm.io/gorm"
"wucher/internal/domain/takeover"
"wucher/internal/shared/pkg/uuidv7"
)
type Flight struct {
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
Status string `gorm:"type:varchar(20);not null;default:draft;column:status"`
Date time.Time `gorm:"type:date;not null;index;column:date"`
MissionCode *string `gorm:"type:varchar(64);index;column:mission_code"`
DutyRosterID []byte `gorm:"type:binary(16);->;column:duty_roster_id"`
ReserveAcID []byte `gorm:"type:binary(16);->;column:reserve_ac_id"`
TakeoverAcID []byte `gorm:"type:binary(16);index;column:takeover_ac_id"`
Takeover *takeover.TakeoverAc `gorm:"foreignKey:TakeoverAcID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
CreatedAt time.Time `gorm:"column:created_at"`
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
CreatedByName string `gorm:"->;column:created_by_name"`
UpdatedAt time.Time `gorm:"column:updated_at"`
UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"`
UpdatedByName string `gorm:"->;column:updated_by_name"`
DeletedAt *time.Time `gorm:"column:deleted_at;index"`
DeletedBy []byte `gorm:"type:binary(16);column:deleted_by"`
}
func (Flight) TableName() string { return "flights" }
func (f *Flight) BeforeCreate(tx *gorm.DB) error {
if len(f.ID) == 0 {
f.ID = uuidv7.MustBytes()
}
return nil
}

View File

@@ -0,0 +1,20 @@
package flight
import "context"
type FlightRepository interface {
Create(ctx context.Context, row *Flight) error
GetLatestMissionCodeByPrefix(ctx context.Context, prefix string) (string, error)
Update(ctx context.Context, row *Flight) error
Delete(ctx context.Context, id []byte, deletedBy []byte) error
GetByID(ctx context.Context, id []byte) (*Flight, error)
ListByUserID(ctx context.Context, userID []byte, limit, offset int) ([]Flight, int64, error)
ListByCreatedBy(ctx context.Context, createdBy []byte, filter string, date string, sort string, limit, offset int) ([]Flight, int64, error)
GetByReserveAcID(ctx context.Context, reserveAcID []byte) (*Flight, error)
ListByReserveAcID(ctx context.Context, reserveAcID []byte) ([]Flight, error)
GetByTakeoverAcID(ctx context.Context, takeoverAcID []byte) (*Flight, error)
ListByTakeoverAcIDs(ctx context.Context, takeoverAcIDs [][]byte) ([]Flight, error)
GetByDutyRosterID(ctx context.Context, dutyRosterID []byte) (*Flight, error)
ListByDutyRosterIDs(ctx context.Context, dutyRosterIDs [][]byte) ([]Flight, error)
List(ctx context.Context, filter string, date string, sort string, limit, offset int) ([]Flight, int64, error)
}

View File

@@ -0,0 +1,19 @@
package flight
import "context"
type FlightService interface {
Create(ctx context.Context, row *Flight) error
Update(ctx context.Context, row *Flight) error
Delete(ctx context.Context, id []byte, deletedBy []byte) error
GetByID(ctx context.Context, id []byte) (*Flight, error)
ListByUserID(ctx context.Context, userID []byte, limit, offset int) ([]Flight, int64, error)
ListByCreatedBy(ctx context.Context, createdBy []byte, filter string, date string, sort string, limit, offset int) ([]Flight, int64, error)
GetByReserveAcID(ctx context.Context, reserveAcID []byte) (*Flight, error)
ListByReserveAcID(ctx context.Context, reserveAcID []byte) ([]Flight, error)
GetByTakeoverAcID(ctx context.Context, takeoverAcID []byte) (*Flight, error)
ListByTakeoverAcIDs(ctx context.Context, takeoverAcIDs [][]byte) ([]Flight, error)
GetByDutyRosterID(ctx context.Context, dutyRosterID []byte) (*Flight, error)
ListByDutyRosterIDs(ctx context.Context, dutyRosterIDs [][]byte) ([]Flight, error)
List(ctx context.Context, filter string, date string, sort string, limit, offset int) ([]Flight, int64, error)
}