Files
bj_power/bj_power_mes/schema/recipe.go
T

41 lines
1.0 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"},
}
}
func (Recipe) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
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.Int("totalSteps").Default(0).Comment("总步骤数"),
field.Bool("isActive").Default(true).Comment("是否启用"),
}
}
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("工件"),
}
}