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,47 @@
package reserveac
import (
"time"
"gorm.io/gorm"
flightinspection "wucher/internal/domain/flight_inspection"
helicopter "wucher/internal/domain/helicopter"
"wucher/internal/shared/pkg/reserveacutil"
"wucher/internal/shared/pkg/uuidv7"
)
const (
StatusPending = reserveacutil.StatusPending
StatusApproved = reserveacutil.StatusApproved
StatusOnProgress = reserveacutil.StatusOnProgress
)
type ReserveAc struct {
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
Status string `gorm:"type:varchar(20);not null;default:pending;index;check:chk_reserve_ac_status,status IN ('pending','approved','onprogress');column:status"`
BaseID []byte `gorm:"type:binary(16);index;column:base_id"`
AircraftID []byte `gorm:"type:binary(16);not null;index;column:helicopter_id"`
InspectionID []byte `gorm:"type:binary(16);not null;uniqueIndex:uidx_reserve_acs_inspection_id;column:inspection_id"`
Notes *string `gorm:"type:text;column:notes"`
Aircraft *helicopter.Helicopter `gorm:"foreignKey:AircraftID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Inspection *flightinspection.FlightInspection `gorm:"foreignKey:InspectionID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
CreatedAt time.Time `gorm:"column:created_at"`
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
UpdatedAt time.Time `gorm:"column:updated_at"`
UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"`
DeletedAt *time.Time `gorm:"column:deleted_at;index"`
DeletedBy []byte `gorm:"type:binary(16);column:deleted_by"`
}
func (ReserveAc) TableName() string { return "reserve_acs" }
func (o *ReserveAc) BeforeCreate(_ *gorm.DB) error {
if len(o.ID) == 0 {
o.ID = uuidv7.MustBytes()
}
o.Status = reserveacutil.NormalizeStatus(o.Status)
return nil
}

View File

@@ -0,0 +1,20 @@
package reserveac
import (
"context"
shareddto "wucher/internal/transport/http/dto/shared"
)
type ReserveAcRepository interface {
Create(ctx context.Context, row *ReserveAc) error
Update(ctx context.Context, row *ReserveAc) error
Delete(ctx context.Context, id []byte, deletedBy []byte) error
GetByID(ctx context.Context, id []byte) (*ReserveAc, error)
GetActiveByInspectionID(ctx context.Context, inspectionID []byte) (*ReserveAc, error)
List(ctx context.Context, filter string, sort string, limit, offset int) ([]ReserveAc, int64, error)
AircraftExists(ctx context.Context, helicopterID []byte) (bool, error)
FlightInspectionExists(ctx context.Context, inspectionID []byte) (bool, error)
ExistsActiveByInspectionID(ctx context.Context, inspectionID []byte, excludeID []byte) (bool, error)
GetLastDailyInspectionByHelicopterID(ctx context.Context, helicopterID []byte) (*shareddto.LastDailyInspection, error)
}

View File

@@ -0,0 +1,20 @@
package reserveac
import (
"context"
shareddto "wucher/internal/transport/http/dto/shared"
)
type ReserveAcService interface {
Create(ctx context.Context, row *ReserveAc) error
Update(ctx context.Context, row *ReserveAc) error
Delete(ctx context.Context, id []byte, deletedBy []byte) error
GetByID(ctx context.Context, id []byte) (*ReserveAc, error)
GetActiveByInspectionID(ctx context.Context, inspectionID []byte) (*ReserveAc, error)
List(ctx context.Context, filter string, sort string, limit, offset int) ([]ReserveAc, int64, error)
AircraftExists(ctx context.Context, helicopterID []byte) (bool, error)
FlightInspectionExists(ctx context.Context, inspectionID []byte) (bool, error)
ExistsActiveByInspectionID(ctx context.Context, inspectionID []byte, excludeID []byte) (bool, error)
GetLastDailyInspectionByHelicopterID(ctx context.Context, helicopterID []byte) (*shareddto.LastDailyInspection, error)
}