43 lines
1.3 KiB
Go
43 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/field"
|
||
|
|
"entgo.io/ent/schema/index"
|
||
|
|
)
|
||
|
|
|
||
|
|
// ProcessFlow 工艺流程图:一个流程只绑定一个工序编号(1~12),可多版本;
|
||
|
|
// 工位绑定其中一个流程(一个工位同时只绑一个)。流程承载:工序号 + 工艺图纸PDF + 步骤模板。
|
||
|
|
type ProcessFlow struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (ProcessFlow) Annotations() []schema.Annotation {
|
||
|
|
return []schema.Annotation{entsql.Annotation{Table: "process_flow"}}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (ProcessFlow) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.Int("id").Positive(),
|
||
|
|
field.String("name").MaxLen(128).Comment("流程名称,如 工序3_2026版"),
|
||
|
|
field.Int("processCode").Comment("工序编号 1..12"),
|
||
|
|
field.String("pdfFile").Default("").MaxLen(255).Comment("工艺图纸文件名"),
|
||
|
|
// ACTIVE / INACTIVE
|
||
|
|
field.String("status").Default("ACTIVE").MaxLen(20),
|
||
|
|
field.String("remark").Default("").MaxLen(255),
|
||
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
||
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (ProcessFlow) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("processCode"),
|
||
|
|
index.Fields("status"),
|
||
|
|
}
|
||
|
|
}
|