init push
This commit is contained in:
37
internal/domain/flight_inspection_file_checklist/model.go
Normal file
37
internal/domain/flight_inspection_file_checklist/model.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package flightinspectionfilechecklist
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
flightinspection "wucher/internal/domain/flight_inspection"
|
||||
helicopterfile "wucher/internal/domain/helicopter_file"
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
type FlightInspectionFileChecklist struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
|
||||
IsDone bool `gorm:"type:tinyint(1);not null;default:0;index:idx_flight_inspection_file_checklists_inspection_sorted;column:is_done"`
|
||||
|
||||
HelicopterFileID []byte `gorm:"type:binary(16);not null;index:idx_flight_inspection_file_checklists_file;uniqueIndex:uidx_flight_inspection_file_checklists_inspection_file,priority:2;column:helicopter_file_id"`
|
||||
FlightInspectionID []byte `gorm:"type:binary(16);not null;index:idx_flight_inspection_file_checklists_inspection;index:idx_flight_inspection_file_checklists_inspection_sorted;uniqueIndex:uidx_flight_inspection_file_checklists_inspection_file,priority:1;column:flight_inspection_id"`
|
||||
|
||||
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"`
|
||||
|
||||
HelicopterFile *helicopterfile.HelicopterFile `gorm:"foreignKey:HelicopterFileID;references:ID"`
|
||||
FlightInspection *flightinspection.FlightInspection `gorm:"foreignKey:FlightInspectionID;references:ID"`
|
||||
}
|
||||
|
||||
func (FlightInspectionFileChecklist) TableName() string { return "flight_inspection_file_checklists" }
|
||||
|
||||
func (m *FlightInspectionFileChecklist) BeforeCreate(_ *gorm.DB) error {
|
||||
if len(m.ID) == 0 {
|
||||
m.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package flightinspectionfilechecklist
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
Create(ctx context.Context, row *FlightInspectionFileChecklist) error
|
||||
Update(ctx context.Context, row *FlightInspectionFileChecklist) error
|
||||
Delete(ctx context.Context, id []byte) error
|
||||
GetByID(ctx context.Context, id []byte) (*FlightInspectionFileChecklist, error)
|
||||
List(ctx context.Context, filter string, sort string, limit, offset int) ([]FlightInspectionFileChecklist, int64, error)
|
||||
ListByInspectionID(ctx context.Context, inspectionID []byte) ([]FlightInspectionFileChecklist, error)
|
||||
FlightInspectionExists(ctx context.Context, inspectionID []byte) (bool, error)
|
||||
HelicopterFileExists(ctx context.Context, helicopterFileID []byte) (bool, error)
|
||||
}
|
||||
14
internal/domain/flight_inspection_file_checklist/service.go
Normal file
14
internal/domain/flight_inspection_file_checklist/service.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package flightinspectionfilechecklist
|
||||
|
||||
import "context"
|
||||
|
||||
type Service interface {
|
||||
Create(ctx context.Context, row *FlightInspectionFileChecklist) error
|
||||
Update(ctx context.Context, row *FlightInspectionFileChecklist) error
|
||||
Delete(ctx context.Context, id []byte) error
|
||||
GetByID(ctx context.Context, id []byte) (*FlightInspectionFileChecklist, error)
|
||||
List(ctx context.Context, filter string, sort string, limit, offset int) ([]FlightInspectionFileChecklist, int64, error)
|
||||
ListByInspectionID(ctx context.Context, inspectionID []byte) ([]FlightInspectionFileChecklist, error)
|
||||
FlightInspectionExists(ctx context.Context, inspectionID []byte) (bool, error)
|
||||
HelicopterFileExists(ctx context.Context, helicopterFileID []byte) (bool, error)
|
||||
}
|
||||
Reference in New Issue
Block a user