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