Refactor code

This commit is contained in:
wenxu12345 2021-12-30 12:05:10 +08:00
parent 9409d6e05e
commit 4336a1a13e
3 changed files with 23 additions and 6 deletions

View File

@ -435,6 +435,11 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
utils.CopyStructFields(&groupRequest, req) utils.CopyStructFields(&groupRequest, req)
groupRequest.UserID = req.FromUserID groupRequest.UserID = req.FromUserID
groupRequest.HandleUserID = req.OpUserID 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) err := imdb.UpdateGroupRequest(groupRequest)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.String()) log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.String())

View File

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

View File

@ -210,6 +210,19 @@ func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
return groupIDList, nil 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) { //func SelectGroupList(groupID string) ([]string, error) {
// var groupUserID string // var groupUserID string