58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package pagoda
|
|
|
|
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.PagodaGetListReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取主线关卡信息
|
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
list *pb.DBPagoda
|
|
)
|
|
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if !expand.CompletePagoda { // 普通塔
|
|
list, _ = this.module.modelPagoda.getPagodaList(session.GetUserId())
|
|
if list == nil { // redis没有数据
|
|
list = &pb.DBPagoda{}
|
|
list.Id = primitive.NewObjectID().Hex()
|
|
|
|
list.Uid = session.GetUserId()
|
|
list.PagodaId = 0 // 初始数据0层
|
|
list.Type = comm.PagodaType
|
|
this.module.modelPagoda.addNewPagoda(session.GetUserId(), list)
|
|
}
|
|
} else {
|
|
season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
|
if season == nil { // 创建一条新的数据
|
|
seasonPagoda := &pb.DBSeasonPagoda{}
|
|
seasonPagoda.Id = primitive.NewObjectID().Hex()
|
|
|
|
seasonPagoda.Uid = session.GetUserId()
|
|
seasonPagoda.PagodaId = 0 // 初始数据0层
|
|
seasonPagoda.Type = 201 // TODO 新的塔数据根据配置文件获取
|
|
this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), seasonPagoda)
|
|
} else {
|
|
list.PagodaId = season.PagodaId
|
|
list.Type = season.Type
|
|
list.Reward = season.Reward
|
|
}
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list})
|
|
return
|
|
}
|