37 lines
950 B
Go
37 lines
950 B
Go
package web
|
|
|
|
import (
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
//公告数据模块
|
|
type modelNotifyComp struct {
|
|
modules.MCompModel
|
|
module *Web
|
|
}
|
|
|
|
func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
|
this.TableName = "notify"
|
|
this.MCompModel.Init(service, module, comp, opt)
|
|
this.module = module.(*Web)
|
|
return
|
|
}
|
|
|
|
//创建系统公告
|
|
func (this *modelNotifyComp) CreateSystemNotify(notify *pb.DBSystemNotify) (err error) {
|
|
notify.Id = primitive.NewObjectID().Hex()
|
|
if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), notify); err != nil {
|
|
this.module.Errorf("CreateSystemNotify err:%v", err)
|
|
return
|
|
}
|
|
if err = this.Redis.HSet(this.TableName, notify.Id, notify); err != nil {
|
|
this.module.Errorf("CreateSystemNotify err:%v", err)
|
|
return
|
|
}
|
|
return
|
|
}
|