Files
bj_power/bj_power_wms/ent/inventory_create.go
T
SunYF 68f50ee46e refactor(wms): 合并库存表为统一inventory,重构业务逻辑
1. 合并inventory_batch与serial_number为统一inventory表,用manage_mode区分结构件批次/精密件SN
2. 移除冗余的material_type字段与相关逻辑
3. 重构库存查询、检验、入库出库等业务逻辑适配新表结构
4. 调整前端路由与菜单,拆分基础数据为区域维护和物料档案
5. 优化入库校验逻辑,避免空单问题
6. 调整Vite构建配置,关闭自动清空输出目录
7. 为各模块添加详细中文注释,统一业务术语
8. 生成并更新Ent自动代码文件
2026-09-02 08:21:11 +08:00

1628 lines
47 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/inventory"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// InventoryCreate is the builder for creating a Inventory entity.
type InventoryCreate struct {
config
mutation *InventoryMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetManageMode sets the "manage_mode" field.
func (_c *InventoryCreate) SetManageMode(v int) *InventoryCreate {
_c.mutation.SetManageMode(v)
return _c
}
// SetMaterialCode sets the "material_code" field.
func (_c *InventoryCreate) SetMaterialCode(v string) *InventoryCreate {
_c.mutation.SetMaterialCode(v)
return _c
}
// SetMaterialName sets the "material_name" field.
func (_c *InventoryCreate) SetMaterialName(v string) *InventoryCreate {
_c.mutation.SetMaterialName(v)
return _c
}
// SetNillableMaterialName sets the "material_name" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableMaterialName(v *string) *InventoryCreate {
if v != nil {
_c.SetMaterialName(*v)
}
return _c
}
// SetBatchNo sets the "batch_no" field.
func (_c *InventoryCreate) SetBatchNo(v string) *InventoryCreate {
_c.mutation.SetBatchNo(v)
return _c
}
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableBatchNo(v *string) *InventoryCreate {
if v != nil {
_c.SetBatchNo(*v)
}
return _c
}
// SetSnCode sets the "sn_code" field.
func (_c *InventoryCreate) SetSnCode(v string) *InventoryCreate {
_c.mutation.SetSnCode(v)
return _c
}
// SetNillableSnCode sets the "sn_code" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableSnCode(v *string) *InventoryCreate {
if v != nil {
_c.SetSnCode(*v)
}
return _c
}
// SetQuantity sets the "quantity" field.
func (_c *InventoryCreate) SetQuantity(v int) *InventoryCreate {
_c.mutation.SetQuantity(v)
return _c
}
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableQuantity(v *int) *InventoryCreate {
if v != nil {
_c.SetQuantity(*v)
}
return _c
}
// SetLockedQty sets the "locked_qty" field.
func (_c *InventoryCreate) SetLockedQty(v int) *InventoryCreate {
_c.mutation.SetLockedQty(v)
return _c
}
// SetNillableLockedQty sets the "locked_qty" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableLockedQty(v *int) *InventoryCreate {
if v != nil {
_c.SetLockedQty(*v)
}
return _c
}
// SetQualityStatus sets the "quality_status" field.
func (_c *InventoryCreate) SetQualityStatus(v string) *InventoryCreate {
_c.mutation.SetQualityStatus(v)
return _c
}
// SetNillableQualityStatus sets the "quality_status" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableQualityStatus(v *string) *InventoryCreate {
if v != nil {
_c.SetQualityStatus(*v)
}
return _c
}
// SetZoneCode sets the "zone_code" field.
func (_c *InventoryCreate) SetZoneCode(v string) *InventoryCreate {
_c.mutation.SetZoneCode(v)
return _c
}
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableZoneCode(v *string) *InventoryCreate {
if v != nil {
_c.SetZoneCode(*v)
}
return _c
}
// SetStatus sets the "status" field.
func (_c *InventoryCreate) SetStatus(v string) *InventoryCreate {
_c.mutation.SetStatus(v)
return _c
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableStatus(v *string) *InventoryCreate {
if v != nil {
_c.SetStatus(*v)
}
return _c
}
// SetProductionDate sets the "production_date" field.
func (_c *InventoryCreate) SetProductionDate(v string) *InventoryCreate {
_c.mutation.SetProductionDate(v)
return _c
}
// SetNillableProductionDate sets the "production_date" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableProductionDate(v *string) *InventoryCreate {
if v != nil {
_c.SetProductionDate(*v)
}
return _c
}
// SetSupplier sets the "supplier" field.
func (_c *InventoryCreate) SetSupplier(v string) *InventoryCreate {
_c.mutation.SetSupplier(v)
return _c
}
// SetNillableSupplier sets the "supplier" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableSupplier(v *string) *InventoryCreate {
if v != nil {
_c.SetSupplier(*v)
}
return _c
}
// SetInboundNo sets the "inbound_no" field.
func (_c *InventoryCreate) SetInboundNo(v string) *InventoryCreate {
_c.mutation.SetInboundNo(v)
return _c
}
// SetNillableInboundNo sets the "inbound_no" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableInboundNo(v *string) *InventoryCreate {
if v != nil {
_c.SetInboundNo(*v)
}
return _c
}
// SetRemark sets the "remark" field.
func (_c *InventoryCreate) SetRemark(v string) *InventoryCreate {
_c.mutation.SetRemark(v)
return _c
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableRemark(v *string) *InventoryCreate {
if v != nil {
_c.SetRemark(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *InventoryCreate) SetCreatedAt(v int64) *InventoryCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableCreatedAt(v *int64) *InventoryCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *InventoryCreate) SetUpdatedAt(v int64) *InventoryCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *InventoryCreate) SetNillableUpdatedAt(v *int64) *InventoryCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// Mutation returns the InventoryMutation object of the builder.
func (_c *InventoryCreate) Mutation() *InventoryMutation {
return _c.mutation
}
// Save creates the Inventory in the database.
func (_c *InventoryCreate) Save(ctx context.Context) (*Inventory, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *InventoryCreate) SaveX(ctx context.Context) *Inventory {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *InventoryCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *InventoryCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *InventoryCreate) defaults() {
if _, ok := _c.mutation.Quantity(); !ok {
v := inventory.DefaultQuantity
_c.mutation.SetQuantity(v)
}
if _, ok := _c.mutation.LockedQty(); !ok {
v := inventory.DefaultLockedQty
_c.mutation.SetLockedQty(v)
}
if _, ok := _c.mutation.QualityStatus(); !ok {
v := inventory.DefaultQualityStatus
_c.mutation.SetQualityStatus(v)
}
if _, ok := _c.mutation.Status(); !ok {
v := inventory.DefaultStatus
_c.mutation.SetStatus(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := inventory.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := inventory.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *InventoryCreate) check() error {
if _, ok := _c.mutation.ManageMode(); !ok {
return &ValidationError{Name: "manage_mode", err: errors.New(`ent: missing required field "Inventory.manage_mode"`)}
}
if _, ok := _c.mutation.MaterialCode(); !ok {
return &ValidationError{Name: "material_code", err: errors.New(`ent: missing required field "Inventory.material_code"`)}
}
if _, ok := _c.mutation.Quantity(); !ok {
return &ValidationError{Name: "quantity", err: errors.New(`ent: missing required field "Inventory.quantity"`)}
}
if _, ok := _c.mutation.LockedQty(); !ok {
return &ValidationError{Name: "locked_qty", err: errors.New(`ent: missing required field "Inventory.locked_qty"`)}
}
if _, ok := _c.mutation.QualityStatus(); !ok {
return &ValidationError{Name: "quality_status", err: errors.New(`ent: missing required field "Inventory.quality_status"`)}
}
if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Inventory.status"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Inventory.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Inventory.updated_at"`)}
}
return nil
}
func (_c *InventoryCreate) sqlSave(ctx context.Context) (*Inventory, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *InventoryCreate) createSpec() (*Inventory, *sqlgraph.CreateSpec) {
var (
_node = &Inventory{config: _c.config}
_spec = sqlgraph.NewCreateSpec(inventory.Table, sqlgraph.NewFieldSpec(inventory.FieldID, field.TypeInt))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.ManageMode(); ok {
_spec.SetField(inventory.FieldManageMode, field.TypeInt, value)
_node.ManageMode = value
}
if value, ok := _c.mutation.MaterialCode(); ok {
_spec.SetField(inventory.FieldMaterialCode, field.TypeString, value)
_node.MaterialCode = value
}
if value, ok := _c.mutation.MaterialName(); ok {
_spec.SetField(inventory.FieldMaterialName, field.TypeString, value)
_node.MaterialName = value
}
if value, ok := _c.mutation.BatchNo(); ok {
_spec.SetField(inventory.FieldBatchNo, field.TypeString, value)
_node.BatchNo = value
}
if value, ok := _c.mutation.SnCode(); ok {
_spec.SetField(inventory.FieldSnCode, field.TypeString, value)
_node.SnCode = value
}
if value, ok := _c.mutation.Quantity(); ok {
_spec.SetField(inventory.FieldQuantity, field.TypeInt, value)
_node.Quantity = value
}
if value, ok := _c.mutation.LockedQty(); ok {
_spec.SetField(inventory.FieldLockedQty, field.TypeInt, value)
_node.LockedQty = value
}
if value, ok := _c.mutation.QualityStatus(); ok {
_spec.SetField(inventory.FieldQualityStatus, field.TypeString, value)
_node.QualityStatus = value
}
if value, ok := _c.mutation.ZoneCode(); ok {
_spec.SetField(inventory.FieldZoneCode, field.TypeString, value)
_node.ZoneCode = value
}
if value, ok := _c.mutation.Status(); ok {
_spec.SetField(inventory.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.ProductionDate(); ok {
_spec.SetField(inventory.FieldProductionDate, field.TypeString, value)
_node.ProductionDate = value
}
if value, ok := _c.mutation.Supplier(); ok {
_spec.SetField(inventory.FieldSupplier, field.TypeString, value)
_node.Supplier = value
}
if value, ok := _c.mutation.InboundNo(); ok {
_spec.SetField(inventory.FieldInboundNo, field.TypeString, value)
_node.InboundNo = value
}
if value, ok := _c.mutation.Remark(); ok {
_spec.SetField(inventory.FieldRemark, field.TypeString, value)
_node.Remark = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(inventory.FieldCreatedAt, field.TypeInt64, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(inventory.FieldUpdatedAt, field.TypeInt64, value)
_node.UpdatedAt = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.Inventory.Create().
// SetManageMode(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.InventoryUpsert) {
// SetManageMode(v+v).
// }).
// Exec(ctx)
func (_c *InventoryCreate) OnConflict(opts ...sql.ConflictOption) *InventoryUpsertOne {
_c.conflict = opts
return &InventoryUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *InventoryCreate) OnConflictColumns(columns ...string) *InventoryUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &InventoryUpsertOne{
create: _c,
}
}
type (
// InventoryUpsertOne is the builder for "upsert"-ing
// one Inventory node.
InventoryUpsertOne struct {
create *InventoryCreate
}
// InventoryUpsert is the "OnConflict" setter.
InventoryUpsert struct {
*sql.UpdateSet
}
)
// SetManageMode sets the "manage_mode" field.
func (u *InventoryUpsert) SetManageMode(v int) *InventoryUpsert {
u.Set(inventory.FieldManageMode, v)
return u
}
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateManageMode() *InventoryUpsert {
u.SetExcluded(inventory.FieldManageMode)
return u
}
// AddManageMode adds v to the "manage_mode" field.
func (u *InventoryUpsert) AddManageMode(v int) *InventoryUpsert {
u.Add(inventory.FieldManageMode, v)
return u
}
// SetMaterialCode sets the "material_code" field.
func (u *InventoryUpsert) SetMaterialCode(v string) *InventoryUpsert {
u.Set(inventory.FieldMaterialCode, v)
return u
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateMaterialCode() *InventoryUpsert {
u.SetExcluded(inventory.FieldMaterialCode)
return u
}
// SetMaterialName sets the "material_name" field.
func (u *InventoryUpsert) SetMaterialName(v string) *InventoryUpsert {
u.Set(inventory.FieldMaterialName, v)
return u
}
// UpdateMaterialName sets the "material_name" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateMaterialName() *InventoryUpsert {
u.SetExcluded(inventory.FieldMaterialName)
return u
}
// ClearMaterialName clears the value of the "material_name" field.
func (u *InventoryUpsert) ClearMaterialName() *InventoryUpsert {
u.SetNull(inventory.FieldMaterialName)
return u
}
// SetBatchNo sets the "batch_no" field.
func (u *InventoryUpsert) SetBatchNo(v string) *InventoryUpsert {
u.Set(inventory.FieldBatchNo, v)
return u
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateBatchNo() *InventoryUpsert {
u.SetExcluded(inventory.FieldBatchNo)
return u
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *InventoryUpsert) ClearBatchNo() *InventoryUpsert {
u.SetNull(inventory.FieldBatchNo)
return u
}
// SetSnCode sets the "sn_code" field.
func (u *InventoryUpsert) SetSnCode(v string) *InventoryUpsert {
u.Set(inventory.FieldSnCode, v)
return u
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateSnCode() *InventoryUpsert {
u.SetExcluded(inventory.FieldSnCode)
return u
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *InventoryUpsert) ClearSnCode() *InventoryUpsert {
u.SetNull(inventory.FieldSnCode)
return u
}
// SetQuantity sets the "quantity" field.
func (u *InventoryUpsert) SetQuantity(v int) *InventoryUpsert {
u.Set(inventory.FieldQuantity, v)
return u
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateQuantity() *InventoryUpsert {
u.SetExcluded(inventory.FieldQuantity)
return u
}
// AddQuantity adds v to the "quantity" field.
func (u *InventoryUpsert) AddQuantity(v int) *InventoryUpsert {
u.Add(inventory.FieldQuantity, v)
return u
}
// SetLockedQty sets the "locked_qty" field.
func (u *InventoryUpsert) SetLockedQty(v int) *InventoryUpsert {
u.Set(inventory.FieldLockedQty, v)
return u
}
// UpdateLockedQty sets the "locked_qty" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateLockedQty() *InventoryUpsert {
u.SetExcluded(inventory.FieldLockedQty)
return u
}
// AddLockedQty adds v to the "locked_qty" field.
func (u *InventoryUpsert) AddLockedQty(v int) *InventoryUpsert {
u.Add(inventory.FieldLockedQty, v)
return u
}
// SetQualityStatus sets the "quality_status" field.
func (u *InventoryUpsert) SetQualityStatus(v string) *InventoryUpsert {
u.Set(inventory.FieldQualityStatus, v)
return u
}
// UpdateQualityStatus sets the "quality_status" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateQualityStatus() *InventoryUpsert {
u.SetExcluded(inventory.FieldQualityStatus)
return u
}
// SetZoneCode sets the "zone_code" field.
func (u *InventoryUpsert) SetZoneCode(v string) *InventoryUpsert {
u.Set(inventory.FieldZoneCode, v)
return u
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateZoneCode() *InventoryUpsert {
u.SetExcluded(inventory.FieldZoneCode)
return u
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *InventoryUpsert) ClearZoneCode() *InventoryUpsert {
u.SetNull(inventory.FieldZoneCode)
return u
}
// SetStatus sets the "status" field.
func (u *InventoryUpsert) SetStatus(v string) *InventoryUpsert {
u.Set(inventory.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateStatus() *InventoryUpsert {
u.SetExcluded(inventory.FieldStatus)
return u
}
// SetProductionDate sets the "production_date" field.
func (u *InventoryUpsert) SetProductionDate(v string) *InventoryUpsert {
u.Set(inventory.FieldProductionDate, v)
return u
}
// UpdateProductionDate sets the "production_date" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateProductionDate() *InventoryUpsert {
u.SetExcluded(inventory.FieldProductionDate)
return u
}
// ClearProductionDate clears the value of the "production_date" field.
func (u *InventoryUpsert) ClearProductionDate() *InventoryUpsert {
u.SetNull(inventory.FieldProductionDate)
return u
}
// SetSupplier sets the "supplier" field.
func (u *InventoryUpsert) SetSupplier(v string) *InventoryUpsert {
u.Set(inventory.FieldSupplier, v)
return u
}
// UpdateSupplier sets the "supplier" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateSupplier() *InventoryUpsert {
u.SetExcluded(inventory.FieldSupplier)
return u
}
// ClearSupplier clears the value of the "supplier" field.
func (u *InventoryUpsert) ClearSupplier() *InventoryUpsert {
u.SetNull(inventory.FieldSupplier)
return u
}
// SetInboundNo sets the "inbound_no" field.
func (u *InventoryUpsert) SetInboundNo(v string) *InventoryUpsert {
u.Set(inventory.FieldInboundNo, v)
return u
}
// UpdateInboundNo sets the "inbound_no" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateInboundNo() *InventoryUpsert {
u.SetExcluded(inventory.FieldInboundNo)
return u
}
// ClearInboundNo clears the value of the "inbound_no" field.
func (u *InventoryUpsert) ClearInboundNo() *InventoryUpsert {
u.SetNull(inventory.FieldInboundNo)
return u
}
// SetRemark sets the "remark" field.
func (u *InventoryUpsert) SetRemark(v string) *InventoryUpsert {
u.Set(inventory.FieldRemark, v)
return u
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateRemark() *InventoryUpsert {
u.SetExcluded(inventory.FieldRemark)
return u
}
// ClearRemark clears the value of the "remark" field.
func (u *InventoryUpsert) ClearRemark() *InventoryUpsert {
u.SetNull(inventory.FieldRemark)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *InventoryUpsert) SetCreatedAt(v int64) *InventoryUpsert {
u.Set(inventory.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateCreatedAt() *InventoryUpsert {
u.SetExcluded(inventory.FieldCreatedAt)
return u
}
// AddCreatedAt adds v to the "created_at" field.
func (u *InventoryUpsert) AddCreatedAt(v int64) *InventoryUpsert {
u.Add(inventory.FieldCreatedAt, v)
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *InventoryUpsert) SetUpdatedAt(v int64) *InventoryUpsert {
u.Set(inventory.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InventoryUpsert) UpdateUpdatedAt() *InventoryUpsert {
u.SetExcluded(inventory.FieldUpdatedAt)
return u
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *InventoryUpsert) AddUpdatedAt(v int64) *InventoryUpsert {
u.Add(inventory.FieldUpdatedAt, v)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *InventoryUpsertOne) UpdateNewValues() *InventoryUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *InventoryUpsertOne) Ignore() *InventoryUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *InventoryUpsertOne) DoNothing() *InventoryUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the InventoryCreate.OnConflict
// documentation for more info.
func (u *InventoryUpsertOne) Update(set func(*InventoryUpsert)) *InventoryUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&InventoryUpsert{UpdateSet: update})
}))
return u
}
// SetManageMode sets the "manage_mode" field.
func (u *InventoryUpsertOne) SetManageMode(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetManageMode(v)
})
}
// AddManageMode adds v to the "manage_mode" field.
func (u *InventoryUpsertOne) AddManageMode(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.AddManageMode(v)
})
}
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateManageMode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateManageMode()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *InventoryUpsertOne) SetMaterialCode(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateMaterialCode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateMaterialCode()
})
}
// SetMaterialName sets the "material_name" field.
func (u *InventoryUpsertOne) SetMaterialName(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetMaterialName(v)
})
}
// UpdateMaterialName sets the "material_name" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateMaterialName() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateMaterialName()
})
}
// ClearMaterialName clears the value of the "material_name" field.
func (u *InventoryUpsertOne) ClearMaterialName() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearMaterialName()
})
}
// SetBatchNo sets the "batch_no" field.
func (u *InventoryUpsertOne) SetBatchNo(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetBatchNo(v)
})
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateBatchNo() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateBatchNo()
})
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *InventoryUpsertOne) ClearBatchNo() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearBatchNo()
})
}
// SetSnCode sets the "sn_code" field.
func (u *InventoryUpsertOne) SetSnCode(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetSnCode(v)
})
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateSnCode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateSnCode()
})
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *InventoryUpsertOne) ClearSnCode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearSnCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *InventoryUpsertOne) SetQuantity(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *InventoryUpsertOne) AddQuantity(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateQuantity() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateQuantity()
})
}
// SetLockedQty sets the "locked_qty" field.
func (u *InventoryUpsertOne) SetLockedQty(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetLockedQty(v)
})
}
// AddLockedQty adds v to the "locked_qty" field.
func (u *InventoryUpsertOne) AddLockedQty(v int) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.AddLockedQty(v)
})
}
// UpdateLockedQty sets the "locked_qty" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateLockedQty() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateLockedQty()
})
}
// SetQualityStatus sets the "quality_status" field.
func (u *InventoryUpsertOne) SetQualityStatus(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetQualityStatus(v)
})
}
// UpdateQualityStatus sets the "quality_status" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateQualityStatus() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateQualityStatus()
})
}
// SetZoneCode sets the "zone_code" field.
func (u *InventoryUpsertOne) SetZoneCode(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetZoneCode(v)
})
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateZoneCode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateZoneCode()
})
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *InventoryUpsertOne) ClearZoneCode() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearZoneCode()
})
}
// SetStatus sets the "status" field.
func (u *InventoryUpsertOne) SetStatus(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateStatus() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateStatus()
})
}
// SetProductionDate sets the "production_date" field.
func (u *InventoryUpsertOne) SetProductionDate(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetProductionDate(v)
})
}
// UpdateProductionDate sets the "production_date" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateProductionDate() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateProductionDate()
})
}
// ClearProductionDate clears the value of the "production_date" field.
func (u *InventoryUpsertOne) ClearProductionDate() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearProductionDate()
})
}
// SetSupplier sets the "supplier" field.
func (u *InventoryUpsertOne) SetSupplier(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetSupplier(v)
})
}
// UpdateSupplier sets the "supplier" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateSupplier() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateSupplier()
})
}
// ClearSupplier clears the value of the "supplier" field.
func (u *InventoryUpsertOne) ClearSupplier() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearSupplier()
})
}
// SetInboundNo sets the "inbound_no" field.
func (u *InventoryUpsertOne) SetInboundNo(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetInboundNo(v)
})
}
// UpdateInboundNo sets the "inbound_no" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateInboundNo() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateInboundNo()
})
}
// ClearInboundNo clears the value of the "inbound_no" field.
func (u *InventoryUpsertOne) ClearInboundNo() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearInboundNo()
})
}
// SetRemark sets the "remark" field.
func (u *InventoryUpsertOne) SetRemark(v string) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateRemark() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *InventoryUpsertOne) ClearRemark() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *InventoryUpsertOne) SetCreatedAt(v int64) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *InventoryUpsertOne) AddCreatedAt(v int64) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateCreatedAt() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *InventoryUpsertOne) SetUpdatedAt(v int64) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.SetUpdatedAt(v)
})
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *InventoryUpsertOne) AddUpdatedAt(v int64) *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.AddUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InventoryUpsertOne) UpdateUpdatedAt() *InventoryUpsertOne {
return u.Update(func(s *InventoryUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *InventoryUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for InventoryCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *InventoryUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *InventoryUpsertOne) ID(ctx context.Context) (id int, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *InventoryUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// InventoryCreateBulk is the builder for creating many Inventory entities in bulk.
type InventoryCreateBulk struct {
config
err error
builders []*InventoryCreate
conflict []sql.ConflictOption
}
// Save creates the Inventory entities in the database.
func (_c *InventoryCreateBulk) Save(ctx context.Context) ([]*Inventory, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Inventory, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*InventoryMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *InventoryCreateBulk) SaveX(ctx context.Context) []*Inventory {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *InventoryCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *InventoryCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.Inventory.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.InventoryUpsert) {
// SetManageMode(v+v).
// }).
// Exec(ctx)
func (_c *InventoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *InventoryUpsertBulk {
_c.conflict = opts
return &InventoryUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *InventoryCreateBulk) OnConflictColumns(columns ...string) *InventoryUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &InventoryUpsertBulk{
create: _c,
}
}
// InventoryUpsertBulk is the builder for "upsert"-ing
// a bulk of Inventory nodes.
type InventoryUpsertBulk struct {
create *InventoryCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *InventoryUpsertBulk) UpdateNewValues() *InventoryUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Inventory.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *InventoryUpsertBulk) Ignore() *InventoryUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *InventoryUpsertBulk) DoNothing() *InventoryUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the InventoryCreateBulk.OnConflict
// documentation for more info.
func (u *InventoryUpsertBulk) Update(set func(*InventoryUpsert)) *InventoryUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&InventoryUpsert{UpdateSet: update})
}))
return u
}
// SetManageMode sets the "manage_mode" field.
func (u *InventoryUpsertBulk) SetManageMode(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetManageMode(v)
})
}
// AddManageMode adds v to the "manage_mode" field.
func (u *InventoryUpsertBulk) AddManageMode(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.AddManageMode(v)
})
}
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateManageMode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateManageMode()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *InventoryUpsertBulk) SetMaterialCode(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateMaterialCode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateMaterialCode()
})
}
// SetMaterialName sets the "material_name" field.
func (u *InventoryUpsertBulk) SetMaterialName(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetMaterialName(v)
})
}
// UpdateMaterialName sets the "material_name" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateMaterialName() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateMaterialName()
})
}
// ClearMaterialName clears the value of the "material_name" field.
func (u *InventoryUpsertBulk) ClearMaterialName() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearMaterialName()
})
}
// SetBatchNo sets the "batch_no" field.
func (u *InventoryUpsertBulk) SetBatchNo(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetBatchNo(v)
})
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateBatchNo() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateBatchNo()
})
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *InventoryUpsertBulk) ClearBatchNo() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearBatchNo()
})
}
// SetSnCode sets the "sn_code" field.
func (u *InventoryUpsertBulk) SetSnCode(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetSnCode(v)
})
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateSnCode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateSnCode()
})
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *InventoryUpsertBulk) ClearSnCode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearSnCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *InventoryUpsertBulk) SetQuantity(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *InventoryUpsertBulk) AddQuantity(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateQuantity() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateQuantity()
})
}
// SetLockedQty sets the "locked_qty" field.
func (u *InventoryUpsertBulk) SetLockedQty(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetLockedQty(v)
})
}
// AddLockedQty adds v to the "locked_qty" field.
func (u *InventoryUpsertBulk) AddLockedQty(v int) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.AddLockedQty(v)
})
}
// UpdateLockedQty sets the "locked_qty" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateLockedQty() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateLockedQty()
})
}
// SetQualityStatus sets the "quality_status" field.
func (u *InventoryUpsertBulk) SetQualityStatus(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetQualityStatus(v)
})
}
// UpdateQualityStatus sets the "quality_status" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateQualityStatus() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateQualityStatus()
})
}
// SetZoneCode sets the "zone_code" field.
func (u *InventoryUpsertBulk) SetZoneCode(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetZoneCode(v)
})
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateZoneCode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateZoneCode()
})
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *InventoryUpsertBulk) ClearZoneCode() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearZoneCode()
})
}
// SetStatus sets the "status" field.
func (u *InventoryUpsertBulk) SetStatus(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateStatus() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateStatus()
})
}
// SetProductionDate sets the "production_date" field.
func (u *InventoryUpsertBulk) SetProductionDate(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetProductionDate(v)
})
}
// UpdateProductionDate sets the "production_date" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateProductionDate() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateProductionDate()
})
}
// ClearProductionDate clears the value of the "production_date" field.
func (u *InventoryUpsertBulk) ClearProductionDate() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearProductionDate()
})
}
// SetSupplier sets the "supplier" field.
func (u *InventoryUpsertBulk) SetSupplier(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetSupplier(v)
})
}
// UpdateSupplier sets the "supplier" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateSupplier() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateSupplier()
})
}
// ClearSupplier clears the value of the "supplier" field.
func (u *InventoryUpsertBulk) ClearSupplier() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearSupplier()
})
}
// SetInboundNo sets the "inbound_no" field.
func (u *InventoryUpsertBulk) SetInboundNo(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetInboundNo(v)
})
}
// UpdateInboundNo sets the "inbound_no" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateInboundNo() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateInboundNo()
})
}
// ClearInboundNo clears the value of the "inbound_no" field.
func (u *InventoryUpsertBulk) ClearInboundNo() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearInboundNo()
})
}
// SetRemark sets the "remark" field.
func (u *InventoryUpsertBulk) SetRemark(v string) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateRemark() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *InventoryUpsertBulk) ClearRemark() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *InventoryUpsertBulk) SetCreatedAt(v int64) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *InventoryUpsertBulk) AddCreatedAt(v int64) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateCreatedAt() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *InventoryUpsertBulk) SetUpdatedAt(v int64) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.SetUpdatedAt(v)
})
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *InventoryUpsertBulk) AddUpdatedAt(v int64) *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.AddUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *InventoryUpsertBulk) UpdateUpdatedAt() *InventoryUpsertBulk {
return u.Update(func(s *InventoryUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *InventoryUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the InventoryCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for InventoryCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *InventoryUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}