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

53 lines
1.4 KiB
Go

package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 设置职位
func (this *apiComp) SettingJobCheck(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode) {
if req.SociatyId == "" || req.TargetId == "" || req.Job == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode, data proto.Message) {
if code = this.SettingJobCheck(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) {
code = pb.ErrorCode_SociatyNoRight
return
}
if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil {
code = pb.ErrorCode_SociatySettingJob
this.module.Errorf("设置职位失败:%v", err)
return
}
rsp := &pb.SociatySettingJobResp{
TargetId: req.TargetId,
SociatyId: sociaty.Id,
Job: req.Job,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSettingJob, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}