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,40 @@
package dul
import (
"time"
"gorm.io/gorm"
filemanager "wucher/internal/domain/file_manager"
"wucher/internal/domain/base"
"wucher/internal/shared/pkg/uuidv7"
)
type DUL struct {
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
No uint64 `gorm:"type:bigint unsigned;not null;autoIncrement;uniqueIndex;column:no"`
Name string `gorm:"type:varchar(128);not null;column:name"`
Date time.Time `gorm:"type:date;not null;column:date"`
Info string `gorm:"type:text;column:info"`
BaseID []byte `gorm:"type:binary(16);column:base_id"`
Base *base.Base `gorm:"foreignKey:BaseID;references:ID"`
Images []*filemanager.Attachment `gorm:"-"`
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"`
DeletedAt *time.Time `gorm:"column:deleted_at"`
DeletedBy []byte `gorm:"type:binary(16);column:deleted_by"`
}
func (DUL) TableName() string { return "duls" }
func (f *DUL) BeforeCreate(tx *gorm.DB) error {
if len(f.ID) == 0 {
f.ID = uuidv7.MustBytes()
}
return nil
}

View File

@@ -0,0 +1,15 @@
package dul
import "context"
type Repository interface {
Create(ctx context.Context, row *DUL) error
Update(ctx context.Context, row *DUL) error
Delete(ctx context.Context, id []byte) error
GetByID(ctx context.Context, id []byte) (*DUL, error)
List(ctx context.Context, filter, sort string, limit, offset int, baseIDs [][]byte) ([]DUL, int64, error)
}
type TransactionalRepository interface {
WithTransaction(ctx context.Context, fn func(repo Repository) error) error
}

View File

@@ -0,0 +1,11 @@
package dul
import "context"
type Service interface {
Create(ctx context.Context, row *DUL) error
Update(ctx context.Context, row *DUL) error
Delete(ctx context.Context, id []byte, actorID []byte) error
GetByID(ctx context.Context, id []byte) (*DUL, error)
List(ctx context.Context, filter, sort string, limit, offset int, baseIDs [][]byte) ([]DUL, int64, error)
}