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,46 @@
package helicopterfile
import (
"time"
"gorm.io/gorm"
filemanager "wucher/internal/domain/file_manager"
"wucher/internal/domain/helicopter"
"wucher/internal/shared/pkg/uuidv7"
)
const (
SectionBeforeFirstFlightInspection = "bfi"
SectionFlightPreparationAndWB = "fpwb"
SectionAfterLastFlightInspection = "afi"
)
type HelicopterFile struct {
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
Section string `gorm:"type:varchar(64);not null;index;check:chk_helicopter_files_section,section IN ('bfi','fpwb','afi');column:section"`
Position int `gorm:"column:position;not null;default:1"`
IsMandatory bool `gorm:"column:is_mandatory;not null;default:false"`
HelicopterID []byte `gorm:"type:binary(16);not null;index;column:helicopter_id"`
FileAttachmentID []byte `gorm:"type:binary(16);index;column:file_attachment_id"`
SourceFileID []byte `gorm:"type:binary(16);index;column:source_file_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"`
Helicopter *helicopter.Helicopter `gorm:"foreignKey:HelicopterID;references:ID"`
FileAttachment *filemanager.Attachment `gorm:"foreignKey:FileAttachmentID;references:ID"`
SourceFile *filemanager.File `gorm:"foreignKey:SourceFileID;references:ID"`
}
func (HelicopterFile) TableName() string { return "helicopter_files" }
func (m *HelicopterFile) BeforeCreate(_ *gorm.DB) error {
if len(m.ID) == 0 {
m.ID = uuidv7.MustBytes()
}
return nil
}

View File

@@ -0,0 +1,17 @@
package helicopterfile
import "context"
type Repository interface {
Create(ctx context.Context, row *HelicopterFile) error
Update(ctx context.Context, row *HelicopterFile) error
Delete(ctx context.Context, id []byte) error
GetByID(ctx context.Context, id []byte) (*HelicopterFile, error)
List(ctx context.Context, filter string, sort string, limit, offset int) ([]HelicopterFile, int64, error)
ListPendingAttachments(ctx context.Context, limit int) ([]HelicopterFile, error)
ListPendingAttachmentsBySourceFileID(ctx context.Context, sourceFileID []byte, limit int) ([]HelicopterFile, error)
ListByHelicopter(ctx context.Context, helicopterID []byte) ([]HelicopterFile, error)
ListByHelicopterAndSection(ctx context.Context, helicopterID []byte, section string) ([]HelicopterFile, error)
HelicopterExists(ctx context.Context, helicopterID []byte) (bool, error)
AttachmentExists(ctx context.Context, attachmentID []byte) (bool, error)
}

View File

@@ -0,0 +1,59 @@
package helicopterfile
import (
"context"
filemanager "wucher/internal/domain/file_manager"
)
type BulkItemError struct {
Status int
Title string
Detail string
}
type UploadIntentBulkInput struct {
Type string
Name string
ContentType string
SizeBytes int64
}
type UploadIntentBulkItemResult struct {
Index int
Success bool
Grant *filemanager.FileUploadIntentGrant
Error *BulkItemError
}
type CreateBulkInput struct {
Type string
Section string
Position *int
IsMandatory *bool
HelicopterID string
UploadIntentUUID string
FileName string
FolderUUID *string
}
type CreateBulkItemResult struct {
Index int
Success bool
Row *HelicopterFile
Error *BulkItemError
}
type Service interface {
Create(ctx context.Context, row *HelicopterFile) error
Update(ctx context.Context, row *HelicopterFile) error
Delete(ctx context.Context, id []byte) error
GetByID(ctx context.Context, id []byte) (*HelicopterFile, error)
List(ctx context.Context, filter string, sort string, limit, offset int) ([]HelicopterFile, int64, error)
ListByHelicopter(ctx context.Context, helicopterID []byte) ([]HelicopterFile, error)
ListByHelicopterAndSection(ctx context.Context, helicopterID []byte, section string) ([]HelicopterFile, error)
HelicopterExists(ctx context.Context, helicopterID []byte) (bool, error)
AttachmentExists(ctx context.Context, attachmentID []byte) (bool, error)
RequestUploadIntentsBulk(ctx context.Context, inputs []UploadIntentBulkInput, actorID []byte) []UploadIntentBulkItemResult
CreateFromUploadIntentsBulk(ctx context.Context, inputs []CreateBulkInput, actorID []byte) []CreateBulkItemResult
}