53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
"strconv"
|
|
"time"
|
|
|
|
"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 len(list.Boss) == 0 {
|
|
_cfg := this.module.configure.GetHuntingBossTypeConfigData()
|
|
for k := range _cfg {
|
|
list.Boss[k] = 0
|
|
str := strconv.Itoa(int(k)) + "_0"
|
|
list.BossTime[str] = 0
|
|
}
|
|
}
|
|
// 校验 是不是当天
|
|
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
|
|
}
|