go_dreamfactory/modules/enchant/api_getlist.go
2023-01-09 19:59:03 +08:00

55 lines
1.4 KiB
Go

package enchant
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.EnchantGetListReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) GetList(session comm.IUserSession, req *pb.EnchantGetListReq) (code pb.ErrorCode, data proto.Message) {
code = this.GetListCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
// 刷新挑战卷
if code = this.module.ModuleItems.RecoverTicket(session); code != pb.ErrorCode_Success {
return
}
list, err := this.module.modelEnchant.getEnchantList(session.GetUserId())
if mgo.MongodbNil == err {
list.Id = primitive.NewObjectID().Hex()
list.Uid = session.GetUserId()
list.Boss = make(map[int32]int64)
list.BossTime = make(map[int32]int32)
_cfg := this.module.configure.GetEnchantBossTypeConfigData()
for k := range _cfg {
list.BossTime[k] = 0
}
this.module.modelEnchant.Add(session.GetUserId(), list)
}
if session.GetUserId() != "" { // 恢复时间
if userexpand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()); err == nil {
list.RecoveryTime = userexpand.Recovertimeunifiedticket
}
}
session.SendMsg(string(this.module.GetType()), EnchantGetListResp, &pb.EnchantGetListResp{Data: list})
return
}