go_dreamfactory/modules/plunder/model_land.go
2024-01-16 16:35:06 +08:00

49 lines
1.1 KiB
Go

package plunder
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"
)
type modelLand struct {
modules.MCompModel
module *Plunder
}
func (this *modelLand) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TablePlunderLand
return
}
// 获取岛基本数据
func (this *modelLand) getPlunderLandData(uid string) (info *pb.DBPlunderLand, err error) {
info = &pb.DBPlunderLand{}
if err = this.Get(uid, 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)
return
}