feat:完善信息
This commit is contained in:
@ -1,8 +1,15 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserTenant struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_tenant_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_tenant_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
@ -29,6 +36,13 @@ func (m *UserTenant) TableName() string {
|
||||
return m.NewTableName("user_tenant")
|
||||
}
|
||||
|
||||
func (m *UserTenant) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserTenant() *UserTenant {
|
||||
return &UserTenant{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user