go_dreamfactory/modules/sociaty/api_cross_quit.go
2022-10-31 15:12:35 +08:00

51 lines
1.2 KiB
Go

package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 退出公会
func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) {
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 err := this.module.modelSociaty.quit(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyQuit
this.module.Errorf("退出公会失败:%v", err)
return
}
//更新玩家sociatyId
update := map[string]interface{}{
"sociatyId": "",
}
if err := this.module.ModuleUser.ChangeRemoteUserExpand(uid, update); err != nil {
code = pb.ErrorCode_DBError
this.module.Errorf("更新玩家公会ID err:%v", err)
return
}
rsp := &pb.SociatyQuitResp{
Uid: uid,
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}