57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package uigame
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
)
|
|
|
|
type modelLattice struct {
|
|
modules.MCompModel
|
|
module *UiGame
|
|
}
|
|
|
|
func (this *modelLattice) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableGameLattice)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*UiGame)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
func (this *modelLattice) getLatticeList(uid string, hid string) (result *pb.DBLatticeData, err error) {
|
|
result = &pb.DBLatticeData{}
|
|
if err = this.Get(uid, result); err != nil {
|
|
if mgo.MongodbNil == err {
|
|
result = &pb.DBLatticeData{
|
|
Id: primitive.NewObjectID().Hex(),
|
|
Uid: uid,
|
|
Hdoid: hid,
|
|
Gotarr: map[int32]int32{},
|
|
Lattice: map[int32]*pb.LatticeData{},
|
|
Lasttime: 0,
|
|
Floor: 1, //默认1层
|
|
Total: 1,
|
|
}
|
|
err = nil
|
|
this.module.modelLattice.Add(uid, result)
|
|
}
|
|
return
|
|
}
|
|
err = nil
|
|
return result, err
|
|
}
|
|
|
|
func (this *modelLattice) modifyLatticeListByObjId(uid string, data map[string]interface{}) error {
|
|
return this.Change(uid, data)
|
|
}
|