feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// Alert 预警实例:扫描器按规则产生,用户在预警中心标记已读闭环。
|
||||
// 防刷:同一 rule_code+target 已存在「未读」且 created_at 距今 < 24h 的预警时不重复插入。
|
||||
type Alert struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Alert) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "alerts"},
|
||||
entsql.WithComments(true),
|
||||
schema.Comment("Alert 预警实例:扫描器按规则产生,用户标记已读闭环"),
|
||||
}
|
||||
}
|
||||
|
||||
func (Alert) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("rule_code").Comment("关联规则编码(固定五类)"),
|
||||
field.String("level").Default("warning").MaxLen(16).Comment("级别 info/warning/error"),
|
||||
field.String("title").Comment("预警标题"),
|
||||
field.String("content").Comment("预警内容"),
|
||||
// 关联对象:物料编码 / 批次号 / SN / 库存行ID 等,用于防刷去重。
|
||||
field.String("target").Optional().Comment("关联对象(物料编码/批次/SN/库存行ID等)"),
|
||||
field.String("status").Default("unread").MaxLen(16).Comment("状态 unread/read"),
|
||||
field.Int64("created_at").DefaultFunc(nowUnix).Comment("创建时间"),
|
||||
field.Int64("updated_at").DefaultFunc(nowUnix).Comment("更新时间"),
|
||||
}
|
||||
}
|
||||
|
||||
func (Alert) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("status"),
|
||||
index.Fields("rule_code"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user