53 lines
1.3 KiB
Go
53 lines
1.3 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)
|
|
|
|
} else if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), EnchantGetListResp, &pb.EnchantGetListResp{Data: list})
|
|
return
|
|
}
|