初始化2
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// InventoryLock 库存锁定(工单锁库存,防超卖)
|
||||
type InventoryLock struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (InventoryLock) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
// 锁定对象:批次或 SN
|
||||
field.String("target_type").Comment("BATCH/SN"),
|
||||
field.String("target_id").Comment("批次号或 SN"),
|
||||
field.String("material_code").Comment("物料编码"),
|
||||
field.Int("locked_qty").Default(1).Comment("锁定数量"),
|
||||
field.String("order_no").Comment("关联工单号"),
|
||||
field.String("status").Default("ACTIVE").Comment("ACTIVE/RELEASED/CONSUMED"),
|
||||
field.Int64("expired_at").Optional().Comment("过期时间戳"),
|
||||
field.String("remark").Optional().Comment("备注"),
|
||||
field.Int64("created_at").DefaultFunc(nowUnix),
|
||||
field.Int64("updated_at").DefaultFunc(nowUnix),
|
||||
}
|
||||
}
|
||||
|
||||
func (InventoryLock) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("order_no"),
|
||||
index.Fields("status"),
|
||||
index.Fields("target_id"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user