32 lines
809 B
Go
32 lines
809 B
Go
package schema
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"entgo.io/ent"
|
||
|
|
"entgo.io/ent/schema/field"
|
||
|
|
"entgo.io/ent/schema/index"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PackageBox 包装箱 ↔ SN 关联
|
||
|
|
type PackageBox struct {
|
||
|
|
ent.Schema
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PackageBox) Fields() []ent.Field {
|
||
|
|
return []ent.Field{
|
||
|
|
field.String("box_no").Unique().Comment("箱号"),
|
||
|
|
// 关联 SN 列表(逗号分隔)或 JSON
|
||
|
|
field.String("sn_list").Optional().Comment("箱内 SN 列表"),
|
||
|
|
field.String("material_code").Optional().Comment("物料编码"),
|
||
|
|
field.Int("quantity").Default(0).Comment("箱内数量"),
|
||
|
|
field.String("operator").Optional().Comment("包装人"),
|
||
|
|
field.String("remark").Optional().Comment("备注"),
|
||
|
|
field.Int64("created_at").DefaultFunc(nowUnix),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (PackageBox) Indexes() []ent.Index {
|
||
|
|
return []ent.Index{
|
||
|
|
index.Fields("material_code"),
|
||
|
|
}
|
||
|
|
}
|