提交 4336a1a1 编写于 作者: W wenxu12345

Refactor code

上级 9409d6e0
......@@ -435,6 +435,11 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
utils.CopyStructFields(&groupRequest, req)
groupRequest.UserID = req.FromUserID
groupRequest.HandleUserID = req.OpUserID
if !token_verify.IsMangerUserID(req.OpUserID) && !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) {
log.NewError(req.OperationID, "IsMangerUserID IsGroupOwnerAdmin false ", req.GroupID, req.OpUserID)
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
err := imdb.UpdateGroupRequest(groupRequest)
if err != nil {
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.String())
......
......@@ -108,12 +108,11 @@ type GetGroupInfoResp struct {
}
type ApplicationGroupResponseReq struct {
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
HandledMsg string `json:"handledMsg"`
//`json:"flag" binding:"required,oneof=-1 0 1"`
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
HandledMsg string `json:"handledMsg"`
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
}
type ApplicationGroupResponseResp struct {
CommResp
......
......@@ -210,6 +210,19 @@ func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
return groupIDList, nil
}
func IsGroupOwnerAdmin(groupID, UserID string) bool {
groupMemberList, err := GetOwnerManagerByGroupID(groupID)
if err != nil {
return false
}
for _, v := range groupMemberList {
if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers {
return true
}
}
return false
}
//
//func SelectGroupList(groupID string) ([]string, error) {
// var groupUserID string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册