Files
bj_power/bj_power_wms/ent/client.go
T
SunYF a2afd2f6dc feat: 五项目业务实现并对接完成
- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE
- WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置
- WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页
- 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面
- Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理
- 清理各项目球形磨遗留代码,新增部署手册.md
2026-08-27 19:50:57 +08:00

2477 lines
93 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"log"
"reflect"
"bj_power_wms/ent/migrate"
"bj_power_wms/ent/inbounddetail"
"bj_power_wms/ent/inboundorder"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventorybatch"
"bj_power_wms/ent/inventorylock"
"bj_power_wms/ent/material"
"bj_power_wms/ent/ordermaterialledger"
"bj_power_wms/ent/outbounddetail"
"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"
"bj_power_wms/ent/zone"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
)
// Client is the client that holds all ent builders.
type Client struct {
config
// Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema
// InboundDetail is the client for interacting with the InboundDetail builders.
InboundDetail *InboundDetailClient
// InboundOrder is the client for interacting with the InboundOrder builders.
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
// InventoryLock is the client for interacting with the InventoryLock builders.
InventoryLock *InventoryLockClient
// Material is the client for interacting with the Material builders.
Material *MaterialClient
// OrderMaterialLedger is the client for interacting with the OrderMaterialLedger builders.
OrderMaterialLedger *OrderMaterialLedgerClient
// OutboundDetail is the client for interacting with the OutboundDetail builders.
OutboundDetail *OutboundDetailClient
// OutboundOrder is the client for interacting with the OutboundOrder builders.
OutboundOrder *OutboundOrderClient
// PackageBox is the client for interacting with the PackageBox builders.
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.
StocktakeOrder *StocktakeOrderClient
// User is the client for interacting with the User builders.
User *UserClient
// Zone is the client for interacting with the Zone builders.
Zone *ZoneClient
}
// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
client := &Client{config: newConfig(opts...)}
client.init()
return client
}
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.InboundDetail = NewInboundDetailClient(c.config)
c.InboundOrder = NewInboundOrderClient(c.config)
c.InspectionRecord = NewInspectionRecordClient(c.config)
c.InventoryBatch = NewInventoryBatchClient(c.config)
c.InventoryLock = NewInventoryLockClient(c.config)
c.Material = NewMaterialClient(c.config)
c.OrderMaterialLedger = NewOrderMaterialLedgerClient(c.config)
c.OutboundDetail = NewOutboundDetailClient(c.config)
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)
c.Zone = NewZoneClient(c.config)
}
type (
// config is the configuration for the client and its builder.
config struct {
// driver used for executing database requests.
driver dialect.Driver
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...any)
// hooks to execute on mutations.
hooks *hooks
// interceptors to execute on queries.
inters *inters
}
// Option function to configure the client.
Option func(*config)
)
// newConfig creates a new config for the client.
func newConfig(opts ...Option) config {
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
cfg.options(opts...)
return cfg
}
// options applies the options on the config object.
func (c *config) options(opts ...Option) {
for _, opt := range opts {
opt(c)
}
if c.debug {
c.driver = dialect.Debug(c.driver, c.log)
}
}
// Debug enables debug logging on the ent.Driver.
func Debug() Option {
return func(c *config) {
c.debug = true
}
}
// Log sets the logging function for debug mode.
func Log(fn func(...any)) Option {
return func(c *config) {
c.log = fn
}
}
// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
return func(c *config) {
c.driver = driver
}
}
// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
switch driverName {
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
drv, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return NewClient(append(options, Driver(drv))...), nil
default:
return nil, fmt.Errorf("unsupported driver: %q", driverName)
}
}
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
// Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, ErrTxStarted
}
tx, err := newTx(ctx, c.driver)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := c.config
cfg.driver = tx
return &Tx{
ctx: ctx,
config: cfg,
InboundDetail: NewInboundDetailClient(cfg),
InboundOrder: NewInboundOrderClient(cfg),
InspectionRecord: NewInspectionRecordClient(cfg),
InventoryBatch: NewInventoryBatchClient(cfg),
InventoryLock: NewInventoryLockClient(cfg),
Material: NewMaterialClient(cfg),
OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
OutboundDetail: NewOutboundDetailClient(cfg),
OutboundOrder: NewOutboundOrderClient(cfg),
PackageBox: NewPackageBoxClient(cfg),
SemiFinished: NewSemiFinishedClient(cfg),
SerialNumber: NewSerialNumberClient(cfg),
StocktakeItem: NewStocktakeItemClient(cfg),
StocktakeOrder: NewStocktakeOrderClient(cfg),
User: NewUserClient(cfg),
Zone: NewZoneClient(cfg),
}, nil
}
// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
}).BeginTx(ctx, opts)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
ctx: ctx,
config: cfg,
InboundDetail: NewInboundDetailClient(cfg),
InboundOrder: NewInboundOrderClient(cfg),
InspectionRecord: NewInspectionRecordClient(cfg),
InventoryBatch: NewInventoryBatchClient(cfg),
InventoryLock: NewInventoryLockClient(cfg),
Material: NewMaterialClient(cfg),
OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
OutboundDetail: NewOutboundDetailClient(cfg),
OutboundOrder: NewOutboundOrderClient(cfg),
PackageBox: NewPackageBoxClient(cfg),
SemiFinished: NewSemiFinishedClient(cfg),
SerialNumber: NewSerialNumberClient(cfg),
StocktakeItem: NewStocktakeItemClient(cfg),
StocktakeOrder: NewStocktakeOrderClient(cfg),
User: NewUserClient(cfg),
Zone: NewZoneClient(cfg),
}, nil
}
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
// client.Debug().
// InboundDetail.
// Query().
// Count(ctx)
func (c *Client) Debug() *Client {
if c.debug {
return c
}
cfg := c.config
cfg.driver = dialect.Debug(c.driver, c.log)
client := &Client{config: cfg}
client.init()
return client
}
// Close closes the database connection and prevents new queries from starting.
func (c *Client) Close() error {
return c.driver.Close()
}
// Use adds the mutation hooks to all the entity clients.
// 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.InventoryLock, c.Material, c.OrderMaterialLedger, c.OutboundDetail,
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.SerialNumber, c.StocktakeItem,
c.StocktakeOrder, c.User, c.Zone,
} {
n.Use(hooks...)
}
}
// Intercept adds the query interceptors to all the entity clients.
// 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.InventoryLock, c.Material, c.OrderMaterialLedger, c.OutboundDetail,
c.OutboundOrder, c.PackageBox, c.SemiFinished, c.SerialNumber, c.StocktakeItem,
c.StocktakeOrder, c.User, c.Zone,
} {
n.Intercept(interceptors...)
}
}
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *InboundDetailMutation:
return c.InboundDetail.mutate(ctx, m)
case *InboundOrderMutation:
return c.InboundOrder.mutate(ctx, m)
case *InspectionRecordMutation:
return c.InspectionRecord.mutate(ctx, m)
case *InventoryBatchMutation:
return c.InventoryBatch.mutate(ctx, m)
case *InventoryLockMutation:
return c.InventoryLock.mutate(ctx, m)
case *MaterialMutation:
return c.Material.mutate(ctx, m)
case *OrderMaterialLedgerMutation:
return c.OrderMaterialLedger.mutate(ctx, m)
case *OutboundDetailMutation:
return c.OutboundDetail.mutate(ctx, m)
case *OutboundOrderMutation:
return c.OutboundOrder.mutate(ctx, m)
case *PackageBoxMutation:
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:
return c.StocktakeOrder.mutate(ctx, m)
case *UserMutation:
return c.User.mutate(ctx, m)
case *ZoneMutation:
return c.Zone.mutate(ctx, m)
default:
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
}
}
// InboundDetailClient is a client for the InboundDetail schema.
type InboundDetailClient struct {
config
}
// NewInboundDetailClient returns a client for the InboundDetail from the given config.
func NewInboundDetailClient(c config) *InboundDetailClient {
return &InboundDetailClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `inbounddetail.Hooks(f(g(h())))`.
func (c *InboundDetailClient) Use(hooks ...Hook) {
c.hooks.InboundDetail = append(c.hooks.InboundDetail, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `inbounddetail.Intercept(f(g(h())))`.
func (c *InboundDetailClient) Intercept(interceptors ...Interceptor) {
c.inters.InboundDetail = append(c.inters.InboundDetail, interceptors...)
}
// Create returns a builder for creating a InboundDetail entity.
func (c *InboundDetailClient) Create() *InboundDetailCreate {
mutation := newInboundDetailMutation(c.config, OpCreate)
return &InboundDetailCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of InboundDetail entities.
func (c *InboundDetailClient) CreateBulk(builders ...*InboundDetailCreate) *InboundDetailCreateBulk {
return &InboundDetailCreateBulk{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 *InboundDetailClient) MapCreateBulk(slice any, setFunc func(*InboundDetailCreate, int)) *InboundDetailCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &InboundDetailCreateBulk{err: fmt.Errorf("calling to InboundDetailClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*InboundDetailCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &InboundDetailCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for InboundDetail.
func (c *InboundDetailClient) Update() *InboundDetailUpdate {
mutation := newInboundDetailMutation(c.config, OpUpdate)
return &InboundDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *InboundDetailClient) UpdateOne(_m *InboundDetail) *InboundDetailUpdateOne {
mutation := newInboundDetailMutation(c.config, OpUpdateOne, withInboundDetail(_m))
return &InboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *InboundDetailClient) UpdateOneID(id int) *InboundDetailUpdateOne {
mutation := newInboundDetailMutation(c.config, OpUpdateOne, withInboundDetailID(id))
return &InboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for InboundDetail.
func (c *InboundDetailClient) Delete() *InboundDetailDelete {
mutation := newInboundDetailMutation(c.config, OpDelete)
return &InboundDetailDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InboundDetailClient) DeleteOne(_m *InboundDetail) *InboundDetailDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *InboundDetailClient) DeleteOneID(id int) *InboundDetailDeleteOne {
builder := c.Delete().Where(inbounddetail.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InboundDetailDeleteOne{builder}
}
// Query returns a query builder for InboundDetail.
func (c *InboundDetailClient) Query() *InboundDetailQuery {
return &InboundDetailQuery{
config: c.config,
ctx: &QueryContext{Type: TypeInboundDetail},
inters: c.Interceptors(),
}
}
// Get returns a InboundDetail entity by its id.
func (c *InboundDetailClient) Get(ctx context.Context, id int) (*InboundDetail, error) {
return c.Query().Where(inbounddetail.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *InboundDetailClient) GetX(ctx context.Context, id int) *InboundDetail {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *InboundDetailClient) Hooks() []Hook {
return c.hooks.InboundDetail
}
// Interceptors returns the client interceptors.
func (c *InboundDetailClient) Interceptors() []Interceptor {
return c.inters.InboundDetail
}
func (c *InboundDetailClient) mutate(ctx context.Context, m *InboundDetailMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&InboundDetailCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&InboundDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&InboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&InboundDetailDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown InboundDetail mutation op: %q", m.Op())
}
}
// InboundOrderClient is a client for the InboundOrder schema.
type InboundOrderClient struct {
config
}
// NewInboundOrderClient returns a client for the InboundOrder from the given config.
func NewInboundOrderClient(c config) *InboundOrderClient {
return &InboundOrderClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `inboundorder.Hooks(f(g(h())))`.
func (c *InboundOrderClient) Use(hooks ...Hook) {
c.hooks.InboundOrder = append(c.hooks.InboundOrder, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `inboundorder.Intercept(f(g(h())))`.
func (c *InboundOrderClient) Intercept(interceptors ...Interceptor) {
c.inters.InboundOrder = append(c.inters.InboundOrder, interceptors...)
}
// Create returns a builder for creating a InboundOrder entity.
func (c *InboundOrderClient) Create() *InboundOrderCreate {
mutation := newInboundOrderMutation(c.config, OpCreate)
return &InboundOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of InboundOrder entities.
func (c *InboundOrderClient) CreateBulk(builders ...*InboundOrderCreate) *InboundOrderCreateBulk {
return &InboundOrderCreateBulk{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 *InboundOrderClient) MapCreateBulk(slice any, setFunc func(*InboundOrderCreate, int)) *InboundOrderCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &InboundOrderCreateBulk{err: fmt.Errorf("calling to InboundOrderClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*InboundOrderCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &InboundOrderCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for InboundOrder.
func (c *InboundOrderClient) Update() *InboundOrderUpdate {
mutation := newInboundOrderMutation(c.config, OpUpdate)
return &InboundOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *InboundOrderClient) UpdateOne(_m *InboundOrder) *InboundOrderUpdateOne {
mutation := newInboundOrderMutation(c.config, OpUpdateOne, withInboundOrder(_m))
return &InboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *InboundOrderClient) UpdateOneID(id int) *InboundOrderUpdateOne {
mutation := newInboundOrderMutation(c.config, OpUpdateOne, withInboundOrderID(id))
return &InboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for InboundOrder.
func (c *InboundOrderClient) Delete() *InboundOrderDelete {
mutation := newInboundOrderMutation(c.config, OpDelete)
return &InboundOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InboundOrderClient) DeleteOne(_m *InboundOrder) *InboundOrderDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *InboundOrderClient) DeleteOneID(id int) *InboundOrderDeleteOne {
builder := c.Delete().Where(inboundorder.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InboundOrderDeleteOne{builder}
}
// Query returns a query builder for InboundOrder.
func (c *InboundOrderClient) Query() *InboundOrderQuery {
return &InboundOrderQuery{
config: c.config,
ctx: &QueryContext{Type: TypeInboundOrder},
inters: c.Interceptors(),
}
}
// Get returns a InboundOrder entity by its id.
func (c *InboundOrderClient) Get(ctx context.Context, id int) (*InboundOrder, error) {
return c.Query().Where(inboundorder.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *InboundOrderClient) GetX(ctx context.Context, id int) *InboundOrder {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *InboundOrderClient) Hooks() []Hook {
return c.hooks.InboundOrder
}
// Interceptors returns the client interceptors.
func (c *InboundOrderClient) Interceptors() []Interceptor {
return c.inters.InboundOrder
}
func (c *InboundOrderClient) mutate(ctx context.Context, m *InboundOrderMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&InboundOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&InboundOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&InboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&InboundOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown InboundOrder mutation op: %q", m.Op())
}
}
// InspectionRecordClient is a client for the InspectionRecord schema.
type InspectionRecordClient struct {
config
}
// NewInspectionRecordClient returns a client for the InspectionRecord from the given config.
func NewInspectionRecordClient(c config) *InspectionRecordClient {
return &InspectionRecordClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `inspectionrecord.Hooks(f(g(h())))`.
func (c *InspectionRecordClient) Use(hooks ...Hook) {
c.hooks.InspectionRecord = append(c.hooks.InspectionRecord, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `inspectionrecord.Intercept(f(g(h())))`.
func (c *InspectionRecordClient) Intercept(interceptors ...Interceptor) {
c.inters.InspectionRecord = append(c.inters.InspectionRecord, interceptors...)
}
// Create returns a builder for creating a InspectionRecord entity.
func (c *InspectionRecordClient) Create() *InspectionRecordCreate {
mutation := newInspectionRecordMutation(c.config, OpCreate)
return &InspectionRecordCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of InspectionRecord entities.
func (c *InspectionRecordClient) CreateBulk(builders ...*InspectionRecordCreate) *InspectionRecordCreateBulk {
return &InspectionRecordCreateBulk{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 *InspectionRecordClient) MapCreateBulk(slice any, setFunc func(*InspectionRecordCreate, int)) *InspectionRecordCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &InspectionRecordCreateBulk{err: fmt.Errorf("calling to InspectionRecordClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*InspectionRecordCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &InspectionRecordCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for InspectionRecord.
func (c *InspectionRecordClient) Update() *InspectionRecordUpdate {
mutation := newInspectionRecordMutation(c.config, OpUpdate)
return &InspectionRecordUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *InspectionRecordClient) UpdateOne(_m *InspectionRecord) *InspectionRecordUpdateOne {
mutation := newInspectionRecordMutation(c.config, OpUpdateOne, withInspectionRecord(_m))
return &InspectionRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *InspectionRecordClient) UpdateOneID(id int) *InspectionRecordUpdateOne {
mutation := newInspectionRecordMutation(c.config, OpUpdateOne, withInspectionRecordID(id))
return &InspectionRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for InspectionRecord.
func (c *InspectionRecordClient) Delete() *InspectionRecordDelete {
mutation := newInspectionRecordMutation(c.config, OpDelete)
return &InspectionRecordDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InspectionRecordClient) DeleteOne(_m *InspectionRecord) *InspectionRecordDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *InspectionRecordClient) DeleteOneID(id int) *InspectionRecordDeleteOne {
builder := c.Delete().Where(inspectionrecord.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InspectionRecordDeleteOne{builder}
}
// Query returns a query builder for InspectionRecord.
func (c *InspectionRecordClient) Query() *InspectionRecordQuery {
return &InspectionRecordQuery{
config: c.config,
ctx: &QueryContext{Type: TypeInspectionRecord},
inters: c.Interceptors(),
}
}
// Get returns a InspectionRecord entity by its id.
func (c *InspectionRecordClient) Get(ctx context.Context, id int) (*InspectionRecord, error) {
return c.Query().Where(inspectionrecord.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *InspectionRecordClient) GetX(ctx context.Context, id int) *InspectionRecord {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *InspectionRecordClient) Hooks() []Hook {
return c.hooks.InspectionRecord
}
// Interceptors returns the client interceptors.
func (c *InspectionRecordClient) Interceptors() []Interceptor {
return c.inters.InspectionRecord
}
func (c *InspectionRecordClient) mutate(ctx context.Context, m *InspectionRecordMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&InspectionRecordCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&InspectionRecordUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&InspectionRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&InspectionRecordDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown InspectionRecord mutation op: %q", m.Op())
}
}
// InventoryBatchClient is a client for the InventoryBatch schema.
type InventoryBatchClient struct {
config
}
// NewInventoryBatchClient returns a client for the InventoryBatch from the given config.
func NewInventoryBatchClient(c config) *InventoryBatchClient {
return &InventoryBatchClient{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...)
}
// 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...)
}
// 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}
}
// 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}
}
// 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 {
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)}
}
builders := make([]*InventoryBatchCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &InventoryBatchCreateBulk{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}
}
// 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}
}
// 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}
}
// 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}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InventoryBatchClient) DeleteOne(_m *InventoryBatch) *InventoryBatchDeleteOne {
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))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InventoryBatchDeleteOne{builder}
}
// Query returns a query builder for InventoryBatch.
func (c *InventoryBatchClient) Query() *InventoryBatchQuery {
return &InventoryBatchQuery{
config: c.config,
ctx: &QueryContext{Type: TypeInventoryBatch},
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)
}
// GetX is like Get, but panics if an error occurs.
func (c *InventoryBatchClient) GetX(ctx context.Context, id int) *InventoryBatch {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *InventoryBatchClient) Hooks() []Hook {
return c.hooks.InventoryBatch
}
// Interceptors returns the client interceptors.
func (c *InventoryBatchClient) Interceptors() []Interceptor {
return c.inters.InventoryBatch
}
func (c *InventoryBatchClient) mutate(ctx context.Context, m *InventoryBatchMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&InventoryBatchCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&InventoryBatchUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&InventoryBatchUpdateOne{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)
default:
return nil, fmt.Errorf("ent: unknown InventoryBatch mutation op: %q", m.Op())
}
}
// InventoryLockClient is a client for the InventoryLock schema.
type InventoryLockClient struct {
config
}
// NewInventoryLockClient returns a client for the InventoryLock from the given config.
func NewInventoryLockClient(c config) *InventoryLockClient {
return &InventoryLockClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `inventorylock.Hooks(f(g(h())))`.
func (c *InventoryLockClient) Use(hooks ...Hook) {
c.hooks.InventoryLock = append(c.hooks.InventoryLock, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `inventorylock.Intercept(f(g(h())))`.
func (c *InventoryLockClient) Intercept(interceptors ...Interceptor) {
c.inters.InventoryLock = append(c.inters.InventoryLock, interceptors...)
}
// Create returns a builder for creating a InventoryLock entity.
func (c *InventoryLockClient) Create() *InventoryLockCreate {
mutation := newInventoryLockMutation(c.config, OpCreate)
return &InventoryLockCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of InventoryLock entities.
func (c *InventoryLockClient) CreateBulk(builders ...*InventoryLockCreate) *InventoryLockCreateBulk {
return &InventoryLockCreateBulk{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 *InventoryLockClient) MapCreateBulk(slice any, setFunc func(*InventoryLockCreate, int)) *InventoryLockCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &InventoryLockCreateBulk{err: fmt.Errorf("calling to InventoryLockClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*InventoryLockCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &InventoryLockCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for InventoryLock.
func (c *InventoryLockClient) Update() *InventoryLockUpdate {
mutation := newInventoryLockMutation(c.config, OpUpdate)
return &InventoryLockUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *InventoryLockClient) UpdateOne(_m *InventoryLock) *InventoryLockUpdateOne {
mutation := newInventoryLockMutation(c.config, OpUpdateOne, withInventoryLock(_m))
return &InventoryLockUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *InventoryLockClient) UpdateOneID(id int) *InventoryLockUpdateOne {
mutation := newInventoryLockMutation(c.config, OpUpdateOne, withInventoryLockID(id))
return &InventoryLockUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for InventoryLock.
func (c *InventoryLockClient) Delete() *InventoryLockDelete {
mutation := newInventoryLockMutation(c.config, OpDelete)
return &InventoryLockDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *InventoryLockClient) DeleteOne(_m *InventoryLock) *InventoryLockDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *InventoryLockClient) DeleteOneID(id int) *InventoryLockDeleteOne {
builder := c.Delete().Where(inventorylock.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &InventoryLockDeleteOne{builder}
}
// Query returns a query builder for InventoryLock.
func (c *InventoryLockClient) Query() *InventoryLockQuery {
return &InventoryLockQuery{
config: c.config,
ctx: &QueryContext{Type: TypeInventoryLock},
inters: c.Interceptors(),
}
}
// Get returns a InventoryLock entity by its id.
func (c *InventoryLockClient) Get(ctx context.Context, id int) (*InventoryLock, error) {
return c.Query().Where(inventorylock.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *InventoryLockClient) GetX(ctx context.Context, id int) *InventoryLock {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *InventoryLockClient) Hooks() []Hook {
return c.hooks.InventoryLock
}
// Interceptors returns the client interceptors.
func (c *InventoryLockClient) Interceptors() []Interceptor {
return c.inters.InventoryLock
}
func (c *InventoryLockClient) mutate(ctx context.Context, m *InventoryLockMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&InventoryLockCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&InventoryLockUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&InventoryLockUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&InventoryLockDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown InventoryLock mutation op: %q", m.Op())
}
}
// MaterialClient is a client for the Material schema.
type MaterialClient struct {
config
}
// NewMaterialClient returns a client for the Material from the given config.
func NewMaterialClient(c config) *MaterialClient {
return &MaterialClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `material.Hooks(f(g(h())))`.
func (c *MaterialClient) Use(hooks ...Hook) {
c.hooks.Material = append(c.hooks.Material, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `material.Intercept(f(g(h())))`.
func (c *MaterialClient) Intercept(interceptors ...Interceptor) {
c.inters.Material = append(c.inters.Material, interceptors...)
}
// Create returns a builder for creating a Material entity.
func (c *MaterialClient) Create() *MaterialCreate {
mutation := newMaterialMutation(c.config, OpCreate)
return &MaterialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Material entities.
func (c *MaterialClient) CreateBulk(builders ...*MaterialCreate) *MaterialCreateBulk {
return &MaterialCreateBulk{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 *MaterialClient) MapCreateBulk(slice any, setFunc func(*MaterialCreate, int)) *MaterialCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &MaterialCreateBulk{err: fmt.Errorf("calling to MaterialClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*MaterialCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &MaterialCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Material.
func (c *MaterialClient) Update() *MaterialUpdate {
mutation := newMaterialMutation(c.config, OpUpdate)
return &MaterialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *MaterialClient) UpdateOne(_m *Material) *MaterialUpdateOne {
mutation := newMaterialMutation(c.config, OpUpdateOne, withMaterial(_m))
return &MaterialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *MaterialClient) UpdateOneID(id int) *MaterialUpdateOne {
mutation := newMaterialMutation(c.config, OpUpdateOne, withMaterialID(id))
return &MaterialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Material.
func (c *MaterialClient) Delete() *MaterialDelete {
mutation := newMaterialMutation(c.config, OpDelete)
return &MaterialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *MaterialClient) DeleteOne(_m *Material) *MaterialDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *MaterialClient) DeleteOneID(id int) *MaterialDeleteOne {
builder := c.Delete().Where(material.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &MaterialDeleteOne{builder}
}
// Query returns a query builder for Material.
func (c *MaterialClient) Query() *MaterialQuery {
return &MaterialQuery{
config: c.config,
ctx: &QueryContext{Type: TypeMaterial},
inters: c.Interceptors(),
}
}
// Get returns a Material entity by its id.
func (c *MaterialClient) Get(ctx context.Context, id int) (*Material, error) {
return c.Query().Where(material.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *MaterialClient) GetX(ctx context.Context, id int) *Material {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *MaterialClient) Hooks() []Hook {
return c.hooks.Material
}
// Interceptors returns the client interceptors.
func (c *MaterialClient) Interceptors() []Interceptor {
return c.inters.Material
}
func (c *MaterialClient) mutate(ctx context.Context, m *MaterialMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&MaterialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&MaterialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&MaterialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&MaterialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Material mutation op: %q", m.Op())
}
}
// OrderMaterialLedgerClient is a client for the OrderMaterialLedger schema.
type OrderMaterialLedgerClient struct {
config
}
// NewOrderMaterialLedgerClient returns a client for the OrderMaterialLedger from the given config.
func NewOrderMaterialLedgerClient(c config) *OrderMaterialLedgerClient {
return &OrderMaterialLedgerClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `ordermaterialledger.Hooks(f(g(h())))`.
func (c *OrderMaterialLedgerClient) Use(hooks ...Hook) {
c.hooks.OrderMaterialLedger = append(c.hooks.OrderMaterialLedger, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `ordermaterialledger.Intercept(f(g(h())))`.
func (c *OrderMaterialLedgerClient) Intercept(interceptors ...Interceptor) {
c.inters.OrderMaterialLedger = append(c.inters.OrderMaterialLedger, interceptors...)
}
// Create returns a builder for creating a OrderMaterialLedger entity.
func (c *OrderMaterialLedgerClient) Create() *OrderMaterialLedgerCreate {
mutation := newOrderMaterialLedgerMutation(c.config, OpCreate)
return &OrderMaterialLedgerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of OrderMaterialLedger entities.
func (c *OrderMaterialLedgerClient) CreateBulk(builders ...*OrderMaterialLedgerCreate) *OrderMaterialLedgerCreateBulk {
return &OrderMaterialLedgerCreateBulk{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 *OrderMaterialLedgerClient) MapCreateBulk(slice any, setFunc func(*OrderMaterialLedgerCreate, int)) *OrderMaterialLedgerCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &OrderMaterialLedgerCreateBulk{err: fmt.Errorf("calling to OrderMaterialLedgerClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*OrderMaterialLedgerCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &OrderMaterialLedgerCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for OrderMaterialLedger.
func (c *OrderMaterialLedgerClient) Update() *OrderMaterialLedgerUpdate {
mutation := newOrderMaterialLedgerMutation(c.config, OpUpdate)
return &OrderMaterialLedgerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *OrderMaterialLedgerClient) UpdateOne(_m *OrderMaterialLedger) *OrderMaterialLedgerUpdateOne {
mutation := newOrderMaterialLedgerMutation(c.config, OpUpdateOne, withOrderMaterialLedger(_m))
return &OrderMaterialLedgerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *OrderMaterialLedgerClient) UpdateOneID(id int) *OrderMaterialLedgerUpdateOne {
mutation := newOrderMaterialLedgerMutation(c.config, OpUpdateOne, withOrderMaterialLedgerID(id))
return &OrderMaterialLedgerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for OrderMaterialLedger.
func (c *OrderMaterialLedgerClient) Delete() *OrderMaterialLedgerDelete {
mutation := newOrderMaterialLedgerMutation(c.config, OpDelete)
return &OrderMaterialLedgerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *OrderMaterialLedgerClient) DeleteOne(_m *OrderMaterialLedger) *OrderMaterialLedgerDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *OrderMaterialLedgerClient) DeleteOneID(id int) *OrderMaterialLedgerDeleteOne {
builder := c.Delete().Where(ordermaterialledger.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &OrderMaterialLedgerDeleteOne{builder}
}
// Query returns a query builder for OrderMaterialLedger.
func (c *OrderMaterialLedgerClient) Query() *OrderMaterialLedgerQuery {
return &OrderMaterialLedgerQuery{
config: c.config,
ctx: &QueryContext{Type: TypeOrderMaterialLedger},
inters: c.Interceptors(),
}
}
// Get returns a OrderMaterialLedger entity by its id.
func (c *OrderMaterialLedgerClient) Get(ctx context.Context, id int) (*OrderMaterialLedger, error) {
return c.Query().Where(ordermaterialledger.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *OrderMaterialLedgerClient) GetX(ctx context.Context, id int) *OrderMaterialLedger {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *OrderMaterialLedgerClient) Hooks() []Hook {
return c.hooks.OrderMaterialLedger
}
// Interceptors returns the client interceptors.
func (c *OrderMaterialLedgerClient) Interceptors() []Interceptor {
return c.inters.OrderMaterialLedger
}
func (c *OrderMaterialLedgerClient) mutate(ctx context.Context, m *OrderMaterialLedgerMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&OrderMaterialLedgerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&OrderMaterialLedgerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&OrderMaterialLedgerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&OrderMaterialLedgerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown OrderMaterialLedger mutation op: %q", m.Op())
}
}
// OutboundDetailClient is a client for the OutboundDetail schema.
type OutboundDetailClient struct {
config
}
// NewOutboundDetailClient returns a client for the OutboundDetail from the given config.
func NewOutboundDetailClient(c config) *OutboundDetailClient {
return &OutboundDetailClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `outbounddetail.Hooks(f(g(h())))`.
func (c *OutboundDetailClient) Use(hooks ...Hook) {
c.hooks.OutboundDetail = append(c.hooks.OutboundDetail, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `outbounddetail.Intercept(f(g(h())))`.
func (c *OutboundDetailClient) Intercept(interceptors ...Interceptor) {
c.inters.OutboundDetail = append(c.inters.OutboundDetail, interceptors...)
}
// Create returns a builder for creating a OutboundDetail entity.
func (c *OutboundDetailClient) Create() *OutboundDetailCreate {
mutation := newOutboundDetailMutation(c.config, OpCreate)
return &OutboundDetailCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of OutboundDetail entities.
func (c *OutboundDetailClient) CreateBulk(builders ...*OutboundDetailCreate) *OutboundDetailCreateBulk {
return &OutboundDetailCreateBulk{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 *OutboundDetailClient) MapCreateBulk(slice any, setFunc func(*OutboundDetailCreate, int)) *OutboundDetailCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &OutboundDetailCreateBulk{err: fmt.Errorf("calling to OutboundDetailClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*OutboundDetailCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &OutboundDetailCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for OutboundDetail.
func (c *OutboundDetailClient) Update() *OutboundDetailUpdate {
mutation := newOutboundDetailMutation(c.config, OpUpdate)
return &OutboundDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *OutboundDetailClient) UpdateOne(_m *OutboundDetail) *OutboundDetailUpdateOne {
mutation := newOutboundDetailMutation(c.config, OpUpdateOne, withOutboundDetail(_m))
return &OutboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *OutboundDetailClient) UpdateOneID(id int) *OutboundDetailUpdateOne {
mutation := newOutboundDetailMutation(c.config, OpUpdateOne, withOutboundDetailID(id))
return &OutboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for OutboundDetail.
func (c *OutboundDetailClient) Delete() *OutboundDetailDelete {
mutation := newOutboundDetailMutation(c.config, OpDelete)
return &OutboundDetailDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *OutboundDetailClient) DeleteOne(_m *OutboundDetail) *OutboundDetailDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *OutboundDetailClient) DeleteOneID(id int) *OutboundDetailDeleteOne {
builder := c.Delete().Where(outbounddetail.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &OutboundDetailDeleteOne{builder}
}
// Query returns a query builder for OutboundDetail.
func (c *OutboundDetailClient) Query() *OutboundDetailQuery {
return &OutboundDetailQuery{
config: c.config,
ctx: &QueryContext{Type: TypeOutboundDetail},
inters: c.Interceptors(),
}
}
// Get returns a OutboundDetail entity by its id.
func (c *OutboundDetailClient) Get(ctx context.Context, id int) (*OutboundDetail, error) {
return c.Query().Where(outbounddetail.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *OutboundDetailClient) GetX(ctx context.Context, id int) *OutboundDetail {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *OutboundDetailClient) Hooks() []Hook {
return c.hooks.OutboundDetail
}
// Interceptors returns the client interceptors.
func (c *OutboundDetailClient) Interceptors() []Interceptor {
return c.inters.OutboundDetail
}
func (c *OutboundDetailClient) mutate(ctx context.Context, m *OutboundDetailMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&OutboundDetailCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&OutboundDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&OutboundDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&OutboundDetailDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown OutboundDetail mutation op: %q", m.Op())
}
}
// OutboundOrderClient is a client for the OutboundOrder schema.
type OutboundOrderClient struct {
config
}
// NewOutboundOrderClient returns a client for the OutboundOrder from the given config.
func NewOutboundOrderClient(c config) *OutboundOrderClient {
return &OutboundOrderClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `outboundorder.Hooks(f(g(h())))`.
func (c *OutboundOrderClient) Use(hooks ...Hook) {
c.hooks.OutboundOrder = append(c.hooks.OutboundOrder, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `outboundorder.Intercept(f(g(h())))`.
func (c *OutboundOrderClient) Intercept(interceptors ...Interceptor) {
c.inters.OutboundOrder = append(c.inters.OutboundOrder, interceptors...)
}
// Create returns a builder for creating a OutboundOrder entity.
func (c *OutboundOrderClient) Create() *OutboundOrderCreate {
mutation := newOutboundOrderMutation(c.config, OpCreate)
return &OutboundOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of OutboundOrder entities.
func (c *OutboundOrderClient) CreateBulk(builders ...*OutboundOrderCreate) *OutboundOrderCreateBulk {
return &OutboundOrderCreateBulk{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 *OutboundOrderClient) MapCreateBulk(slice any, setFunc func(*OutboundOrderCreate, int)) *OutboundOrderCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &OutboundOrderCreateBulk{err: fmt.Errorf("calling to OutboundOrderClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*OutboundOrderCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &OutboundOrderCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for OutboundOrder.
func (c *OutboundOrderClient) Update() *OutboundOrderUpdate {
mutation := newOutboundOrderMutation(c.config, OpUpdate)
return &OutboundOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *OutboundOrderClient) UpdateOne(_m *OutboundOrder) *OutboundOrderUpdateOne {
mutation := newOutboundOrderMutation(c.config, OpUpdateOne, withOutboundOrder(_m))
return &OutboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *OutboundOrderClient) UpdateOneID(id int) *OutboundOrderUpdateOne {
mutation := newOutboundOrderMutation(c.config, OpUpdateOne, withOutboundOrderID(id))
return &OutboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for OutboundOrder.
func (c *OutboundOrderClient) Delete() *OutboundOrderDelete {
mutation := newOutboundOrderMutation(c.config, OpDelete)
return &OutboundOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *OutboundOrderClient) DeleteOne(_m *OutboundOrder) *OutboundOrderDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *OutboundOrderClient) DeleteOneID(id int) *OutboundOrderDeleteOne {
builder := c.Delete().Where(outboundorder.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &OutboundOrderDeleteOne{builder}
}
// Query returns a query builder for OutboundOrder.
func (c *OutboundOrderClient) Query() *OutboundOrderQuery {
return &OutboundOrderQuery{
config: c.config,
ctx: &QueryContext{Type: TypeOutboundOrder},
inters: c.Interceptors(),
}
}
// Get returns a OutboundOrder entity by its id.
func (c *OutboundOrderClient) Get(ctx context.Context, id int) (*OutboundOrder, error) {
return c.Query().Where(outboundorder.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *OutboundOrderClient) GetX(ctx context.Context, id int) *OutboundOrder {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *OutboundOrderClient) Hooks() []Hook {
return c.hooks.OutboundOrder
}
// Interceptors returns the client interceptors.
func (c *OutboundOrderClient) Interceptors() []Interceptor {
return c.inters.OutboundOrder
}
func (c *OutboundOrderClient) mutate(ctx context.Context, m *OutboundOrderMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&OutboundOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&OutboundOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&OutboundOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&OutboundOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown OutboundOrder mutation op: %q", m.Op())
}
}
// PackageBoxClient is a client for the PackageBox schema.
type PackageBoxClient struct {
config
}
// NewPackageBoxClient returns a client for the PackageBox from the given config.
func NewPackageBoxClient(c config) *PackageBoxClient {
return &PackageBoxClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `packagebox.Hooks(f(g(h())))`.
func (c *PackageBoxClient) Use(hooks ...Hook) {
c.hooks.PackageBox = append(c.hooks.PackageBox, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `packagebox.Intercept(f(g(h())))`.
func (c *PackageBoxClient) Intercept(interceptors ...Interceptor) {
c.inters.PackageBox = append(c.inters.PackageBox, interceptors...)
}
// Create returns a builder for creating a PackageBox entity.
func (c *PackageBoxClient) Create() *PackageBoxCreate {
mutation := newPackageBoxMutation(c.config, OpCreate)
return &PackageBoxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of PackageBox entities.
func (c *PackageBoxClient) CreateBulk(builders ...*PackageBoxCreate) *PackageBoxCreateBulk {
return &PackageBoxCreateBulk{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 *PackageBoxClient) MapCreateBulk(slice any, setFunc func(*PackageBoxCreate, int)) *PackageBoxCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &PackageBoxCreateBulk{err: fmt.Errorf("calling to PackageBoxClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*PackageBoxCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &PackageBoxCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for PackageBox.
func (c *PackageBoxClient) Update() *PackageBoxUpdate {
mutation := newPackageBoxMutation(c.config, OpUpdate)
return &PackageBoxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *PackageBoxClient) UpdateOne(_m *PackageBox) *PackageBoxUpdateOne {
mutation := newPackageBoxMutation(c.config, OpUpdateOne, withPackageBox(_m))
return &PackageBoxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *PackageBoxClient) UpdateOneID(id int) *PackageBoxUpdateOne {
mutation := newPackageBoxMutation(c.config, OpUpdateOne, withPackageBoxID(id))
return &PackageBoxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for PackageBox.
func (c *PackageBoxClient) Delete() *PackageBoxDelete {
mutation := newPackageBoxMutation(c.config, OpDelete)
return &PackageBoxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *PackageBoxClient) DeleteOne(_m *PackageBox) *PackageBoxDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *PackageBoxClient) DeleteOneID(id int) *PackageBoxDeleteOne {
builder := c.Delete().Where(packagebox.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &PackageBoxDeleteOne{builder}
}
// Query returns a query builder for PackageBox.
func (c *PackageBoxClient) Query() *PackageBoxQuery {
return &PackageBoxQuery{
config: c.config,
ctx: &QueryContext{Type: TypePackageBox},
inters: c.Interceptors(),
}
}
// Get returns a PackageBox entity by its id.
func (c *PackageBoxClient) Get(ctx context.Context, id int) (*PackageBox, error) {
return c.Query().Where(packagebox.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *PackageBoxClient) GetX(ctx context.Context, id int) *PackageBox {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *PackageBoxClient) Hooks() []Hook {
return c.hooks.PackageBox
}
// Interceptors returns the client interceptors.
func (c *PackageBoxClient) Interceptors() []Interceptor {
return c.inters.PackageBox
}
func (c *PackageBoxClient) mutate(ctx context.Context, m *PackageBoxMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&PackageBoxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&PackageBoxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&PackageBoxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&PackageBoxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown PackageBox mutation op: %q", m.Op())
}
}
// SemiFinishedClient is a client for the SemiFinished schema.
type SemiFinishedClient struct {
config
}
// NewSemiFinishedClient returns a client for the SemiFinished from the given config.
func NewSemiFinishedClient(c config) *SemiFinishedClient {
return &SemiFinishedClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `semifinished.Hooks(f(g(h())))`.
func (c *SemiFinishedClient) Use(hooks ...Hook) {
c.hooks.SemiFinished = append(c.hooks.SemiFinished, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `semifinished.Intercept(f(g(h())))`.
func (c *SemiFinishedClient) Intercept(interceptors ...Interceptor) {
c.inters.SemiFinished = append(c.inters.SemiFinished, interceptors...)
}
// Create returns a builder for creating a SemiFinished entity.
func (c *SemiFinishedClient) Create() *SemiFinishedCreate {
mutation := newSemiFinishedMutation(c.config, OpCreate)
return &SemiFinishedCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of SemiFinished entities.
func (c *SemiFinishedClient) CreateBulk(builders ...*SemiFinishedCreate) *SemiFinishedCreateBulk {
return &SemiFinishedCreateBulk{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 *SemiFinishedClient) MapCreateBulk(slice any, setFunc func(*SemiFinishedCreate, int)) *SemiFinishedCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &SemiFinishedCreateBulk{err: fmt.Errorf("calling to SemiFinishedClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*SemiFinishedCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &SemiFinishedCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for SemiFinished.
func (c *SemiFinishedClient) Update() *SemiFinishedUpdate {
mutation := newSemiFinishedMutation(c.config, OpUpdate)
return &SemiFinishedUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *SemiFinishedClient) UpdateOne(_m *SemiFinished) *SemiFinishedUpdateOne {
mutation := newSemiFinishedMutation(c.config, OpUpdateOne, withSemiFinished(_m))
return &SemiFinishedUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *SemiFinishedClient) UpdateOneID(id int) *SemiFinishedUpdateOne {
mutation := newSemiFinishedMutation(c.config, OpUpdateOne, withSemiFinishedID(id))
return &SemiFinishedUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for SemiFinished.
func (c *SemiFinishedClient) Delete() *SemiFinishedDelete {
mutation := newSemiFinishedMutation(c.config, OpDelete)
return &SemiFinishedDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *SemiFinishedClient) DeleteOne(_m *SemiFinished) *SemiFinishedDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SemiFinishedClient) DeleteOneID(id int) *SemiFinishedDeleteOne {
builder := c.Delete().Where(semifinished.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &SemiFinishedDeleteOne{builder}
}
// Query returns a query builder for SemiFinished.
func (c *SemiFinishedClient) Query() *SemiFinishedQuery {
return &SemiFinishedQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSemiFinished},
inters: c.Interceptors(),
}
}
// Get returns a SemiFinished entity by its id.
func (c *SemiFinishedClient) Get(ctx context.Context, id int) (*SemiFinished, error) {
return c.Query().Where(semifinished.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *SemiFinishedClient) GetX(ctx context.Context, id int) *SemiFinished {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *SemiFinishedClient) Hooks() []Hook {
return c.hooks.SemiFinished
}
// Interceptors returns the client interceptors.
func (c *SemiFinishedClient) Interceptors() []Interceptor {
return c.inters.SemiFinished
}
func (c *SemiFinishedClient) mutate(ctx context.Context, m *SemiFinishedMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SemiFinishedCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SemiFinishedUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SemiFinishedUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SemiFinishedDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown SemiFinished mutation op: %q", m.Op())
}
}
// 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
}
// NewStocktakeItemClient returns a client for the StocktakeItem from the given config.
func NewStocktakeItemClient(c config) *StocktakeItemClient {
return &StocktakeItemClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `stocktakeitem.Hooks(f(g(h())))`.
func (c *StocktakeItemClient) Use(hooks ...Hook) {
c.hooks.StocktakeItem = append(c.hooks.StocktakeItem, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `stocktakeitem.Intercept(f(g(h())))`.
func (c *StocktakeItemClient) Intercept(interceptors ...Interceptor) {
c.inters.StocktakeItem = append(c.inters.StocktakeItem, interceptors...)
}
// Create returns a builder for creating a StocktakeItem entity.
func (c *StocktakeItemClient) Create() *StocktakeItemCreate {
mutation := newStocktakeItemMutation(c.config, OpCreate)
return &StocktakeItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of StocktakeItem entities.
func (c *StocktakeItemClient) CreateBulk(builders ...*StocktakeItemCreate) *StocktakeItemCreateBulk {
return &StocktakeItemCreateBulk{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 *StocktakeItemClient) MapCreateBulk(slice any, setFunc func(*StocktakeItemCreate, int)) *StocktakeItemCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &StocktakeItemCreateBulk{err: fmt.Errorf("calling to StocktakeItemClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*StocktakeItemCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &StocktakeItemCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for StocktakeItem.
func (c *StocktakeItemClient) Update() *StocktakeItemUpdate {
mutation := newStocktakeItemMutation(c.config, OpUpdate)
return &StocktakeItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *StocktakeItemClient) UpdateOne(_m *StocktakeItem) *StocktakeItemUpdateOne {
mutation := newStocktakeItemMutation(c.config, OpUpdateOne, withStocktakeItem(_m))
return &StocktakeItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *StocktakeItemClient) UpdateOneID(id int) *StocktakeItemUpdateOne {
mutation := newStocktakeItemMutation(c.config, OpUpdateOne, withStocktakeItemID(id))
return &StocktakeItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for StocktakeItem.
func (c *StocktakeItemClient) Delete() *StocktakeItemDelete {
mutation := newStocktakeItemMutation(c.config, OpDelete)
return &StocktakeItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *StocktakeItemClient) DeleteOne(_m *StocktakeItem) *StocktakeItemDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *StocktakeItemClient) DeleteOneID(id int) *StocktakeItemDeleteOne {
builder := c.Delete().Where(stocktakeitem.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &StocktakeItemDeleteOne{builder}
}
// Query returns a query builder for StocktakeItem.
func (c *StocktakeItemClient) Query() *StocktakeItemQuery {
return &StocktakeItemQuery{
config: c.config,
ctx: &QueryContext{Type: TypeStocktakeItem},
inters: c.Interceptors(),
}
}
// Get returns a StocktakeItem entity by its id.
func (c *StocktakeItemClient) Get(ctx context.Context, id int) (*StocktakeItem, error) {
return c.Query().Where(stocktakeitem.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *StocktakeItemClient) GetX(ctx context.Context, id int) *StocktakeItem {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *StocktakeItemClient) Hooks() []Hook {
return c.hooks.StocktakeItem
}
// Interceptors returns the client interceptors.
func (c *StocktakeItemClient) Interceptors() []Interceptor {
return c.inters.StocktakeItem
}
func (c *StocktakeItemClient) mutate(ctx context.Context, m *StocktakeItemMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&StocktakeItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&StocktakeItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&StocktakeItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&StocktakeItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown StocktakeItem mutation op: %q", m.Op())
}
}
// StocktakeOrderClient is a client for the StocktakeOrder schema.
type StocktakeOrderClient struct {
config
}
// NewStocktakeOrderClient returns a client for the StocktakeOrder from the given config.
func NewStocktakeOrderClient(c config) *StocktakeOrderClient {
return &StocktakeOrderClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `stocktakeorder.Hooks(f(g(h())))`.
func (c *StocktakeOrderClient) Use(hooks ...Hook) {
c.hooks.StocktakeOrder = append(c.hooks.StocktakeOrder, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `stocktakeorder.Intercept(f(g(h())))`.
func (c *StocktakeOrderClient) Intercept(interceptors ...Interceptor) {
c.inters.StocktakeOrder = append(c.inters.StocktakeOrder, interceptors...)
}
// Create returns a builder for creating a StocktakeOrder entity.
func (c *StocktakeOrderClient) Create() *StocktakeOrderCreate {
mutation := newStocktakeOrderMutation(c.config, OpCreate)
return &StocktakeOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of StocktakeOrder entities.
func (c *StocktakeOrderClient) CreateBulk(builders ...*StocktakeOrderCreate) *StocktakeOrderCreateBulk {
return &StocktakeOrderCreateBulk{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 *StocktakeOrderClient) MapCreateBulk(slice any, setFunc func(*StocktakeOrderCreate, int)) *StocktakeOrderCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &StocktakeOrderCreateBulk{err: fmt.Errorf("calling to StocktakeOrderClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*StocktakeOrderCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &StocktakeOrderCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for StocktakeOrder.
func (c *StocktakeOrderClient) Update() *StocktakeOrderUpdate {
mutation := newStocktakeOrderMutation(c.config, OpUpdate)
return &StocktakeOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *StocktakeOrderClient) UpdateOne(_m *StocktakeOrder) *StocktakeOrderUpdateOne {
mutation := newStocktakeOrderMutation(c.config, OpUpdateOne, withStocktakeOrder(_m))
return &StocktakeOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *StocktakeOrderClient) UpdateOneID(id int) *StocktakeOrderUpdateOne {
mutation := newStocktakeOrderMutation(c.config, OpUpdateOne, withStocktakeOrderID(id))
return &StocktakeOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for StocktakeOrder.
func (c *StocktakeOrderClient) Delete() *StocktakeOrderDelete {
mutation := newStocktakeOrderMutation(c.config, OpDelete)
return &StocktakeOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *StocktakeOrderClient) DeleteOne(_m *StocktakeOrder) *StocktakeOrderDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *StocktakeOrderClient) DeleteOneID(id int) *StocktakeOrderDeleteOne {
builder := c.Delete().Where(stocktakeorder.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &StocktakeOrderDeleteOne{builder}
}
// Query returns a query builder for StocktakeOrder.
func (c *StocktakeOrderClient) Query() *StocktakeOrderQuery {
return &StocktakeOrderQuery{
config: c.config,
ctx: &QueryContext{Type: TypeStocktakeOrder},
inters: c.Interceptors(),
}
}
// Get returns a StocktakeOrder entity by its id.
func (c *StocktakeOrderClient) Get(ctx context.Context, id int) (*StocktakeOrder, error) {
return c.Query().Where(stocktakeorder.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *StocktakeOrderClient) GetX(ctx context.Context, id int) *StocktakeOrder {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *StocktakeOrderClient) Hooks() []Hook {
return c.hooks.StocktakeOrder
}
// Interceptors returns the client interceptors.
func (c *StocktakeOrderClient) Interceptors() []Interceptor {
return c.inters.StocktakeOrder
}
func (c *StocktakeOrderClient) mutate(ctx context.Context, m *StocktakeOrderMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&StocktakeOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&StocktakeOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&StocktakeOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&StocktakeOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown StocktakeOrder mutation op: %q", m.Op())
}
}
// UserClient is a client for the User schema.
type UserClient struct {
config
}
// NewUserClient returns a client for the User from the given config.
func NewUserClient(c config) *UserClient {
return &UserClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`.
func (c *UserClient) Use(hooks ...Hook) {
c.hooks.User = append(c.hooks.User, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
func (c *UserClient) Intercept(interceptors ...Interceptor) {
c.inters.User = append(c.inters.User, interceptors...)
}
// Create returns a builder for creating a User entity.
func (c *UserClient) Create() *UserCreate {
mutation := newUserMutation(c.config, OpCreate)
return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of User entities.
func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk {
return &UserCreateBulk{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 *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*UserCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &UserCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for User.
func (c *UserClient) Update() *UserUpdate {
mutation := newUserMutation(c.config, OpUpdate)
return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne {
mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m))
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *UserClient) UpdateOneID(id int) *UserUpdateOne {
mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id))
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for User.
func (c *UserClient) Delete() *UserDelete {
mutation := newUserMutation(c.config, OpDelete)
return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *UserClient) DeleteOneID(id int) *UserDeleteOne {
builder := c.Delete().Where(user.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &UserDeleteOne{builder}
}
// Query returns a query builder for User.
func (c *UserClient) Query() *UserQuery {
return &UserQuery{
config: c.config,
ctx: &QueryContext{Type: TypeUser},
inters: c.Interceptors(),
}
}
// Get returns a User entity by its id.
func (c *UserClient) Get(ctx context.Context, id int) (*User, error) {
return c.Query().Where(user.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *UserClient) GetX(ctx context.Context, id int) *User {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *UserClient) Hooks() []Hook {
return c.hooks.User
}
// Interceptors returns the client interceptors.
func (c *UserClient) Interceptors() []Interceptor {
return c.inters.User
}
func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
}
}
// ZoneClient is a client for the Zone schema.
type ZoneClient struct {
config
}
// NewZoneClient returns a client for the Zone from the given config.
func NewZoneClient(c config) *ZoneClient {
return &ZoneClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `zone.Hooks(f(g(h())))`.
func (c *ZoneClient) Use(hooks ...Hook) {
c.hooks.Zone = append(c.hooks.Zone, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `zone.Intercept(f(g(h())))`.
func (c *ZoneClient) Intercept(interceptors ...Interceptor) {
c.inters.Zone = append(c.inters.Zone, interceptors...)
}
// Create returns a builder for creating a Zone entity.
func (c *ZoneClient) Create() *ZoneCreate {
mutation := newZoneMutation(c.config, OpCreate)
return &ZoneCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of Zone entities.
func (c *ZoneClient) CreateBulk(builders ...*ZoneCreate) *ZoneCreateBulk {
return &ZoneCreateBulk{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 *ZoneClient) MapCreateBulk(slice any, setFunc func(*ZoneCreate, int)) *ZoneCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &ZoneCreateBulk{err: fmt.Errorf("calling to ZoneClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*ZoneCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &ZoneCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for Zone.
func (c *ZoneClient) Update() *ZoneUpdate {
mutation := newZoneMutation(c.config, OpUpdate)
return &ZoneUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *ZoneClient) UpdateOne(_m *Zone) *ZoneUpdateOne {
mutation := newZoneMutation(c.config, OpUpdateOne, withZone(_m))
return &ZoneUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *ZoneClient) UpdateOneID(id int) *ZoneUpdateOne {
mutation := newZoneMutation(c.config, OpUpdateOne, withZoneID(id))
return &ZoneUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for Zone.
func (c *ZoneClient) Delete() *ZoneDelete {
mutation := newZoneMutation(c.config, OpDelete)
return &ZoneDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *ZoneClient) DeleteOne(_m *Zone) *ZoneDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ZoneClient) DeleteOneID(id int) *ZoneDeleteOne {
builder := c.Delete().Where(zone.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &ZoneDeleteOne{builder}
}
// Query returns a query builder for Zone.
func (c *ZoneClient) Query() *ZoneQuery {
return &ZoneQuery{
config: c.config,
ctx: &QueryContext{Type: TypeZone},
inters: c.Interceptors(),
}
}
// Get returns a Zone entity by its id.
func (c *ZoneClient) Get(ctx context.Context, id int) (*Zone, error) {
return c.Query().Where(zone.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *ZoneClient) GetX(ctx context.Context, id int) *Zone {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *ZoneClient) Hooks() []Hook {
return c.hooks.Zone
}
// Interceptors returns the client interceptors.
func (c *ZoneClient) Interceptors() []Interceptor {
return c.inters.Zone
}
func (c *ZoneClient) mutate(ctx context.Context, m *ZoneMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ZoneCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ZoneUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ZoneUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ZoneDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Zone mutation op: %q", m.Op())
}
}
// hooks and interceptors per client, for fast access.
type (
hooks struct {
InboundDetail, InboundOrder, InspectionRecord, InventoryBatch, InventoryLock,
Material, OrderMaterialLedger, OutboundDetail, OutboundOrder, PackageBox,
SemiFinished, SerialNumber, StocktakeItem, StocktakeOrder, User,
Zone []ent.Hook
}
inters struct {
InboundDetail, InboundOrder, InspectionRecord, InventoryBatch, InventoryLock,
Material, OrderMaterialLedger, OutboundDetail, OutboundOrder, PackageBox,
SemiFinished, SerialNumber, StocktakeItem, StocktakeOrder, User,
Zone []ent.Interceptor
}
)