38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package federal_state
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"wucher/internal/domain/land"
|
|
"wucher/internal/shared/pkg/uuidv7"
|
|
)
|
|
|
|
type FederalState struct {
|
|
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
|
LandID []byte `gorm:"type:binary(16);column:land_id"`
|
|
Name string `gorm:"type:varchar(128);not null;column:name"`
|
|
Note string `gorm:"type:text;column:note"`
|
|
SortKey *int `gorm:"column:sortkey"`
|
|
IsActive bool `gorm:"type:tinyint(1);index;not null;default:1;column:is_active"`
|
|
|
|
Land *land.Land `gorm:"foreignKey:LandID;references: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"`
|
|
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
|
DeletedBy []byte `gorm:"type:binary(16);column:deleted_by"`
|
|
}
|
|
|
|
func (FederalState) TableName() string { return "federal_states" }
|
|
|
|
func (f *FederalState) BeforeCreate(tx *gorm.DB) error {
|
|
if len(f.ID) == 0 {
|
|
f.ID = uuidv7.MustBytes()
|
|
}
|
|
return nil
|
|
}
|