41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
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
|
|
}
|