feat:优化项目信息
This commit is contained in:
48
app/common/model/user_identity.go
Normal file
48
app/common/model/user_identity.go
Normal file
@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserIdentity 用户身份管理数据模型
|
||||
type UserIdentity struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_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"`
|
||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||
FixedPhone string `gorm:"column:fixed_phone;type:varchar(20);default:null;comment:固定电话" json:"fixed_phone"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
IsSelected UserIdentitySelected `gorm:"column:is_selected;type:tinyint(1);default:0;comment:最后一次选中的身份信息" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// UserIdentitySelected 身份选中状态
|
||||
type UserIdentitySelected int
|
||||
|
||||
const (
|
||||
// UserIdentitySelectedForNo 未选中
|
||||
UserIdentitySelectedForNo UserIdentitySelected = iota
|
||||
// UserIdentitySelectedForYes 已选中
|
||||
UserIdentitySelectedForYes
|
||||
)
|
||||
|
||||
func (m *UserIdentity) TableName() string {
|
||||
return m.NewTableName("user_identity")
|
||||
}
|
||||
|
||||
func (m *UserIdentity) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserIdentity() *UserIdentity {
|
||||
return &UserIdentity{}
|
||||
}
|
Reference in New Issue
Block a user