44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package schema
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
type DockSlot struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (DockSlot) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.Annotation{Table: "dock_slot"},
|
|
entsql.WithComments(true),
|
|
}
|
|
}
|
|
|
|
func (DockSlot) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive(),
|
|
field.Int("dockNo").Comment("接驳台编号"),
|
|
field.Int("slotNo").Default(1).Min(1).Max(9).Comment("位置号 1-9"),
|
|
field.Int("status").Default(0).Min(0).Max(4).Comment("在位状态 0:空位 1:有料 2:加工中 3:加工完成"),
|
|
field.Int("currentJobId").Optional().Nillable().Comment("当前工件ID"),
|
|
field.Int("workpieceTypeId").Optional().Nillable().Comment("工件类型ID"),
|
|
field.Int("workOrderId").Optional().Nillable().Comment("关联的工单ID"),
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Comment("更新时间"),
|
|
}
|
|
}
|
|
|
|
func (DockSlot) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("currentJob", Job.Type).Field("currentJobId").Unique(),
|
|
edge.To("productType", ProductType.Type).Field("workpieceTypeId").Unique(),
|
|
edge.To("workOrder", WorkOrder.Type).Field("workOrderId").Unique(),
|
|
}
|
|
}
|