44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// Recipe 工艺路线,定义产品从原料到成品的完整加工流程
|
|
type Recipe struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (Recipe) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.Annotation{
|
|
Table: "recipe",
|
|
Options: "COMMENT='工艺路线表,定义产品从原料到成品的完整加工工序流程,支持版本管理'",
|
|
},
|
|
entsql.WithComments(true),
|
|
}
|
|
}
|
|
|
|
func (Recipe) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Int("id").Positive().Comment("主键ID"),
|
|
field.String("name").MaxLen(50).Comment("路线名称,如 曲轴标准工艺"),
|
|
field.String("code").MaxLen(20).Unique().Comment("路线编码,全局唯一标识"),
|
|
field.Int("version").Default(1).Comment("版本号,工艺变更时递增,追溯历史版本"),
|
|
field.String("desc").Default("").Comment("路线描述,说明该工艺的适用范围和特点"),
|
|
field.Bool("isActive").Default(true).Comment("是否启用,false=停用该工艺路线"),
|
|
}
|
|
}
|
|
|
|
func (Recipe) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("steps", RecipeStep.Type).Comment("工序步骤列表"),
|
|
edge.To("productTypes", ProductType.Type).Comment("使用该工艺的产品类型"),
|
|
edge.To("jobs", Job.Type).Comment("使用该工艺的工件"),
|
|
}
|
|
}
|