46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 公会申请
|
|
|
|
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.SociatyApplyReq) (code pb.ErrorCode) {
|
|
if req.SociatyId == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.ApplyCheck(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 err := this.module.modelSociaty.apply(uid, sociaty); err != nil {
|
|
code = pb.ErrorCode_SociatyApply
|
|
this.module.Errorf("sociaty %s apply err:%v", req.SociatyId, err)
|
|
return
|
|
}
|
|
rsp := &pb.SociatyApplyResp{
|
|
Uid: uid,
|
|
ScoiatyId: req.SociatyId,
|
|
}
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApply, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|