54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package realarena
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) MatchCancelCheck(session comm.IUserSession, req *pb.RealArenaMatchCancelReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
///取消匹配
|
|
func (this *apiComp) MatchCancel(session comm.IUserSession, req *pb.RealArenaMatchCancelReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBRealArena
|
|
err error
|
|
)
|
|
if errdata = this.MatchCancelCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if info, err = this.module.model.getinfo(session); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info.State == 1 {
|
|
if err = this.module.match.CancelMatch(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if err = this.module.model.change(session.GetUserId(), map[string]interface{}{
|
|
"state": 0,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "matchcancel", &pb.RealArenaMatchCancelResp{})
|
|
return
|
|
}
|