49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 取消公会申请
|
|
|
|
func (this *apiComp) ApplyCancelCheck(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode) {
|
|
if req.SociatyId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
this.module.Error("公会申请取消参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.ApplyCancelCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
uid := session.GetUserId()
|
|
|
|
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
|
|
if sociaty != nil && sociaty.Id == "" {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Error("公会未找到", log.Fields{"uid": uid, "sociatyId": req.SociatyId})
|
|
return
|
|
}
|
|
|
|
if err := this.module.modelSociaty.applyCancel(uid, sociaty); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
this.module.Error("申请撤销", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()})
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyApplyResp{
|
|
Uid: uid,
|
|
ScoiatyId: req.SociatyId,
|
|
}
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyCanel, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|