掠夺数据结构调整
This commit is contained in:
parent
33ab6cc66b
commit
3a4b21311b
@ -19,7 +19,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if list, err = this.module.model.getPlunderData(session.GetUserId()); err != nil {
|
if list, err = this.module.modelPlunder.getPlunderData(session.GetUserId()); err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/mgo"
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
@ -23,26 +25,31 @@ func (this *modelLand) Init(service core.IService, module core.IModule, comp cor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取岛基本数据
|
// 获取岛基本数据
|
||||||
func (this *modelLand) getPlunderLandData(uid string) (info *pb.DBPlunderLand, err error) {
|
func (this *modelLand) getPlunderLandData(id string) (info *pb.DBPlunderLand, err error) {
|
||||||
info = &pb.DBPlunderLand{}
|
info = &pb.DBPlunderLand{}
|
||||||
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
if err = this.GetListObj(comm.RDS_EMPTY, id, info); err != nil && err != mgo.MongodbNil {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err == mgo.MongodbNil {
|
|
||||||
info = &pb.DBPlunderLand{
|
|
||||||
Id: primitive.NewObjectID().Hex(),
|
|
||||||
Uinfo: map[string]*pb.BaseUserInfo{},
|
|
||||||
Ship: map[string]*pb.ShipData{},
|
|
||||||
Etime: 0,
|
|
||||||
}
|
|
||||||
err = this.Add(uid, info)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改岛信息
|
// 修改岛信息
|
||||||
func (this *modelLand) changePlunderLandData(uid string, update map[string]interface{}) (err error) {
|
func (this *modelLand) changePlunderLandData(id string, update map[string]interface{}) (err error) {
|
||||||
err = this.Change(uid, update)
|
err = this.ChangeList(comm.RDS_EMPTY, id, update)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand, err error) {
|
||||||
|
|
||||||
|
land = &pb.DBPlunderLand{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
Uinfo: map[string]*pb.BaseUserInfo{},
|
||||||
|
Ship: map[string]*pb.ShipData{},
|
||||||
|
Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置
|
||||||
|
}
|
||||||
|
err = this.AddList(comm.RDS_EMPTY, land.Id, land)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/mgo"
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -26,7 +27,7 @@ func (this *modelPlunder) Init(service core.IService, module core.IModule, comp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取猴拳基本数据
|
// 获取基本数据
|
||||||
func (this *modelPlunder) getPlunderData(uid string) (info *pb.DBPlunder, err error) {
|
func (this *modelPlunder) getPlunderData(uid string) (info *pb.DBPlunder, err error) {
|
||||||
info = &pb.DBPlunder{}
|
info = &pb.DBPlunder{}
|
||||||
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
||||||
@ -37,7 +38,15 @@ func (this *modelPlunder) getPlunderData(uid string) (info *pb.DBPlunder, err er
|
|||||||
info = &pb.DBPlunder{
|
info = &pb.DBPlunder{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
|
Ctime: configure.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i := 0; i < 3; i++ { // 队列固定三条
|
||||||
|
info.Line = append(info.Line, &pb.PlunderLine{})
|
||||||
|
}
|
||||||
|
info.Line = append(info.Line, &pb.PlunderLine{
|
||||||
|
Closetime: -1, // 需要手动解锁
|
||||||
|
})
|
||||||
err = this.Add(uid, info)
|
err = this.Add(uid, info)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -19,7 +20,8 @@ type Plunder struct {
|
|||||||
service comm.IService
|
service comm.IService
|
||||||
api *apiComp
|
api *apiComp
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
model *modelPlunder
|
modelPlunder *modelPlunder
|
||||||
|
modelLand *modelLand
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模块名
|
// 模块名
|
||||||
@ -46,5 +48,10 @@ func (this *Plunder) OnInstallComp() {
|
|||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
this.model = this.RegisterComp(new(modelPlunder)).(*modelPlunder)
|
this.modelPlunder = this.RegisterComp(new(modelPlunder)).(*modelPlunder)
|
||||||
|
this.modelLand = this.RegisterComp(new(modelLand)).(*modelLand)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Plunder) CreatePlunderLand(uid string) (land *pb.DBPlunderLand, err error) {
|
||||||
|
return this.modelLand.createPlunderLandData(uid)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user