67 lines
1.8 KiB
Go
67 lines
1.8 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.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
|
}
|
|
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 {
|
|
code = pb.ErrorCode_SociatyNoFound
|
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: 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.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
|
log.Field{Key: "params", Value: req},
|
|
log.Field{Key: "err", Value: 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
|
|
}
|