Files
bj_power/bj_power_mes/schema/station_terminal_event.go
T

42 lines
1.5 KiB
Go
Raw Normal View History

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"
)
// StationTerminalEvent 工位终端状态变化流水(2026-11-28 拍板第十三节):
// SSE 建连/断连(stream_on/off)+ 登录/退出/暂停/恢复等事件逐条留痕,供追溯"现场什么时候没人"。
// 当前状态看 station_terminal_state(单行覆盖),历史看本表(只增不改)。
type StationTerminalEvent struct {
ent.Schema
}
func (StationTerminalEvent) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "station_terminal_event"}, entsql.WithComments(true), schema.Comment("StationTerminalEvent 工位终端状态变化流水(只增)。")}
}
func (StationTerminalEvent) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.Int("stationNo").Comment("工位号"),
field.String("event").MaxLen(32).Comment("事件:stream_on/stream_off/login/logout/pause/resume/heartbeat"),
field.Bool("loggedIn").Default(false).Comment("事件后登录态"),
field.Bool("powered").Default(false).Comment("事件后开机态"),
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
field.String("detail").Default("").MaxLen(255).Comment("补充说明"),
field.Int64("createdAt").Default(0).Comment("事件时间 unix秒"),
}
}
func (StationTerminalEvent) Indexes() []ent.Index {
return []ent.Index{
index.Fields("stationNo"),
index.Fields("event"),
index.Fields("createdAt"),
}
}