package gm import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) ///论坛 数据组件 type modelNotifyComp struct { modules.MCompModel module *GM } //组件初始化接口 func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { this.MCompModel.Init(service, module, comp, opt) this.module = module.(*GM) this.TableName = "notify" //创建uid索引 this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, }) return } //创建系统公告 func (this *modelNotifyComp) CreateSystemNotify(notify *pb.DBSystemNotify) (err error) { if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), notify); err != nil { log.Errorf("CreateSystemNotify err:%v", err) return } if err = this.Redis.HSet(this.TableName, notify.Id, notify); err != nil { log.Errorf("CreateSystemNotify err:%v", err) return } return }