54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
"time"
|
|
|
|
"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 // 参数校验失败直接返回
|
|
}
|
|
list, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if list == nil {
|
|
list.Id = primitive.NewObjectID().Hex()
|
|
list.Uid = session.GetUserId()
|
|
list.Boos = make(map[int32]int32)
|
|
_mapType := this.configure.GetHuntingBossTypeConfigData()
|
|
for k := range _mapType {
|
|
list.Boos[k] = 0 // 默认难度0
|
|
}
|
|
this.module.modelHunting.Add(session.GetUserId(), list) // 写缓存
|
|
}
|
|
// 校验 是不是当天
|
|
if !utils.IsToday(list.CTime) {
|
|
list.CTime = time.Now().Unix()
|
|
list.BuyCount = 0
|
|
list.ChallengeCount = 0
|
|
mapData := make(map[string]interface{}, 0)
|
|
mapData["cTime"] = list.CTime
|
|
mapData["buyCount"] = list.BuyCount
|
|
mapData["challengeCount"] = list.ChallengeCount
|
|
code = this.module.ModifyHuntingData(session.GetUserId(), mapData) //修改内存信息
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
|
|
return
|
|
}
|