package entities import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) type OutletSetting struct { ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"` OutletID uuid.UUID `gorm:"type:uuid;not null;index" json:"outlet_id" validate:"required"` Key string `gorm:"not null;size:255;index" json:"key" validate:"required,min=1,max=255"` Value string `gorm:"type:text" json:"value"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` Outlet Outlet `gorm:"foreignKey:OutletID" json:"outlet,omitempty"` } func (os *OutletSetting) BeforeCreate(tx *gorm.DB) error { if os.ID == uuid.Nil { os.ID = uuid.New() } return nil } func (OutletSetting) TableName() string { return "outlet_settings" }