52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package practice
|
|
|
|
import (
|
|
"errors"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 踢馆(熊猫武馆)
|
|
func (this *apiComp) QiecuoCheck(session comm.IUserSession, req *pb.PracticeQiecuoReq) (code pb.ErrorCode) {
|
|
if req.Fid == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.QiecuoCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
//目标是否在线
|
|
if !this.module.ModuleUser.IsOnline(req.Fid) {
|
|
code = pb.ErrorCode_UserOffline
|
|
return
|
|
}
|
|
|
|
//切磋请求处理
|
|
if err := this.module.modelQiecuo.qiecuoReq(session.GetUserId(), req.Fid); err != nil {
|
|
var customErr = new(comm.CustomError)
|
|
if errors.As(err, &customErr) {
|
|
code = customErr.Code
|
|
} else {
|
|
code = pb.ErrorCode_DBError
|
|
}
|
|
return
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), "qiecuo", &pb.PracticeQiecuoResp{
|
|
Fid: req.Fid,
|
|
}); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
this.module.SendMsgToUser(string(this.module.GetType()), "qiecuonotify",
|
|
&pb.PracticeQiecuonotifyPush{Uid: session.GetUserId(), NotifyType: 1}, req.Fid)
|
|
|
|
return
|
|
}
|