添加user2/GetSelfInfo

This commit is contained in:
gazebo
2019-11-06 10:00:36 +08:00
parent 8d7671f34d
commit 49a4b7b069
3 changed files with 30 additions and 0 deletions

View File

@@ -702,3 +702,11 @@ func LoadUserCart(ctx *jxcontext.Context, userID string, storeIDs []int) (cartIt
err = dao.GetRows(dao.GetDB(), &cartItems, sql, userID, storeIDs)
return cartItems, err
}
func GetSelfInfo(ctx *jxcontext.Context) (user *model.User, err error) {
tokenInfo, err := auth2.GetTokenInfo(ctx.GetToken())
if err == nil {
user, err = dao.GetUserByID(dao.GetDB(), "user_id", tokenInfo.GetID())
}
return user, err
}

View File

@@ -361,3 +361,16 @@ func (c *User2Controller) SaveMyCart() {
return retVal, "", err
})
}
// @Title 得到用户自己的信息
// @Description 得到用户自己的信息
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetSelfInfo [get]
func (c *User2Controller) GetSelfInfo() {
c.callGetSelfInfo(func(params *tUser2GetSelfInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetSelfInfo(params.Ctx)
return retVal, "", err
})
}

View File

@@ -1890,6 +1890,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetSelfInfo",
Router: `/GetSelfInfo`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetStoreRoleList",