package schema import ( "time" "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" ) // Station 工位主数据:工位固定只对应一个工序编号,绑定一个工艺流程图(flowId) type Station struct { ent.Schema } func (Station) Annotations() []schema.Annotation { return []schema.Annotation{entsql.Annotation{Table: "station"}} } func (Station) Fields() []ent.Field { return []ent.Field{ field.Int("id").Positive(), field.Int("stationNo").Unique().Comment("工位号 1..12"), field.String("name").Default("").MaxLen(64).Comment("工位名称"), field.Int("flowId").Optional().Comment("绑定工艺流程图ID"), // LINE(线上位,连PLC) / OFFLINE(线下位,如 0 上线位、13 下线位,不连PLC) field.String("stationType").Default("LINE").MaxLen(20).Comment("工位类型 LINE/OFFLINE"), // ENABLED / DISABLED field.String("status").Default("ENABLED").MaxLen(20), field.Time("createdAt").Default(time.Now).Immutable(), } } func (Station) Indexes() []ent.Index { return []ent.Index{index.Fields("stationNo").Unique()} }