mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
tidy code
This commit is contained in:
parent
141936e609
commit
6d589a1204
@ -81,6 +81,6 @@ func UserToken(c *gin.Context) {
|
||||
|
||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
@ -79,11 +79,12 @@ import (
|
||||
func GetUserInfo(c *gin.Context) {
|
||||
params := api.GetUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
utils.CopyStructFields(&req, params)
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
if !ok {
|
||||
@ -102,21 +103,20 @@ func GetUserInfo(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
resp.UserInfoList = RpcResp.UserInfoList
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
resp := api.GetUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: RpcResp.UserInfoList}
|
||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
params := api.GetUserInfoReq{}
|
||||
params := api.UpdateUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.UpdateUserInfoReq{}
|
||||
utils.CopyStructFields(&req, params)
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
if !ok {
|
||||
@ -134,6 +134,7 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.CommonResp.ErrCode, "errMsg": RpcResp.CommonResp.ErrMsg})
|
||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", RpcResp.CommonResp)
|
||||
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
@ -434,7 +434,6 @@ func (s *friendServer) GetFriendApplyList(ctx context.Context, req *pbFriend.Get
|
||||
var userInfo sdkws.FriendRequest
|
||||
utils.CopyStructFields(&userInfo, applyUserInfo)
|
||||
appleUserList = append(appleUserList, &userInfo)
|
||||
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "rpc GetFriendApplyList ok", pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList})
|
||||
return &pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList}, nil
|
||||
|
@ -26,3 +26,12 @@ type GetUserInfoResp struct {
|
||||
CommResp
|
||||
UserInfoList []*open_im_sdk.UserInfo `json:"data"`
|
||||
}
|
||||
|
||||
type UpdateUserInfoReq struct {
|
||||
UserInfo
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type UpdateUserInfoResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user