36 lines
997 B
Go
36 lines
997 B
Go
package flightinspection
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"wucher/internal/shared/pkg/uuidv7"
|
|
)
|
|
|
|
const (
|
|
StatusDraft = "Draft"
|
|
StatusInProgress = "InProgress"
|
|
StatusCompleted = "Completed"
|
|
)
|
|
|
|
type FlightInspection struct {
|
|
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
|
InspectionDate time.Time `gorm:"type:date;not null;index;column:inspection_date"`
|
|
Status string `gorm:"type:varchar(20);not null;default:Draft;index;check:chk_flight_inspection_status,status IN ('Draft','InProgress','Completed');column:status"`
|
|
|
|
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"`
|
|
}
|
|
|
|
func (FlightInspection) TableName() string { return "flight_inspections" }
|
|
|
|
func (f *FlightInspection) BeforeCreate(tx *gorm.DB) error {
|
|
if len(f.ID) == 0 {
|
|
f.ID = uuidv7.MustBytes()
|
|
}
|
|
return nil
|
|
}
|