feat:完善入驻信息管理
This commit is contained in:
@ -18,7 +18,7 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
|
||||
type (
|
||||
InstanceLoginParams struct {
|
||||
UID uint64
|
||||
Name, Mobile string
|
||||
Avatar, Name, Mobile string
|
||||
Identity, SelectIdentity int
|
||||
Status model.AccountStatusKind
|
||||
}
|
||||
@ -36,6 +36,7 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
_session := session.NewEnterprise()
|
||||
_session.Token = token
|
||||
_session.UID = params.UID
|
||||
_session.Avatar = params.Avatar
|
||||
_session.Name = params.Name
|
||||
_session.Mobile = params.Mobile
|
||||
_session.Identity = params.Identity
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
model3 "SciencesServer/app/api/enterprise/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/handle"
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
@ -59,7 +60,7 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
// 查询账号信息
|
||||
mUserInstance := model3.NewUserInstance()
|
||||
|
||||
if isExist, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "mobile", "status"},
|
||||
if isExist, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "avatar", "name", "mobile", "status"},
|
||||
model2.NewWhere("mobile", params.Captcha.Mobile)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -81,8 +82,8 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
||||
}
|
||||
RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
@ -95,7 +96,7 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
}
|
||||
mUserInstance := model3.NewUserInstance()
|
||||
|
||||
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "mobile", "password", "salt", "status"},
|
||||
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "avatar", "mobile", "password", "salt", "status"},
|
||||
model2.NewWhere("mobile", params.Password.Account))
|
||||
|
||||
if err != nil {
|
||||
@ -113,8 +114,8 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
return nil, err
|
||||
}
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
|
@ -17,6 +17,7 @@ type InstanceHandle func(session *session.Enterprise) *Instance
|
||||
type (
|
||||
// InstanceInfo 基本信息
|
||||
InstanceInfo struct {
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Identity int `json:"identity"` // 具体身份
|
||||
SelectIdentity int `json:"select_identity"` // 最后一次选中的身份信息
|
||||
@ -32,7 +33,7 @@ type (
|
||||
|
||||
// Info 基本信息
|
||||
func (c *Instance) Info() *InstanceInfo {
|
||||
return &InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}
|
||||
return &InstanceInfo{Avatar: c.Avatar, Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}
|
||||
}
|
||||
|
||||
// BindMobile 绑定手机号码
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
|
||||
type SysUser struct {
|
||||
Model
|
||||
Local
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_sys_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Account string `gorm:"column:account;type:varchar(50);default:null;comment:账户名" json:"account"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
|
@ -9,13 +9,15 @@ import (
|
||||
// UserInstance 账号信息
|
||||
type UserInstance struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_tenant_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Source UserInstanceSource `gorm:"column:source;type:tinyint(1);default:1;comment:账号来源" json:"source"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"`
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:null;comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:null;comment:盐值" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_tenant_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Source UserInstanceSource `gorm:"column:source;type:tinyint(1);default:1;comment:账号来源" json:"source"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"`
|
||||
Gender
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:null;comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:null;comment:盐值" json:"-"`
|
||||
AccountStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
@ -44,6 +46,17 @@ func (m *UserInstance) BeforeCreate(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserInstance) GetAvatarAttribute(domain string) string {
|
||||
if m.Avatar == "" {
|
||||
return ""
|
||||
}
|
||||
compile := "^(http|https):"
|
||||
if utils.ValidateCompile(m.Avatar, compile) {
|
||||
return m.Avatar
|
||||
}
|
||||
return domain + m.Avatar
|
||||
}
|
||||
|
||||
func (m *UserInstance) SetPasswordAttribute() {
|
||||
m.Salt = utils.GetRandomString(8)
|
||||
m.Password = utils.HashString([]byte(utils.Md5String(m.Password, m.Salt)))
|
||||
|
@ -10,6 +10,7 @@ type Enterprise struct {
|
||||
Token string `json:"token"` // token
|
||||
UID uint64 `json:"uid"` // 唯一标识ID
|
||||
ManageUID uint64 `json:"manage_uid"` // 管理平台用户唯一ID
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Mobile string `json:"mobile"` // 手机号码
|
||||
Identity int `json:"identity"` // 总身份信息
|
||||
|
@ -51,7 +51,7 @@ cache:
|
||||
redis:
|
||||
addr: "192.168.0.188:6379"
|
||||
password: ABCabc01!
|
||||
db: 4
|
||||
db: 6
|
||||
max_active: 0
|
||||
max_idle: 1000
|
||||
idle_timeout: 240
|
||||
|
@ -37,11 +37,17 @@ func TestReplaceCompile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateCompile(t *testing.T) {
|
||||
src := "2134"
|
||||
//src := "2134"
|
||||
//
|
||||
//t.Log(src)
|
||||
//
|
||||
//compile := "^[\\w-.:]{4,32}$"
|
||||
//status := ValidateCompile(src, compile)
|
||||
//t.Log(status)
|
||||
|
||||
src := "htt2ps:2134"
|
||||
t.Log(src)
|
||||
|
||||
compile := "^[\\w-.:]{4,32}$"
|
||||
compile := "^(http|https):"
|
||||
status := ValidateCompile(src, compile)
|
||||
t.Log(status)
|
||||
}
|
||||
|
Reference in New Issue
Block a user