| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package db
- import (
- cherryApp "f1-game/internal/cherry_app"
- "fmt"
- clog "github.com/cherry-game/cherry/logger"
- )
- // ver00002 补充系统城池
- type ver00002 struct {
- }
- // Version 手动自增,必需唯一
- func (ver00002) Version() int32 {
- return 2
- }
- func (ver00002) Enable() bool {
- return false
- }
- func (p ver00002) Execute() bool {
- clog.Infof("Execute %v, nodeID = %s", p.Version(), cherryApp.NodeID())
- // nodeTable, _ := GetMapNodeTableFromDB(capp.NodeID())
- // mapCastleCollection := dbComponent.DB().Collection(nameDB.Table_MapCastle)
- // mapCastleTables := []*MapCastleTable{}
- // for _, castleRow := range data.MapCastle.List() {
- // var (
- // x = castleRow.Point.X
- // y = castleRow.Point.Y
- // offsetPoints = data.MapObject.GetOffsetPoints(castleRow.ConfigID, x, y)
- // table = NewMapCastleTable(nodeTable.newGUID(), capp.NodeID(), x, y, castleRow.ID, offsetPoints...)
- // )
- // mapCastleTables = append(mapCastleTables, table)
- // }
- // _, err := mapCastleCollection.InsertMany(context.Background(), mapCastleTables)
- // if err != nil {
- // clog.Fatalf("[migrator - %d] insert map castle table error: %v", p.Version(), err)
- // }
- // mapCastleBaseCollection := dbComponent.DB().Collection(nameDB.Table_MapCastleBase)
- // mapCastleBaseTables := []*MapCastleBaseTable{}
- // for _, castleRow := range data.MapCastleBase.List() {
- // var (
- // x = castleRow.Point.X
- // y = castleRow.Point.Y
- // offsetPoints = data.MapObject.GetOffsetPoints(constant.MapTile_CastleBase, x, y)
- // table = NewMapCastleBaseTable(nodeTable.newGUID(), capp.NodeID(), x, y, castleRow.BaseID, offsetPoints...)
- // )
- // mapCastleBaseTables = append(mapCastleBaseTables, table)
- // }
- // _, err = mapCastleBaseCollection.InsertMany(context.Background(), mapCastleBaseTables)
- // if err != nil {
- // clog.Fatalf("[migrator - %d] insert map castle base table error: %v", p.Version(), err)
- // }
- // tableBytes, _ := bson.Marshal(nodeTable)
- // update := bson.D{{Key: "$set", Value: bson.Raw(tableBytes)}}
- // filter := bson.M{
- // "_id": nodeTable.PrimaryValue(), // 利用自带的_id主键进行条件过滤
- // }
- // _, err = dbComponent.DB().
- // Collection(nodeTable.TableName()).
- // UpdateOne(context.Background(), filter, update, options.UpdateOne().SetUpsert(true))
- // if err != nil {
- // clog.Fatalf("[migrator - %d] update node table error: %v", p.Version(), err)
- // }
- return true
- }
- func (p ver00002) Desc() string {
- return fmt.Sprintf("[migrator - %d] insert map castle", p.Version())
- }
|