37 lines
963 B
Go
37 lines
963 B
Go
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"),
|
||
|
|
// 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()}
|
||
|
|
}
|