添加User.Avatar
This commit is contained in:
@@ -52,6 +52,7 @@ type IUser interface {
|
|||||||
GetMobile() string
|
GetMobile() string
|
||||||
GetEmail() string
|
GetEmail() string
|
||||||
GetName() string
|
GetName() string
|
||||||
|
GetAvatar() string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type UserBasic struct {
|
|||||||
Mobile string `json:"mobile"`
|
Mobile string `json:"mobile"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Avatar string `json:"avatar"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserBasic) GetID() string {
|
func (u *UserBasic) GetID() string {
|
||||||
@@ -39,6 +40,10 @@ func (u *UserBasic) GetName() string {
|
|||||||
return u.Name
|
return u.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserBasic) GetAvatar() string {
|
||||||
|
return u.Avatar
|
||||||
|
}
|
||||||
|
|
||||||
func (u *UserBasic) UpdateByIUser(user IUser) {
|
func (u *UserBasic) UpdateByIUser(user IUser) {
|
||||||
if user != nil {
|
if user != nil {
|
||||||
u.UserID = user.GetID()
|
u.UserID = user.GetID()
|
||||||
@@ -46,6 +51,7 @@ func (u *UserBasic) UpdateByIUser(user IUser) {
|
|||||||
u.Mobile = user.GetMobile()
|
u.Mobile = user.GetMobile()
|
||||||
u.Email = user.GetEmail()
|
u.Email = user.GetEmail()
|
||||||
u.Name = user.GetName()
|
u.Name = user.GetName()
|
||||||
|
u.Avatar = user.GetAvatar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ func (a *Auther) VerifySecret(state, code string) (authBindEx *auth2.AuthBindEx,
|
|||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if authBindEx, err = a.UnionFindAuthBind(a.authType, []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
if authBindEx, err = a.UnionFindAuthBind(a.authType, []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
||||||
authBindEx.UserHint = &auth2.UserBasic{
|
authBindEx.UserHint = &auth2.UserBasic{
|
||||||
Name: wxUserinfo.NickName,
|
Name: wxUserinfo.NickName,
|
||||||
|
Avatar: wxUserinfo.HeadImgURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,14 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
|||||||
user.Type = model.UserTypeConsumer
|
user.Type = model.UserTypeConsumer
|
||||||
if inAuthInfo.AuthBindInfo.Type == dingding.AuthTypeStaff {
|
if inAuthInfo.AuthBindInfo.Type == dingding.AuthTypeStaff {
|
||||||
user.Type |= model.UserTypeOperator
|
user.Type |= model.UserTypeOperator
|
||||||
} else {
|
} else if user.Mobile != nil {
|
||||||
user.Type |= model.UserTypeStoreBoss
|
user.Type |= model.UserTypeStoreBoss
|
||||||
}
|
}
|
||||||
createName += "," + inAuthInfo.GetAuthID()
|
createName += "," + inAuthInfo.GetAuthID()
|
||||||
authType = inAuthInfo.GetAuthType()
|
authType = inAuthInfo.GetAuthType()
|
||||||
|
if user.Avatar == "" {
|
||||||
|
user.Avatar = inAuthInfo.GetAvatar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err = CreateUser(user, utils.LimitUTF8StringLen(createName, 32)); err == nil {
|
if err = CreateUser(user, utils.LimitUTF8StringLen(createName, 32)); err == nil {
|
||||||
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
|
userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP())
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type User struct {
|
|||||||
Name string `orm:"size(48);index" json:"name" compact:"name"` // 外部显示标识(当前可以重复)
|
Name string `orm:"size(48);index" json:"name" compact:"name"` // 外部显示标识(当前可以重复)
|
||||||
Mobile *string `orm:"size(32);null" json:"mobile" compact:"mobile"`
|
Mobile *string `orm:"size(32);null" json:"mobile" compact:"mobile"`
|
||||||
Email *string `orm:"size(32);null" json:"email" compact:"email"`
|
Email *string `orm:"size(32);null" json:"email" compact:"email"`
|
||||||
|
Avatar string `orm:"size(255)" json:"avatar" compact:"avatar"` // 头像
|
||||||
Status int8 `json:"status" compact:"status"`
|
Status int8 `json:"status" compact:"status"`
|
||||||
Type int8 `json:"type" compact:"type"` // 用户类型
|
Type int8 `json:"type" compact:"type"` // 用户类型
|
||||||
|
|
||||||
@@ -80,6 +81,10 @@ func (user *User) GetName() string {
|
|||||||
return user.Name
|
return user.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (user *User) GetAvatar() string {
|
||||||
|
return user.Avatar
|
||||||
|
}
|
||||||
|
|
||||||
type StoreBoss struct {
|
type StoreBoss struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
UserID string `orm:"size(48);column(user_id);unique" json:"userID"` // 内部唯一标识
|
UserID string `orm:"size(48);column(user_id);unique" json:"userID"` // 内部唯一标识
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetComposedCode(c *beego.Controller, code string) (composedCode string) {
|
func GetComposedCode(c *beego.Controller, code string) (composedCode string) {
|
||||||
@@ -295,3 +296,26 @@ func (c *Auth2Controller) ChangePassword() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 解密小程序数据
|
||||||
|
// @Description 解密小程序数据
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param data formData string true "加密数据"
|
||||||
|
// @Param iv formData string true "iv"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /MiniDecryptData [post]
|
||||||
|
func (c *Auth2Controller) MiniDecryptData() {
|
||||||
|
c.callMiniDecryptData(func(params *tAuth2MiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
authInfo, err := params.Ctx.GetV2AuthInfo()
|
||||||
|
if err == nil {
|
||||||
|
if retVal, err = weixin.AutherObjMini.DecryptData(authInfo, params.Data, params.Iv); err == nil {
|
||||||
|
if user:= params.Ctx.GetFullUser(); user != nil {
|
||||||
|
user.Avatar = "avatar"
|
||||||
|
dao.UpdateEntity(dao.GetDB(), user, "Avatar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -151,6 +151,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "MiniDecryptData",
|
||||||
|
Router: `/MiniDecryptData`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "RemoveAuthBind",
|
Method: "RemoveAuthBind",
|
||||||
|
|||||||
Reference in New Issue
Block a user