58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package sys
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
)
|
|
|
|
type ModelSys struct {
|
|
modules.MCompModel
|
|
moduleSys *ModuleSys
|
|
|
|
service core.IService
|
|
}
|
|
|
|
func (this *ModelSys) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = comm.TableOpenCond
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.moduleSys = module.(*ModuleSys)
|
|
this.service = service
|
|
return
|
|
}
|
|
|
|
func (this *ModelSys) GetOpenCondList(uid string) (result *pb.DBOpenCond, err error) {
|
|
result = &pb.DBOpenCond{}
|
|
if err = this.Get(uid, result); err != nil {
|
|
if mongo.ErrNoDocuments == err { // 创建一条新的数据
|
|
result = &pb.DBOpenCond{
|
|
Id: primitive.NewObjectID().Hex(),
|
|
Uid: uid,
|
|
Cond: map[string]int32{},
|
|
Lv: 1,
|
|
Friend: 0,
|
|
Mline: map[int32]int32{},
|
|
Wtask: map[int32]int32{},
|
|
Pagoda: map[int32]int32{},
|
|
Sociaty: 1,
|
|
Moonlv: 1,
|
|
}
|
|
this.Add(uid, result)
|
|
err = nil
|
|
}
|
|
}
|
|
return result, err
|
|
}
|
|
|
|
// 修改OpenCond 数据
|
|
func (this *ModelSys) ChangeOpenCondData(uid string, value map[string]interface{}) (err error) {
|
|
if len(value) == 0 {
|
|
return nil
|
|
}
|
|
return this.Change(uid, value)
|
|
}
|