Files
bj_power/bj_power_wms/schema/event_log.go
T
SunYF 1f7a42fc38 refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据
- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
2026-10-08 13:09:53 +08:00

47 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// EventLog 操作日志(事件审计)
// 参照 MES 的 event_log 模型落地到 WMS,按 WMS 约定调整:
// - 字段名 snake_case(tools/generate.go 统一转 camelCase 输出 JSON)
// - 时间字段用 Int64 unix 秒
// - 无 work_order_no(WMS 无工单概念),用 entity_type/entity_id 描述业务对象
// 只增不改,不设 updated_at。
type EventLog struct {
ent.Schema
}
func (EventLog) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Table("event_log"), entsql.WithComments(true), schema.Comment("EventLog 操作日志(事件审计)")}
}
func (EventLog) Fields() []ent.Field {
return []ent.Field{
field.String("event_type").MaxLen(64).Comment("事件类型,如 user.create / inbound.create / auth.login"),
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
field.String("entity_type").Default("").MaxLen(32).Comment("对象类型,如 user/role/material/inbound/outbound"),
field.String("entity_id").Default("").MaxLen(64).Comment("对象标识:主键ID或业务单号"),
field.Text("description").Default("").Comment("事件描述"),
field.JSON("payload", map[string]any{}).Optional().SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Comment("扩展负载"),
field.Int64("created_at").DefaultFunc(nowUnix).Comment("发生时间"),
}
}
func (EventLog) Indexes() []ent.Index {
return []ent.Index{
index.Fields("event_type"),
index.Fields("operator"),
index.Fields("created_at"),
}
}