mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 03:26:57 +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},
|
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}}
|
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
@ -79,11 +79,12 @@ import (
|
|||||||
func GetUserInfo(c *gin.Context) {
|
func GetUserInfo(c *gin.Context) {
|
||||||
params := api.GetUserInfoReq{}
|
params := api.GetUserInfoReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
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()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req := &rpc.GetUserInfoReq{}
|
req := &rpc.GetUserInfoReq{}
|
||||||
utils.CopyStructFields(&req, params)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
var ok bool
|
var ok bool
|
||||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -102,21 +103,20 @@ func GetUserInfo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := api.GetUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
resp := api.GetUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: RpcResp.UserInfoList}
|
||||||
resp.UserInfoList = RpcResp.UserInfoList
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateUserInfo(c *gin.Context) {
|
func UpdateUserInfo(c *gin.Context) {
|
||||||
params := api.GetUserInfoReq{}
|
params := api.UpdateUserInfoReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
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()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req := &rpc.UpdateUserInfoReq{}
|
req := &rpc.UpdateUserInfoReq{}
|
||||||
utils.CopyStructFields(&req, params)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
var ok bool
|
var ok bool
|
||||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -134,6 +134,7 @@ func UpdateUserInfo(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.CommonResp.ErrCode, "errMsg": RpcResp.CommonResp.ErrMsg})
|
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", RpcResp.CommonResp)
|
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
|
var userInfo sdkws.FriendRequest
|
||||||
utils.CopyStructFields(&userInfo, applyUserInfo)
|
utils.CopyStructFields(&userInfo, applyUserInfo)
|
||||||
appleUserList = append(appleUserList, &userInfo)
|
appleUserList = append(appleUserList, &userInfo)
|
||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(req.CommID.OperationID, "rpc GetFriendApplyList ok", pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList})
|
log.NewInfo(req.CommID.OperationID, "rpc GetFriendApplyList ok", pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList})
|
||||||
return &pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList}, nil
|
return &pbFriend.GetFriendApplyListResp{FriendRequestList: appleUserList}, nil
|
||||||
|
@ -26,3 +26,12 @@ type GetUserInfoResp struct {
|
|||||||
CommResp
|
CommResp
|
||||||
UserInfoList []*open_im_sdk.UserInfo `json:"data"`
|
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