51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 取消公会申请
|
|
|
|
func (this *apiComp) ApplyCancelCheck(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode) {
|
|
if req.SociatyId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
this.module.Error("公会申请取消参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
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.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
|
|
return
|
|
}
|
|
|
|
if err := this.module.modelSociaty.applyCancel(uid, sociaty); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
this.module.Error("申请撤销",
|
|
log.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "sociatyId", Value: req.SociatyId},
|
|
log.Field{Key: "err", Value: 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
|
|
}
|