init push
This commit is contained in:
58
internal/domain/after_flight_inspection/model.go
Normal file
58
internal/domain/after_flight_inspection/model.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package afterflightinspection
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
type AfterFlightInspection struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
FlightInspectionID []byte `gorm:"type:binary(16);not null;uniqueIndex;column:flight_inspection_id"`
|
||||
OilEngineNR1Checked *string `gorm:"type:varchar(255);null;column:oil_engine_nr1_checked"`
|
||||
OilEngineNR2Checked *string `gorm:"type:varchar(255);null;column:oil_engine_nr2_checked"`
|
||||
HydraulicLHChecked *string `gorm:"type:varchar(255);null;column:hydraulic_lh_checked"`
|
||||
HydraulicRHChecked *string `gorm:"type:varchar(255);null;column:hydraulic_rh_checked"`
|
||||
OilTransmissionMGBChecked *string `gorm:"type:varchar(255);null;column:oil_transmission_mgb_checked"`
|
||||
OilTransmissionIGBChecked *string `gorm:"type:varchar(255);null;column:oil_transmission_igb_checked"`
|
||||
OilTransmissionTGBChecked *string `gorm:"type:varchar(255);null;column:oil_transmission_tgb_checked"`
|
||||
Note *string `gorm:"type:text;column:note"`
|
||||
|
||||
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 (AfterFlightInspection) TableName() string { return "after_flight_inspections" }
|
||||
|
||||
func (a *AfterFlightInspection) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(a.ID) == 0 {
|
||||
a.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidFlightInspectionID = errors.New("flight_inspection_id is invalid")
|
||||
ErrFlightInspectionNotFound = errors.New("flight inspection not found")
|
||||
ErrCapabilitiesUnavailable = errors.New("helicopter capabilities could not be resolved")
|
||||
|
||||
ErrNR1Required = errors.New("oil_engine_nr1_checked is required for this helicopter")
|
||||
ErrNR1NotAvailable = errors.New("NR1 capability not available on this helicopter")
|
||||
ErrNR2Required = errors.New("oil_engine_nr2_checked is required for this helicopter")
|
||||
ErrNR2NotAvailable = errors.New("NR2 capability not available on this helicopter")
|
||||
ErrLHRequired = errors.New("hydraulic_lh_checked is required for this helicopter")
|
||||
ErrLHNotAvailable = errors.New("LH capability not available on this helicopter")
|
||||
ErrRHRequired = errors.New("hydraulic_rh_checked is required for this helicopter")
|
||||
ErrRHNotAvailable = errors.New("RH capability not available on this helicopter")
|
||||
ErrMGBRequired = errors.New("oil_transmission_mgb_checked is required for this helicopter")
|
||||
ErrMGBNotAvailable = errors.New("MGB capability not available on this helicopter")
|
||||
ErrIGBRequired = errors.New("oil_transmission_igb_checked is required for this helicopter")
|
||||
ErrIGBNotAvailable = errors.New("IGB capability not available on this helicopter")
|
||||
ErrTGBRequired = errors.New("oil_transmission_tgb_checked is required for this helicopter")
|
||||
ErrTGBNotAvailable = errors.New("TGB capability not available on this helicopter")
|
||||
)
|
||||
21
internal/domain/after_flight_inspection/repository.go
Normal file
21
internal/domain/after_flight_inspection/repository.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package afterflightinspection
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
Upsert(ctx context.Context, row *AfterFlightInspection) error
|
||||
GetByFlightInspectionID(ctx context.Context, flightInspectionID []byte) (*AfterFlightInspection, error)
|
||||
DeleteByFlightInspectionID(ctx context.Context, flightInspectionID []byte) error
|
||||
FlightInspectionExists(ctx context.Context, flightInspectionID []byte) (bool, error)
|
||||
GetHelicopterCapabilities(ctx context.Context, flightInspectionID []byte) (*HelicopterCapabilities, error)
|
||||
}
|
||||
|
||||
type HelicopterCapabilities struct {
|
||||
NR1 bool
|
||||
NR2 bool
|
||||
LH bool
|
||||
RH bool
|
||||
MGB bool
|
||||
IGB bool
|
||||
TGB bool
|
||||
}
|
||||
20
internal/domain/after_flight_inspection/service.go
Normal file
20
internal/domain/after_flight_inspection/service.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package afterflightinspection
|
||||
|
||||
import "context"
|
||||
|
||||
type Service interface {
|
||||
Upsert(ctx context.Context, flightInspectionID []byte, req *UpsertRequest) (*AfterFlightInspection, error)
|
||||
GetByFlightInspectionID(ctx context.Context, flightInspectionID []byte) (*AfterFlightInspection, error)
|
||||
DeleteByFlightInspectionID(ctx context.Context, flightInspectionID []byte) error
|
||||
}
|
||||
|
||||
type UpsertRequest struct {
|
||||
OilEngineNR1Checked *string
|
||||
OilEngineNR2Checked *string
|
||||
HydraulicLHChecked *string
|
||||
HydraulicRHChecked *string
|
||||
OilTransmissionMGBChecked *string
|
||||
OilTransmissionIGBChecked *string
|
||||
OilTransmissionTGBChecked *string
|
||||
Note *string
|
||||
}
|
||||
Reference in New Issue
Block a user