52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公会转让
|
|
func (this *apiComp) AssignCheck(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode) {
|
|
if req.SociatyId == "" || req.TargetId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.AssignCheck(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.assign(uid, req.TargetId, sociaty); err != nil {
|
|
code = pb.ErrorCode_SociatyAssign
|
|
this.module.Errorf("转让失败:%v", err)
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatyAssignResp{
|
|
TargetId: req.TargetId,
|
|
SociatyId: sociaty.Id,
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAssign, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|