feat:完善信息
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -10,20 +11,48 @@ import (
|
||||
type UserManage struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;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"`
|
||||
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
||||
Selected UserManageSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;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:"-"`
|
||||
IdentityInfo string `gorm:"column:identity_info;type:varchar(255);default:null;comment:身份信息" json:"-"`
|
||||
IsSelected UserManageSelected `gorm:"column:is_selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type IUserIdentity interface {
|
||||
Analysis(src string) interface{}
|
||||
}
|
||||
|
||||
type (
|
||||
// UserIdentityForCompany 公司信息
|
||||
UserIdentityForCompany struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
}
|
||||
// UserIdentityForExpert 专家信息
|
||||
UserIdentityForExpert struct {
|
||||
Industry string `json:"industry"`
|
||||
Keyword string `json:"keyword"`
|
||||
Research string `json:"research"`
|
||||
}
|
||||
)
|
||||
|
||||
func (this *UserIdentityForCompany) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *UserIdentityForExpert) Analysis(src string) interface{} {
|
||||
utils.FromJSON(src, this)
|
||||
return this
|
||||
}
|
||||
|
||||
type UserManageSelected int
|
||||
|
||||
const (
|
||||
@ -44,8 +73,22 @@ func (m *UserManage) BeforeCreate(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserManage) GetOtherAttribute() {
|
||||
func (m *UserManage) GetIdentityInfoAttribute() interface{} {
|
||||
var manage IUserIdentity
|
||||
|
||||
switch m.Identity {
|
||||
case config.TenantUserIdentityForCompany:
|
||||
manage = new(UserIdentityForCompany)
|
||||
break
|
||||
case config.TenantUserIdentityForExpert:
|
||||
manage = new(UserIdentityForExpert)
|
||||
break
|
||||
}
|
||||
return manage.Analysis(m.IdentityInfo)
|
||||
}
|
||||
|
||||
func (m *UserManage) SetIdentityInfoAttribute(src IUserIdentity) {
|
||||
m.IdentityInfo = utils.AnyToJSON(src)
|
||||
}
|
||||
|
||||
func NewUserManage() *UserManage {
|
||||
|
||||
Reference in New Issue
Block a user