init push
This commit is contained in:
35
internal/domain/flight_inspection/model.go
Normal file
35
internal/domain/flight_inspection/model.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
13
internal/domain/flight_inspection/repository.go
Normal file
13
internal/domain/flight_inspection/repository.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package flightinspection
|
||||
|
||||
import "context"
|
||||
|
||||
type FlightInspectionRepository interface {
|
||||
Create(ctx context.Context, row *FlightInspection) error
|
||||
Update(ctx context.Context, row *FlightInspection) error
|
||||
GetByID(ctx context.Context, id []byte) (*FlightInspection, error)
|
||||
List(ctx context.Context, sort string, limit, offset int) ([]FlightInspection, int64, error)
|
||||
}
|
||||
|
||||
// Repository is kept as backward-compatible alias for older services/wirings.
|
||||
type Repository = FlightInspectionRepository
|
||||
10
internal/domain/flight_inspection/service.go
Normal file
10
internal/domain/flight_inspection/service.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package flightinspection
|
||||
|
||||
import "context"
|
||||
|
||||
type FlightInspectionService interface {
|
||||
CreateDraft(ctx context.Context, row *FlightInspection) error
|
||||
Update(ctx context.Context, row *FlightInspection) error
|
||||
GetByID(ctx context.Context, id []byte) (*FlightInspection, error)
|
||||
List(ctx context.Context, sort string, limit, offset int) ([]FlightInspection, int64, error)
|
||||
}
|
||||
Reference in New Issue
Block a user