go_dreamfactory/modules/hunting/api_getlist.go
2022-09-07 19:08:22 +08:00

48 lines
1.2 KiB
Go

package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"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 !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) //修改内存信息
}
for k := range list.Boss {
list.Boss[k] += 1
}
session.SendMsg(string(this.module.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
return
}