go_dreamfactory/modules/dragon/api_list.go

42 lines
1014 B
Go

package dragon
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
)
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.DragonGetListReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) GetList(session comm.IUserSession, req *pb.DragonGetListReq) (errdata *pb.ErrorData) {
var (
dragon []*pb.DBDragon
update map[string]interface{}
)
rsp := &pb.DragonGetListResp{}
update = map[string]interface{}{}
dragon, _ = this.module.modelDragon.GetDragonList(session.GetUserId())
for _, v := range dragon {
if !utils.IsToday(v.Rtime) {
v.Rtime = configure.Now().Unix()
for _, v1 := range v.Play {
if v1.Count != 0 {
v1.Count = 0
update["play"] = v.Play
break
}
}
update["rtime"] = v.Rtime
this.module.modelDragon.UpdateDragonData(session.GetUserId(), v.Id, update)
}
}
rsp.Dragons = dragon
session.SendMsg(string(this.module.GetType()), "getlist", rsp)
return
}