Refactor code

pull/131/head
wenxu12345 3 years ago
parent cc5125d51d
commit 81aaa95170

@ -338,7 +338,7 @@ func ApplicationGroupResponse(c *gin.Context) {
return
}
req := &rpc.GroupApplicationResponseReq{}
utils.CopyStructFields(req, params)
utils.CopyStructFields(req, &params)
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
if !ok {
@ -357,9 +357,9 @@ func ApplicationGroupResponse(c *gin.Context) {
return
}
resp := api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}
c.JSON(http.StatusOK, resp)
resp := api.ApplicationGroupResponseResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
log.NewInfo(req.OperationID, "ApplicationGroupResponse api return ", resp)
c.JSON(http.StatusOK, resp)
}
func JoinGroup(c *gin.Context) {

@ -432,23 +432,20 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
log.NewInfo(req.OperationID, "GroupApplicationResponse args ", req.String())
groupRequest := imdb.GroupRequest{}
utils.CopyStructFields(&groupRequest, req)
groupRequest.UserID = req.FromUserID
groupRequest.GroupID = req.GroupID
groupRequest.HandledTime = time.Now()
groupRequest.HandleResult = req.HandleResult
groupRequest.HandleUserID = req.OpUserID
groupRequest.HandledMsg = req.HandledMsg
err := imdb.UpdateGroupRequest(groupRequest)
if err != nil {
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.String())
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
chat.ApplicationProcessedNotification(req)
if req.HandleResult == 1 {
if req.HandleResult == constant.GroupResponseAgree {
chat.MemberEnterNotification(req)
}
log.NewInfo(req.OperationID, "rpc GroupApplicationResponse return ")
log.NewInfo(req.OperationID, "rpc GroupApplicationResponse return ", pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{}})
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{}}, nil
}

@ -110,9 +110,9 @@ type GetGroupInfoResp struct {
type ApplicationGroupResponseReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
HandledMsg string `json:"handledMsg"`
HandleResult int32 `json:"handleResult" binding:"required"`
HandleResult int32 `json:"handleResult" binding:"required, oneof=-1 1"`
}
type ApplicationGroupResponseResp struct {
CommResp

@ -125,6 +125,9 @@ const (
GroupOwner = 2
GroupAdmin = 3
GroupResponseAgree = 1
GroupResponseRefuse = -1
Male = 1
Female = 2
)

Loading…
Cancel
Save