掠夺数据结构调整
This commit is contained in:
parent
33ab6cc66b
commit
3a4b21311b
@ -19,7 +19,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe
|
||||
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{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Message: err.Error(),
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"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{}
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
// 修改岛信息
|
||||
func (this *modelLand) changePlunderLandData(uid string, update map[string]interface{}) (err error) {
|
||||
err = this.Change(uid, update)
|
||||
func (this *modelLand) changePlunderLandData(id string, update map[string]interface{}) (err error) {
|
||||
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
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -26,7 +27,7 @@ func (this *modelPlunder) Init(service core.IService, module core.IModule, comp
|
||||
return
|
||||
}
|
||||
|
||||
// 获取猴拳基本数据
|
||||
// 获取基本数据
|
||||
func (this *modelPlunder) getPlunderData(uid string) (info *pb.DBPlunder, err error) {
|
||||
info = &pb.DBPlunder{}
|
||||
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
|
||||
@ -35,9 +36,17 @@ func (this *modelPlunder) getPlunderData(uid string) (info *pb.DBPlunder, err er
|
||||
}
|
||||
if err == mgo.MongodbNil {
|
||||
info = &pb.DBPlunder{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
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)
|
||||
}
|
||||
return
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -16,10 +17,11 @@ func NewModule() core.IModule {
|
||||
*/
|
||||
type Plunder struct {
|
||||
modules.ModuleBase
|
||||
service comm.IService
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
model *modelPlunder
|
||||
service comm.IService
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
modelPlunder *modelPlunder
|
||||
modelLand *modelLand
|
||||
}
|
||||
|
||||
// 模块名
|
||||
@ -46,5 +48,10 @@ func (this *Plunder) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
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