go_dreamfactory/modules/sociaty/api_cross_refuse.go
2022-10-31 15:12:01 +08:00

54 lines
1.3 KiB
Go

package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 申请复查
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode) {
if req.Uid == "" || req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode, data proto.Message) {
if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success {
return
}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId)
return
}
if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT,
pb.SociatyJob_VICEPRESIDENT,
pb.SociatyJob_ADMIN) {
code = pb.ErrorCode_SociatyNoRight
return
}
if err := this.module.modelSociaty.refuse(req.Uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyRefuse
this.module.Errorf("申请拒绝失败:%v", err)
return
}
rsp := &pb.SociatyRefuseResp{
Uid: req.Uid,
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRefuse, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}