56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package arena
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) DelRewardCheck(session comm.IUserSession, req *pb.ArenaDelRewardReq) (errdata *pb.ErrorData) {
|
|
if req.Bid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
///删除战斗记录
|
|
func (this *apiComp) DelReward(session comm.IUserSession, req *pb.ArenaDelRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBArenaUser
|
|
err error
|
|
)
|
|
if errdata = this.DelRewardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info.Record != nil {
|
|
for i, v := range info.Record {
|
|
if v.Bid == req.Bid {
|
|
info.Record = append(info.Record[0:i], info.Record[i+1:]...)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "delreward", &pb.ArenaDelRewardResp{Issucc: true, Bid: req.Bid})
|
|
return
|
|
}
|