63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package autoBattle
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
)
|
|
|
|
type modelAutoBattle struct {
|
|
modules.MCompModel
|
|
module *AutoBattle
|
|
}
|
|
|
|
func (this *modelAutoBattle) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = string(comm.TableAuto)
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.module = module.(*AutoBattle)
|
|
// uid 创建索引
|
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
})
|
|
return
|
|
}
|
|
|
|
// 修改列表信息
|
|
func (this *modelAutoBattle) ChangeListByObjId(uid string, id string, data map[string]interface{}) error {
|
|
err := this.ChangeList(uid, id, data)
|
|
return err
|
|
}
|
|
|
|
// 删除自动战斗信息
|
|
func (this *modelAutoBattle) DelListByObjId(uid string, id string, data map[string]interface{}) error {
|
|
err := this.DelListByObjId(uid, id, data)
|
|
return err
|
|
}
|
|
|
|
// 删除自动战斗信息
|
|
func (this *modelAutoBattle) AddListByObjId(uid string, data map[string]interface{}) error {
|
|
err := this.AddLists(uid, data)
|
|
return err
|
|
}
|
|
|
|
// 获取列表信息
|
|
func (this *modelAutoBattle) getAutoBattleList(uid string) (result []*pb.DBAutoBattle, err error) {
|
|
result = make([]*pb.DBAutoBattle, 0)
|
|
err = this.GetList(uid, &result)
|
|
if err == mgo.MongodbNil {
|
|
err = nil
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
// 玩家离线清除自动战斗数据
|
|
func (this *modelAutoBattle) RemoveUserInfo(session comm.IUserSession) (err error) {
|
|
this.BatchDelLists(session.GetUserId())
|
|
return err
|
|
}
|