69 lines
1.8 KiB
Go
69 lines
1.8 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
|
|
}
|
|
|
|
//清除玩家sociatyId
|
|
update := map[string]interface{}{
|
|
"sociatyId": "", //公会ID置空
|
|
}
|
|
if err := this.module.ModuleUser.ChangeRemoteUserExpand(req.TargetId, update); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
this.module.Errorf("更新玩家公会ID err:%v", err)
|
|
return
|
|
}
|
|
|
|
if err := this.module.modelSociatyLog.addLog(Log_Discharge, sociaty.Id, uid, req.TargetId); err != nil {
|
|
this.module.Errorf("踢出公会日志 err:%v", err)
|
|
}
|
|
|
|
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
|
|
}
|