36 lines
856 B
Go
36 lines
856 B
Go
package model
|
|
|
|
import (
|
|
"ArmedPolice/utils"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// SysTenant 租户信息数据模型
|
|
type SysTenant struct {
|
|
Model
|
|
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
|
Key string `gorm:"column:key;type:varchar(100);default:null;comment:标识" json:"key"`
|
|
Name string `gorm:"column:name;type:varchar(30);default:null;comment:名称" json:"name"`
|
|
Area
|
|
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
|
ModelDeleted
|
|
ModelAt
|
|
}
|
|
|
|
func (m *SysTenant) TableName() string {
|
|
return "sys_tenant"
|
|
}
|
|
|
|
func (m *SysTenant) BeforeCreate(db *gorm.DB) error {
|
|
snowflake, _ := utils.NewSnowflake(1)
|
|
m.Key = utils.IntToString(snowflake.GetID())
|
|
m.CreatedAt = time.Now()
|
|
return nil
|
|
}
|
|
|
|
func NewSysTenant() *SysTenant {
|
|
return &SysTenant{}
|
|
}
|