go_dreamfactory/modules/sociaty/api_cross_setting.go
2022-11-03 19:30:56 +08:00

55 lines
1.3 KiB
Go

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) {
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.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
}
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
}