Files
fm_be/internal/domain/vocation/model.go
2026-07-16 22:16:45 +07:00

33 lines
926 B
Go

package vocation
import (
"time"
"gorm.io/gorm"
"wucher/internal/shared/pkg/uuidv7"
)
type Vocation struct {
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
Name string `gorm:"type:varchar(64);uniqueIndex;not null;column:name"`
SortKey *int `gorm:"column:sortkey"`
Note string `gorm:"type:varchar(255);column:note"`
IsActive bool `gorm:"type:tinyint(1);index;not null;default:1;column:is_active"`
CreatedAt time.Time
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
UpdatedAt time.Time
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 (Vocation) TableName() string { return "vocations" }
func (v *Vocation) BeforeCreate(tx *gorm.DB) error {
if len(v.ID) == 0 {
v.ID = uuidv7.MustBytes()
}
return nil
}