54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package model
|
|
|
|
import (
|
|
"SciencesServer/utils"
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
// UserTenant 用户租户信息
|
|
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"`
|
|
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
|
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
|
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"`
|
|
Selected UserTenantSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
|
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
|
ModelDeleted
|
|
ModelAt
|
|
}
|
|
|
|
type UserTenantSelected int
|
|
|
|
const (
|
|
// UserTenantSelectedForNo 未选中
|
|
UserTenantSelectedForNo UserTenantSelected = iota
|
|
// UserTenantSelectedForYes 已选中
|
|
UserTenantSelectedForYes
|
|
)
|
|
|
|
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 (m *UserTenant) GetOtherAttribute() {
|
|
|
|
}
|
|
|
|
func NewUserTenant() *UserTenant {
|
|
return &UserTenant{}
|
|
}
|