41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package viking
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.VikingGetListReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq) (code pb.ErrorCode, data proto.Message) {
|
|
|
|
code = this.GetListCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, err := this.module.modelViking.getVikingList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if list == nil {
|
|
list.Id = primitive.NewObjectID().Hex()
|
|
list.Uid = session.GetUserId()
|
|
list.Boos = make(map[int32]int32)
|
|
_mapType := this.configure.GetVikingBossTypeConfigData()
|
|
for k := range _mapType {
|
|
list.Boos[k] = 0 // 默认难度0
|
|
}
|
|
this.module.modelViking.Add(session.GetUserId(), list) // 写缓存
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), VikingGetListResp, &pb.VikingGetListResp{Data: list})
|
|
return
|
|
}
|