go_dreamfactory/modules/hero/api_list.go
2023-04-14 12:21:58 +08:00

36 lines
1.1 KiB
Go

package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
)
//参数校验
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.HeroListReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) List(session comm.IUserSession, req *pb.HeroListReq) (code pb.ErrorCode, data *pb.ErrorData) {
rsp := &pb.HeroListResp{}
rsp.List = this.module.GetHeroList(session.GetUserId())
// 重置当天抽卡次数 和商店购买次数
if heroRecord, err := this.module.modelRecord.GetHeroRecord(session.GetUserId()); err == nil {
if !utils.IsToday(heroRecord.Mtime) {
update := map[string]interface{}{}
update["onebuy"] = 0
update["tenbuy"] = 0
update["daycount"] = 0
heroRecord.Mtime = configure.Now().Unix()
update["mtime"] = heroRecord.Mtime
if err := this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update); err != nil {
this.module.Errorf("ChangeHeroRecord error: %v", err)
}
}
}
session.SendMsg(string(this.module.GetType()), HeroSubTypeList, rsp)
return
}