package sociaty import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) // 公会设置 func (this *apiComp) SettingCheck(session comm.IUserSession, req *pb.SociatySettingReq) (code pb.ErrorCode) { if req.SociatyId == "" { code = pb.ErrorCode_ReqParameterError } 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.getSociaty(req.SociatyId) if sociaty.Id == "" { code = pb.ErrorCode_SociatyNoFound this.module.Errorf("sociatyId: %s no found", req.SociatyId) 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.Errorf("公会修改失败:%v", err) return } rsp := &pb.SociatySettingResp{ SociatyId: sociaty.Id, } if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp); err != nil { code = pb.ErrorCode_SystemError } return }