go_dreamfactory/modules/web/modelNotify.go
2022-07-25 16:35:35 +08:00

38 lines
966 B
Go

package web
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"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.MCompModel.Init(service, module, comp, opt)
this.module = module.(*Web)
this.TableName = "notify"
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 {
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
}