refactor(wms): 合并库存表为统一inventory,重构业务逻辑
1. 合并inventory_batch与serial_number为统一inventory表,用manage_mode区分结构件批次/精密件SN 2. 移除冗余的material_type字段与相关逻辑 3. 重构库存查询、检验、入库出库等业务逻辑适配新表结构 4. 调整前端路由与菜单,拆分基础数据为区域维护和物料档案 5. 优化入库校验逻辑,避免空单问题 6. 调整Vite构建配置,关闭自动清空输出目录 7. 为各模块添加详细中文注释,统一业务术语 8. 生成并更新Ent自动代码文件
This commit is contained in:
+74
-217
@@ -14,7 +14,7 @@ import (
|
||||
"bj_power_wms/ent/inbounddetail"
|
||||
"bj_power_wms/ent/inboundorder"
|
||||
"bj_power_wms/ent/inspectionrecord"
|
||||
"bj_power_wms/ent/inventorybatch"
|
||||
"bj_power_wms/ent/inventory"
|
||||
"bj_power_wms/ent/inventorylock"
|
||||
"bj_power_wms/ent/material"
|
||||
"bj_power_wms/ent/ordermaterialledger"
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"bj_power_wms/ent/outboundorder"
|
||||
"bj_power_wms/ent/packagebox"
|
||||
"bj_power_wms/ent/semifinished"
|
||||
"bj_power_wms/ent/serialnumber"
|
||||
"bj_power_wms/ent/stocktakeitem"
|
||||
"bj_power_wms/ent/stocktakeorder"
|
||||
"bj_power_wms/ent/user"
|
||||
@@ -44,8 +43,8 @@ type Client struct {
|
||||
InboundOrder *InboundOrderClient
|
||||
// InspectionRecord is the client for interacting with the InspectionRecord builders.
|
||||
InspectionRecord *InspectionRecordClient
|
||||
// InventoryBatch is the client for interacting with the InventoryBatch builders.
|
||||
InventoryBatch *InventoryBatchClient
|
||||
// Inventory is the client for interacting with the Inventory builders.
|
||||
Inventory *InventoryClient
|
||||
// InventoryLock is the client for interacting with the InventoryLock builders.
|
||||
InventoryLock *InventoryLockClient
|
||||
// Material is the client for interacting with the Material builders.
|
||||
@@ -60,8 +59,6 @@ type Client struct {
|
||||
PackageBox *PackageBoxClient
|
||||
// SemiFinished is the client for interacting with the SemiFinished builders.
|
||||
SemiFinished *SemiFinishedClient
|
||||
// SerialNumber is the client for interacting with the SerialNumber builders.
|
||||
SerialNumber *SerialNumberClient
|
||||
// StocktakeItem is the client for interacting with the StocktakeItem builders.
|
||||
StocktakeItem *StocktakeItemClient
|
||||
// StocktakeOrder is the client for interacting with the StocktakeOrder builders.
|
||||
@@ -84,7 +81,7 @@ func (c *Client) init() {
|
||||
c.InboundDetail = NewInboundDetailClient(c.config)
|
||||
c.InboundOrder = NewInboundOrderClient(c.config)
|
||||
c.InspectionRecord = NewInspectionRecordClient(c.config)
|
||||
c.InventoryBatch = NewInventoryBatchClient(c.config)
|
||||
c.Inventory = NewInventoryClient(c.config)
|
||||
c.InventoryLock = NewInventoryLockClient(c.config)
|
||||
c.Material = NewMaterialClient(c.config)
|
||||
c.OrderMaterialLedger = NewOrderMaterialLedgerClient(c.config)
|
||||
@@ -92,7 +89,6 @@ func (c *Client) init() {
|
||||
c.OutboundOrder = NewOutboundOrderClient(c.config)
|
||||
c.PackageBox = NewPackageBoxClient(c.config)
|
||||
c.SemiFinished = NewSemiFinishedClient(c.config)
|
||||
c.SerialNumber = NewSerialNumberClient(c.config)
|
||||
c.StocktakeItem = NewStocktakeItemClient(c.config)
|
||||
c.StocktakeOrder = NewStocktakeOrderClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
@@ -192,7 +188,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
InboundDetail: NewInboundDetailClient(cfg),
|
||||
InboundOrder: NewInboundOrderClient(cfg),
|
||||
InspectionRecord: NewInspectionRecordClient(cfg),
|
||||
InventoryBatch: NewInventoryBatchClient(cfg),
|
||||
Inventory: NewInventoryClient(cfg),
|
||||
InventoryLock: NewInventoryLockClient(cfg),
|
||||
Material: NewMaterialClient(cfg),
|
||||
OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
|
||||
@@ -200,7 +196,6 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
OutboundOrder: NewOutboundOrderClient(cfg),
|
||||
PackageBox: NewPackageBoxClient(cfg),
|
||||
SemiFinished: NewSemiFinishedClient(cfg),
|
||||
SerialNumber: NewSerialNumberClient(cfg),
|
||||
StocktakeItem: NewStocktakeItemClient(cfg),
|
||||
StocktakeOrder: NewStocktakeOrderClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
@@ -227,7 +222,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
InboundDetail: NewInboundDetailClient(cfg),
|
||||
InboundOrder: NewInboundOrderClient(cfg),
|
||||
InspectionRecord: NewInspectionRecordClient(cfg),
|
||||
InventoryBatch: NewInventoryBatchClient(cfg),
|
||||
Inventory: NewInventoryClient(cfg),
|
||||
InventoryLock: NewInventoryLockClient(cfg),
|
||||
Material: NewMaterialClient(cfg),
|
||||
OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
|
||||
@@ -235,7 +230,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
OutboundOrder: NewOutboundOrderClient(cfg),
|
||||
PackageBox: NewPackageBoxClient(cfg),
|
||||
SemiFinished: NewSemiFinishedClient(cfg),
|
||||
SerialNumber: NewSerialNumberClient(cfg),
|
||||
StocktakeItem: NewStocktakeItemClient(cfg),
|
||||
StocktakeOrder: NewStocktakeOrderClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
@@ -269,9 +263,9 @@ func (c *Client) Close() error {
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.InboundDetail, c.InboundOrder, c.InspectionRecord, c.InventoryBatch,
|
||||
c.InboundDetail, c.InboundOrder, c.InspectionRecord, c.Inventory,
|
||||
c.InventoryLock, c.Material, c.OrderMaterialLedger, c.OutboundDetail,
|
||||
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.SerialNumber, c.StocktakeItem,
|
||||
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.StocktakeItem,
|
||||
c.StocktakeOrder, c.User, c.Zone,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
@@ -282,9 +276,9 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.InboundDetail, c.InboundOrder, c.InspectionRecord, c.InventoryBatch,
|
||||
c.InboundDetail, c.InboundOrder, c.InspectionRecord, c.Inventory,
|
||||
c.InventoryLock, c.Material, c.OrderMaterialLedger, c.OutboundDetail,
|
||||
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.SerialNumber, c.StocktakeItem,
|
||||
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.StocktakeItem,
|
||||
c.StocktakeOrder, c.User, c.Zone,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
@@ -300,8 +294,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.InboundOrder.mutate(ctx, m)
|
||||
case *InspectionRecordMutation:
|
||||
return c.InspectionRecord.mutate(ctx, m)
|
||||
case *InventoryBatchMutation:
|
||||
return c.InventoryBatch.mutate(ctx, m)
|
||||
case *InventoryMutation:
|
||||
return c.Inventory.mutate(ctx, m)
|
||||
case *InventoryLockMutation:
|
||||
return c.InventoryLock.mutate(ctx, m)
|
||||
case *MaterialMutation:
|
||||
@@ -316,8 +310,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.PackageBox.mutate(ctx, m)
|
||||
case *SemiFinishedMutation:
|
||||
return c.SemiFinished.mutate(ctx, m)
|
||||
case *SerialNumberMutation:
|
||||
return c.SerialNumber.mutate(ctx, m)
|
||||
case *StocktakeItemMutation:
|
||||
return c.StocktakeItem.mutate(ctx, m)
|
||||
case *StocktakeOrderMutation:
|
||||
@@ -730,107 +722,107 @@ func (c *InspectionRecordClient) mutate(ctx context.Context, m *InspectionRecord
|
||||
}
|
||||
}
|
||||
|
||||
// InventoryBatchClient is a client for the InventoryBatch schema.
|
||||
type InventoryBatchClient struct {
|
||||
// InventoryClient is a client for the Inventory schema.
|
||||
type InventoryClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewInventoryBatchClient returns a client for the InventoryBatch from the given config.
|
||||
func NewInventoryBatchClient(c config) *InventoryBatchClient {
|
||||
return &InventoryBatchClient{config: c}
|
||||
// NewInventoryClient returns a client for the Inventory from the given config.
|
||||
func NewInventoryClient(c config) *InventoryClient {
|
||||
return &InventoryClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `inventorybatch.Hooks(f(g(h())))`.
|
||||
func (c *InventoryBatchClient) Use(hooks ...Hook) {
|
||||
c.hooks.InventoryBatch = append(c.hooks.InventoryBatch, hooks...)
|
||||
// A call to `Use(f, g, h)` equals to `inventory.Hooks(f(g(h())))`.
|
||||
func (c *InventoryClient) Use(hooks ...Hook) {
|
||||
c.hooks.Inventory = append(c.hooks.Inventory, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `inventorybatch.Intercept(f(g(h())))`.
|
||||
func (c *InventoryBatchClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.InventoryBatch = append(c.inters.InventoryBatch, interceptors...)
|
||||
// A call to `Intercept(f, g, h)` equals to `inventory.Intercept(f(g(h())))`.
|
||||
func (c *InventoryClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Inventory = append(c.inters.Inventory, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a InventoryBatch entity.
|
||||
func (c *InventoryBatchClient) Create() *InventoryBatchCreate {
|
||||
mutation := newInventoryBatchMutation(c.config, OpCreate)
|
||||
return &InventoryBatchCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
// Create returns a builder for creating a Inventory entity.
|
||||
func (c *InventoryClient) Create() *InventoryCreate {
|
||||
mutation := newInventoryMutation(c.config, OpCreate)
|
||||
return &InventoryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of InventoryBatch entities.
|
||||
func (c *InventoryBatchClient) CreateBulk(builders ...*InventoryBatchCreate) *InventoryBatchCreateBulk {
|
||||
return &InventoryBatchCreateBulk{config: c.config, builders: builders}
|
||||
// CreateBulk returns a builder for creating a bulk of Inventory entities.
|
||||
func (c *InventoryClient) CreateBulk(builders ...*InventoryCreate) *InventoryCreateBulk {
|
||||
return &InventoryCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *InventoryBatchClient) MapCreateBulk(slice any, setFunc func(*InventoryBatchCreate, int)) *InventoryBatchCreateBulk {
|
||||
func (c *InventoryClient) MapCreateBulk(slice any, setFunc func(*InventoryCreate, int)) *InventoryCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &InventoryBatchCreateBulk{err: fmt.Errorf("calling to InventoryBatchClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
return &InventoryCreateBulk{err: fmt.Errorf("calling to InventoryClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*InventoryBatchCreate, rv.Len())
|
||||
builders := make([]*InventoryCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &InventoryBatchCreateBulk{config: c.config, builders: builders}
|
||||
return &InventoryCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for InventoryBatch.
|
||||
func (c *InventoryBatchClient) Update() *InventoryBatchUpdate {
|
||||
mutation := newInventoryBatchMutation(c.config, OpUpdate)
|
||||
return &InventoryBatchUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
// Update returns an update builder for Inventory.
|
||||
func (c *InventoryClient) Update() *InventoryUpdate {
|
||||
mutation := newInventoryMutation(c.config, OpUpdate)
|
||||
return &InventoryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *InventoryBatchClient) UpdateOne(_m *InventoryBatch) *InventoryBatchUpdateOne {
|
||||
mutation := newInventoryBatchMutation(c.config, OpUpdateOne, withInventoryBatch(_m))
|
||||
return &InventoryBatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
func (c *InventoryClient) UpdateOne(_m *Inventory) *InventoryUpdateOne {
|
||||
mutation := newInventoryMutation(c.config, OpUpdateOne, withInventory(_m))
|
||||
return &InventoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *InventoryBatchClient) UpdateOneID(id int) *InventoryBatchUpdateOne {
|
||||
mutation := newInventoryBatchMutation(c.config, OpUpdateOne, withInventoryBatchID(id))
|
||||
return &InventoryBatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
func (c *InventoryClient) UpdateOneID(id int) *InventoryUpdateOne {
|
||||
mutation := newInventoryMutation(c.config, OpUpdateOne, withInventoryID(id))
|
||||
return &InventoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for InventoryBatch.
|
||||
func (c *InventoryBatchClient) Delete() *InventoryBatchDelete {
|
||||
mutation := newInventoryBatchMutation(c.config, OpDelete)
|
||||
return &InventoryBatchDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
// Delete returns a delete builder for Inventory.
|
||||
func (c *InventoryClient) Delete() *InventoryDelete {
|
||||
mutation := newInventoryMutation(c.config, OpDelete)
|
||||
return &InventoryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *InventoryBatchClient) DeleteOne(_m *InventoryBatch) *InventoryBatchDeleteOne {
|
||||
func (c *InventoryClient) DeleteOne(_m *Inventory) *InventoryDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *InventoryBatchClient) DeleteOneID(id int) *InventoryBatchDeleteOne {
|
||||
builder := c.Delete().Where(inventorybatch.ID(id))
|
||||
func (c *InventoryClient) DeleteOneID(id int) *InventoryDeleteOne {
|
||||
builder := c.Delete().Where(inventory.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &InventoryBatchDeleteOne{builder}
|
||||
return &InventoryDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for InventoryBatch.
|
||||
func (c *InventoryBatchClient) Query() *InventoryBatchQuery {
|
||||
return &InventoryBatchQuery{
|
||||
// Query returns a query builder for Inventory.
|
||||
func (c *InventoryClient) Query() *InventoryQuery {
|
||||
return &InventoryQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeInventoryBatch},
|
||||
ctx: &QueryContext{Type: TypeInventory},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a InventoryBatch entity by its id.
|
||||
func (c *InventoryBatchClient) Get(ctx context.Context, id int) (*InventoryBatch, error) {
|
||||
return c.Query().Where(inventorybatch.ID(id)).Only(ctx)
|
||||
// Get returns a Inventory entity by its id.
|
||||
func (c *InventoryClient) Get(ctx context.Context, id int) (*Inventory, error) {
|
||||
return c.Query().Where(inventory.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *InventoryBatchClient) GetX(ctx context.Context, id int) *InventoryBatch {
|
||||
func (c *InventoryClient) GetX(ctx context.Context, id int) *Inventory {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -839,27 +831,27 @@ func (c *InventoryBatchClient) GetX(ctx context.Context, id int) *InventoryBatch
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *InventoryBatchClient) Hooks() []Hook {
|
||||
return c.hooks.InventoryBatch
|
||||
func (c *InventoryClient) Hooks() []Hook {
|
||||
return c.hooks.Inventory
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *InventoryBatchClient) Interceptors() []Interceptor {
|
||||
return c.inters.InventoryBatch
|
||||
func (c *InventoryClient) Interceptors() []Interceptor {
|
||||
return c.inters.Inventory
|
||||
}
|
||||
|
||||
func (c *InventoryBatchClient) mutate(ctx context.Context, m *InventoryBatchMutation) (Value, error) {
|
||||
func (c *InventoryClient) mutate(ctx context.Context, m *InventoryMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&InventoryBatchCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
return (&InventoryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&InventoryBatchUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
return (&InventoryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&InventoryBatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
return (&InventoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&InventoryBatchDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
return (&InventoryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown InventoryBatch mutation op: %q", m.Op())
|
||||
return nil, fmt.Errorf("ent: unknown Inventory mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1794,139 +1786,6 @@ func (c *SemiFinishedClient) mutate(ctx context.Context, m *SemiFinishedMutation
|
||||
}
|
||||
}
|
||||
|
||||
// SerialNumberClient is a client for the SerialNumber schema.
|
||||
type SerialNumberClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSerialNumberClient returns a client for the SerialNumber from the given config.
|
||||
func NewSerialNumberClient(c config) *SerialNumberClient {
|
||||
return &SerialNumberClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `serialnumber.Hooks(f(g(h())))`.
|
||||
func (c *SerialNumberClient) Use(hooks ...Hook) {
|
||||
c.hooks.SerialNumber = append(c.hooks.SerialNumber, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `serialnumber.Intercept(f(g(h())))`.
|
||||
func (c *SerialNumberClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.SerialNumber = append(c.inters.SerialNumber, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a SerialNumber entity.
|
||||
func (c *SerialNumberClient) Create() *SerialNumberCreate {
|
||||
mutation := newSerialNumberMutation(c.config, OpCreate)
|
||||
return &SerialNumberCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of SerialNumber entities.
|
||||
func (c *SerialNumberClient) CreateBulk(builders ...*SerialNumberCreate) *SerialNumberCreateBulk {
|
||||
return &SerialNumberCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *SerialNumberClient) MapCreateBulk(slice any, setFunc func(*SerialNumberCreate, int)) *SerialNumberCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &SerialNumberCreateBulk{err: fmt.Errorf("calling to SerialNumberClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*SerialNumberCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &SerialNumberCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for SerialNumber.
|
||||
func (c *SerialNumberClient) Update() *SerialNumberUpdate {
|
||||
mutation := newSerialNumberMutation(c.config, OpUpdate)
|
||||
return &SerialNumberUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SerialNumberClient) UpdateOne(_m *SerialNumber) *SerialNumberUpdateOne {
|
||||
mutation := newSerialNumberMutation(c.config, OpUpdateOne, withSerialNumber(_m))
|
||||
return &SerialNumberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SerialNumberClient) UpdateOneID(id int) *SerialNumberUpdateOne {
|
||||
mutation := newSerialNumberMutation(c.config, OpUpdateOne, withSerialNumberID(id))
|
||||
return &SerialNumberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for SerialNumber.
|
||||
func (c *SerialNumberClient) Delete() *SerialNumberDelete {
|
||||
mutation := newSerialNumberMutation(c.config, OpDelete)
|
||||
return &SerialNumberDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SerialNumberClient) DeleteOne(_m *SerialNumber) *SerialNumberDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *SerialNumberClient) DeleteOneID(id int) *SerialNumberDeleteOne {
|
||||
builder := c.Delete().Where(serialnumber.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SerialNumberDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for SerialNumber.
|
||||
func (c *SerialNumberClient) Query() *SerialNumberQuery {
|
||||
return &SerialNumberQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeSerialNumber},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a SerialNumber entity by its id.
|
||||
func (c *SerialNumberClient) Get(ctx context.Context, id int) (*SerialNumber, error) {
|
||||
return c.Query().Where(serialnumber.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SerialNumberClient) GetX(ctx context.Context, id int) *SerialNumber {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SerialNumberClient) Hooks() []Hook {
|
||||
return c.hooks.SerialNumber
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *SerialNumberClient) Interceptors() []Interceptor {
|
||||
return c.inters.SerialNumber
|
||||
}
|
||||
|
||||
func (c *SerialNumberClient) mutate(ctx context.Context, m *SerialNumberMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&SerialNumberCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&SerialNumberUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&SerialNumberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&SerialNumberDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown SerialNumber mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// StocktakeItemClient is a client for the StocktakeItem schema.
|
||||
type StocktakeItemClient struct {
|
||||
config
|
||||
@@ -2462,15 +2321,13 @@ func (c *ZoneClient) mutate(ctx context.Context, m *ZoneMutation) (Value, error)
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
InboundDetail, InboundOrder, InspectionRecord, InventoryBatch, InventoryLock,
|
||||
InboundDetail, InboundOrder, InspectionRecord, Inventory, InventoryLock,
|
||||
Material, OrderMaterialLedger, OutboundDetail, OutboundOrder, PackageBox,
|
||||
SemiFinished, SerialNumber, StocktakeItem, StocktakeOrder, User,
|
||||
Zone []ent.Hook
|
||||
SemiFinished, StocktakeItem, StocktakeOrder, User, Zone []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
InboundDetail, InboundOrder, InspectionRecord, InventoryBatch, InventoryLock,
|
||||
InboundDetail, InboundOrder, InspectionRecord, Inventory, InventoryLock,
|
||||
Material, OrderMaterialLedger, OutboundDetail, OutboundOrder, PackageBox,
|
||||
SemiFinished, SerialNumber, StocktakeItem, StocktakeOrder, User,
|
||||
Zone []ent.Interceptor
|
||||
SemiFinished, StocktakeItem, StocktakeOrder, User, Zone []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user