go_dreamfactory/modules/sociaty/api_cross_applycancel.go
2023-06-06 10:11:23 +08:00

56 lines
1.6 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) (errdata *pb.ErrorData) {
if req.SociatyId == "" {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
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) (errdata *pb.ErrorData) {
if code = this.ApplyCancelCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
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
}