From 9b5e1465c3973f388d81689b2f2747a1c40b1f92 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 29 Aug 2022 16:05:12 +0800 Subject: [PATCH] add --- internal/cms_api/router.go | 1 - internal/cms_api/user/user.go | 51 +++++------------------------------ pkg/cms_api_struct/user.go | 22 +++++++-------- 3 files changed, 18 insertions(+), 56 deletions(-) diff --git a/internal/cms_api/router.go b/internal/cms_api/router.go index 2987bd026..a9fceeb97 100644 --- a/internal/cms_api/router.go +++ b/internal/cms_api/router.go @@ -54,7 +54,6 @@ func NewGinRouter() *gin.Engine { userRouterGroup.POST("/unblock_user", user.UnblockUser) userRouterGroup.POST("/block_user", user.BlockUser) userRouterGroup.GET("/get_block_users", user.GetBlockUsers) - userRouterGroup.GET("/get_block_user", user.GetBlockUserById) } messageCMSRouterGroup := r2.Group("/message") { diff --git a/internal/cms_api/user/user.go b/internal/cms_api/user/user.go index 97dbc66a9..4c22bc56a 100644 --- a/internal/cms_api/user/user.go +++ b/internal/cms_api/user/user.go @@ -143,15 +143,13 @@ func GetBlockUsers(c *gin.Context) { for _, v := range respPb.BlockUsers { resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{ UserResponse: cms_api_struct.UserResponse{ - UserId: v.User.UserId, - ProfilePhoto: v.User.ProfilePhoto, - Nickname: v.User.Nickname, - IsBlock: v.User.IsBlock, - Birth: v.User.Birth, - PhoneNumber: v.User.PhoneNumber, - Email: v.User.Email, - Gender: int(v.User.Gender), - CreateTime: v.User.CreateTime, + UserID: v.UserInfo.UserID, + FaceURL: v.UserInfo.FaceURL, + Nickname: v.UserInfo.Nickname, + PhoneNumber: v.UserInfo.PhoneNumber, + Email: v.UserInfo.Email, + Gender: int(v.UserInfo.Gender), + // CreateTime: v.UserInfo.CreateTime, }, BeginDisableTime: v.BeginDisableTime, EndDisableTime: v.EndDisableTime, @@ -163,38 +161,3 @@ func GetBlockUsers(c *gin.Context) { log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp) openIMHttp.RespHttp200(c, constant.OK, resp) } - -func GetBlockUserById(c *gin.Context) { - var ( - req cms_api_struct.GetBlockUserRequest - resp cms_api_struct.GetBlockUserResponse - reqPb pb.GetBlockUserByIdReq - ) - if err := c.ShouldBindQuery(&req); err != nil { - log.NewError("0", "BindJSON failed ", err.Error()) - openIMHttp.RespHttp200(c, constant.ErrArgs, nil) - return - } - reqPb.OperationID = utils.OperationIDGenerator() - log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req) - reqPb.UserId = req.UserId - etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID) - if etcdConn == nil { - errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(reqPb.OperationID, errMsg) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) - return - } - client := pb.NewUserClient(etcdConn) - respPb, err := client.GetBlockUserById(context.Background(), &reqPb) - if err != nil { - log.NewError(reqPb.OperationID, "GetBlockUserById rpc failed ", err.Error()) - openIMHttp.RespHttp200(c, err, nil) - return - } - resp.EndDisableTime = respPb.BlockUser.EndDisableTime - resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime - utils.CopyStructFields(&resp, respPb.BlockUser.User) - log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp) - openIMHttp.RespHttp200(c, constant.OK, resp) -} diff --git a/pkg/cms_api_struct/user.go b/pkg/cms_api_struct/user.go index d4902c97a..c4c433a1e 100644 --- a/pkg/cms_api_struct/user.go +++ b/pkg/cms_api_struct/user.go @@ -1,17 +1,17 @@ package cms_api_struct type UserResponse struct { - ProfilePhoto string `json:"profile_photo"` - Nickname string `json:"nick_name"` - UserId string `json:"user_id"` - CreateTime string `json:"create_time,omitempty"` - CreateIp string `json:"create_ip,omitempty"` - LastLoginTime string `json:"last_login_time,omitempty"` - LastLoginIp string `json:"last_login_ip,omitempty"` - LoginTimes int32 `json:"login_times"` - LoginLimit int32 `json:"login_limit"` - IsBlock bool `json:"is_block"` - PhoneNumber string `json:"phone_number"` + FaceURL string `json:"faceURL"` + Nickname string `json:"nickName"` + UserID string `json:"userID"` + CreateTime string `json:"createTime,omitempty"` + CreateIp string `json:"createIp,omitempty"` + LastLoginTime string `json:"lastLoginTime,omitempty"` + LastLoginIp string `json:"lastLoginIP,omitempty"` + LoginTimes int32 `json:"loginTimes"` + LoginLimit int32 `json:"loginLimit"` + IsBlock bool `json:"isBlock"` + PhoneNumber string `json:"phoneNumber"` Email string `json:"email"` Birth string `json:"birth"` Gender int `json:"gender"`