54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 踢出公会
|
|
|
|
func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode) {
|
|
if req.TargetId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.DischargeCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
uid := session.GetUserId()
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty.Id == "" {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Errorf("uid:%s not in sociaty", uid)
|
|
return
|
|
}
|
|
|
|
if !this.module.modelSociaty.isRight(uid, sociaty,
|
|
pb.SociatyJob_PRESIDENT,
|
|
pb.SociatyJob_VICEPRESIDENT) {
|
|
code = pb.ErrorCode_SociatyNoRight
|
|
return
|
|
}
|
|
|
|
if err := this.module.modelSociaty.discharge(req.TargetId, sociaty); err != nil {
|
|
code = pb.ErrorCode_SociatyDischarge
|
|
this.module.Errorf("踢出公会失败:%v", err)
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyDischargeResp{
|
|
TargetId: req.TargetId,
|
|
SociatyId: sociaty.Id,
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|