62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公会设置
|
|
|
|
func (this *apiComp) SettingCheck(session comm.IUserSession, req *pb.SociatySettingReq) (code pb.ErrorCode) {
|
|
if req.ApplyLv == 0 || req.Icon == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
this.module.Error("公会设置参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.SettingCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
uid := session.GetUserId()
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty != nil && sociaty.Id == "" {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Error("当前玩家所在的公会未找到", log.Fields{"uid": uid})
|
|
return
|
|
}
|
|
|
|
// 校验权限
|
|
if !this.module.modelSociaty.isRight(uid, sociaty,
|
|
pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT) {
|
|
code = pb.ErrorCode_SociatyNoRight
|
|
return
|
|
}
|
|
|
|
sociaty.Icon = req.Icon
|
|
sociaty.Notice = req.Notice
|
|
sociaty.IsApplyCheck = req.IsApplyCheck
|
|
sociaty.ApplyLv = req.ApplyLv
|
|
|
|
// 设置
|
|
if err := this.module.modelSociaty.setting(sociaty); err != nil {
|
|
code = pb.ErrorCode_SociatySetting
|
|
this.module.Error("公会修改", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()})
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatySettingResp{
|
|
SociatyId: sociaty.Id,
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|