55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
"strconv"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode, data proto.Message) {
|
|
|
|
code = this.GetListCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
// 刷新挑战卷
|
|
if code = this.module.ModuleItems.RecoverTicket(session); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
list, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
|
if mgo.MongodbNil == err {
|
|
list = &pb.DBHunting{
|
|
Id: primitive.NewObjectID().Hex(),
|
|
Uid: session.GetUserId(),
|
|
Boss: make(map[int32]int32),
|
|
BossTime: make(map[string]int32),
|
|
}
|
|
_cfg := this.module.configure.GetHuntingBossTypeConfigData()
|
|
for k := range _cfg {
|
|
list.Boss[k] = 1
|
|
str := strconv.Itoa(int(k)) + "_1"
|
|
list.BossTime[str] = 0
|
|
}
|
|
|
|
this.module.modelHunting.Add(session.GetUserId(), list)
|
|
|
|
} else if err != nil {
|
|
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
|
|
return
|
|
}
|