- 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
1128 lines
34 KiB
Go
1128 lines
34 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/stocktakeitem"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// StocktakeItemCreate is the builder for creating a StocktakeItem entity.
|
|
type StocktakeItemCreate struct {
|
|
config
|
|
mutation *StocktakeItemMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (_c *StocktakeItemCreate) SetStocktakeNo(v string) *StocktakeItemCreate {
|
|
_c.mutation.SetStocktakeNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (_c *StocktakeItemCreate) SetTargetType(v string) *StocktakeItemCreate {
|
|
_c.mutation.SetTargetType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (_c *StocktakeItemCreate) SetTargetID(v string) *StocktakeItemCreate {
|
|
_c.mutation.SetTargetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_c *StocktakeItemCreate) SetMaterialCode(v string) *StocktakeItemCreate {
|
|
_c.mutation.SetMaterialCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableMaterialCode(v *string) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetMaterialCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_c *StocktakeItemCreate) SetZoneCode(v string) *StocktakeItemCreate {
|
|
_c.mutation.SetZoneCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableZoneCode(v *string) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetZoneCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (_c *StocktakeItemCreate) SetBookQty(v int) *StocktakeItemCreate {
|
|
_c.mutation.SetBookQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableBookQty sets the "book_qty" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableBookQty(v *int) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetBookQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (_c *StocktakeItemCreate) SetScannedQty(v int) *StocktakeItemCreate {
|
|
_c.mutation.SetScannedQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableScannedQty sets the "scanned_qty" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableScannedQty(v *int) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetScannedQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (_c *StocktakeItemCreate) SetDiffQty(v int) *StocktakeItemCreate {
|
|
_c.mutation.SetDiffQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDiffQty sets the "diff_qty" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableDiffQty(v *int) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetDiffQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (_c *StocktakeItemCreate) SetCounted(v bool) *StocktakeItemCreate {
|
|
_c.mutation.SetCounted(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCounted sets the "counted" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableCounted(v *bool) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetCounted(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *StocktakeItemCreate) SetUpdatedAt(v int64) *StocktakeItemCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *StocktakeItemCreate) SetNillableUpdatedAt(v *int64) *StocktakeItemCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the StocktakeItemMutation object of the builder.
|
|
func (_c *StocktakeItemCreate) Mutation() *StocktakeItemMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the StocktakeItem in the database.
|
|
func (_c *StocktakeItemCreate) Save(ctx context.Context) (*StocktakeItem, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *StocktakeItemCreate) SaveX(ctx context.Context) *StocktakeItem {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *StocktakeItemCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *StocktakeItemCreate) 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 *StocktakeItemCreate) defaults() {
|
|
if _, ok := _c.mutation.BookQty(); !ok {
|
|
v := stocktakeitem.DefaultBookQty
|
|
_c.mutation.SetBookQty(v)
|
|
}
|
|
if _, ok := _c.mutation.ScannedQty(); !ok {
|
|
v := stocktakeitem.DefaultScannedQty
|
|
_c.mutation.SetScannedQty(v)
|
|
}
|
|
if _, ok := _c.mutation.DiffQty(); !ok {
|
|
v := stocktakeitem.DefaultDiffQty
|
|
_c.mutation.SetDiffQty(v)
|
|
}
|
|
if _, ok := _c.mutation.Counted(); !ok {
|
|
v := stocktakeitem.DefaultCounted
|
|
_c.mutation.SetCounted(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := stocktakeitem.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *StocktakeItemCreate) check() error {
|
|
if _, ok := _c.mutation.StocktakeNo(); !ok {
|
|
return &ValidationError{Name: "stocktake_no", err: errors.New(`ent: missing required field "StocktakeItem.stocktake_no"`)}
|
|
}
|
|
if _, ok := _c.mutation.TargetType(); !ok {
|
|
return &ValidationError{Name: "target_type", err: errors.New(`ent: missing required field "StocktakeItem.target_type"`)}
|
|
}
|
|
if _, ok := _c.mutation.TargetID(); !ok {
|
|
return &ValidationError{Name: "target_id", err: errors.New(`ent: missing required field "StocktakeItem.target_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.BookQty(); !ok {
|
|
return &ValidationError{Name: "book_qty", err: errors.New(`ent: missing required field "StocktakeItem.book_qty"`)}
|
|
}
|
|
if _, ok := _c.mutation.ScannedQty(); !ok {
|
|
return &ValidationError{Name: "scanned_qty", err: errors.New(`ent: missing required field "StocktakeItem.scanned_qty"`)}
|
|
}
|
|
if _, ok := _c.mutation.DiffQty(); !ok {
|
|
return &ValidationError{Name: "diff_qty", err: errors.New(`ent: missing required field "StocktakeItem.diff_qty"`)}
|
|
}
|
|
if _, ok := _c.mutation.Counted(); !ok {
|
|
return &ValidationError{Name: "counted", err: errors.New(`ent: missing required field "StocktakeItem.counted"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "StocktakeItem.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *StocktakeItemCreate) sqlSave(ctx context.Context) (*StocktakeItem, 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 *StocktakeItemCreate) createSpec() (*StocktakeItem, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &StocktakeItem{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(stocktakeitem.Table, sqlgraph.NewFieldSpec(stocktakeitem.FieldID, field.TypeInt))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.StocktakeNo(); ok {
|
|
_spec.SetField(stocktakeitem.FieldStocktakeNo, field.TypeString, value)
|
|
_node.StocktakeNo = value
|
|
}
|
|
if value, ok := _c.mutation.TargetType(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetType, field.TypeString, value)
|
|
_node.TargetType = value
|
|
}
|
|
if value, ok := _c.mutation.TargetID(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetID, field.TypeString, value)
|
|
_node.TargetID = value
|
|
}
|
|
if value, ok := _c.mutation.MaterialCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldMaterialCode, field.TypeString, value)
|
|
_node.MaterialCode = value
|
|
}
|
|
if value, ok := _c.mutation.ZoneCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldZoneCode, field.TypeString, value)
|
|
_node.ZoneCode = value
|
|
}
|
|
if value, ok := _c.mutation.BookQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldBookQty, field.TypeInt, value)
|
|
_node.BookQty = value
|
|
}
|
|
if value, ok := _c.mutation.ScannedQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldScannedQty, field.TypeInt, value)
|
|
_node.ScannedQty = value
|
|
}
|
|
if value, ok := _c.mutation.DiffQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldDiffQty, field.TypeInt, value)
|
|
_node.DiffQty = value
|
|
}
|
|
if value, ok := _c.mutation.Counted(); ok {
|
|
_spec.SetField(stocktakeitem.FieldCounted, field.TypeBool, value)
|
|
_node.Counted = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(stocktakeitem.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.StocktakeItem.Create().
|
|
// SetStocktakeNo(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.StocktakeItemUpsert) {
|
|
// SetStocktakeNo(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *StocktakeItemCreate) OnConflict(opts ...sql.ConflictOption) *StocktakeItemUpsertOne {
|
|
_c.conflict = opts
|
|
return &StocktakeItemUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.StocktakeItem.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *StocktakeItemCreate) OnConflictColumns(columns ...string) *StocktakeItemUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &StocktakeItemUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// StocktakeItemUpsertOne is the builder for "upsert"-ing
|
|
// one StocktakeItem node.
|
|
StocktakeItemUpsertOne struct {
|
|
create *StocktakeItemCreate
|
|
}
|
|
|
|
// StocktakeItemUpsert is the "OnConflict" setter.
|
|
StocktakeItemUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (u *StocktakeItemUpsert) SetStocktakeNo(v string) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldStocktakeNo, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStocktakeNo sets the "stocktake_no" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateStocktakeNo() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldStocktakeNo)
|
|
return u
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (u *StocktakeItemUpsert) SetTargetType(v string) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldTargetType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTargetType sets the "target_type" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateTargetType() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldTargetType)
|
|
return u
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (u *StocktakeItemUpsert) SetTargetID(v string) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldTargetID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTargetID sets the "target_id" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateTargetID() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldTargetID)
|
|
return u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (u *StocktakeItemUpsert) SetMaterialCode(v string) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldMaterialCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateMaterialCode() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldMaterialCode)
|
|
return u
|
|
}
|
|
|
|
// ClearMaterialCode clears the value of the "material_code" field.
|
|
func (u *StocktakeItemUpsert) ClearMaterialCode() *StocktakeItemUpsert {
|
|
u.SetNull(stocktakeitem.FieldMaterialCode)
|
|
return u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (u *StocktakeItemUpsert) SetZoneCode(v string) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldZoneCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateZoneCode() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldZoneCode)
|
|
return u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (u *StocktakeItemUpsert) ClearZoneCode() *StocktakeItemUpsert {
|
|
u.SetNull(stocktakeitem.FieldZoneCode)
|
|
return u
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (u *StocktakeItemUpsert) SetBookQty(v int) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldBookQty, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateBookQty sets the "book_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateBookQty() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldBookQty)
|
|
return u
|
|
}
|
|
|
|
// AddBookQty adds v to the "book_qty" field.
|
|
func (u *StocktakeItemUpsert) AddBookQty(v int) *StocktakeItemUpsert {
|
|
u.Add(stocktakeitem.FieldBookQty, v)
|
|
return u
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsert) SetScannedQty(v int) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldScannedQty, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateScannedQty sets the "scanned_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateScannedQty() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldScannedQty)
|
|
return u
|
|
}
|
|
|
|
// AddScannedQty adds v to the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsert) AddScannedQty(v int) *StocktakeItemUpsert {
|
|
u.Add(stocktakeitem.FieldScannedQty, v)
|
|
return u
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (u *StocktakeItemUpsert) SetDiffQty(v int) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldDiffQty, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDiffQty sets the "diff_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateDiffQty() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldDiffQty)
|
|
return u
|
|
}
|
|
|
|
// AddDiffQty adds v to the "diff_qty" field.
|
|
func (u *StocktakeItemUpsert) AddDiffQty(v int) *StocktakeItemUpsert {
|
|
u.Add(stocktakeitem.FieldDiffQty, v)
|
|
return u
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (u *StocktakeItemUpsert) SetCounted(v bool) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldCounted, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCounted sets the "counted" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateCounted() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldCounted)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *StocktakeItemUpsert) SetUpdatedAt(v int64) *StocktakeItemUpsert {
|
|
u.Set(stocktakeitem.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsert) UpdateUpdatedAt() *StocktakeItemUpsert {
|
|
u.SetExcluded(stocktakeitem.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *StocktakeItemUpsert) AddUpdatedAt(v int64) *StocktakeItemUpsert {
|
|
u.Add(stocktakeitem.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.StocktakeItem.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *StocktakeItemUpsertOne) UpdateNewValues() *StocktakeItemUpsertOne {
|
|
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.StocktakeItem.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *StocktakeItemUpsertOne) Ignore() *StocktakeItemUpsertOne {
|
|
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 *StocktakeItemUpsertOne) DoNothing() *StocktakeItemUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the StocktakeItemCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *StocktakeItemUpsertOne) Update(set func(*StocktakeItemUpsert)) *StocktakeItemUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&StocktakeItemUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (u *StocktakeItemUpsertOne) SetStocktakeNo(v string) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetStocktakeNo(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStocktakeNo sets the "stocktake_no" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateStocktakeNo() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateStocktakeNo()
|
|
})
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (u *StocktakeItemUpsertOne) SetTargetType(v string) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetTargetType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTargetType sets the "target_type" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateTargetType() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateTargetType()
|
|
})
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (u *StocktakeItemUpsertOne) SetTargetID(v string) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetTargetID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTargetID sets the "target_id" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateTargetID() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateTargetID()
|
|
})
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (u *StocktakeItemUpsertOne) SetMaterialCode(v string) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetMaterialCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateMaterialCode() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateMaterialCode()
|
|
})
|
|
}
|
|
|
|
// ClearMaterialCode clears the value of the "material_code" field.
|
|
func (u *StocktakeItemUpsertOne) ClearMaterialCode() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.ClearMaterialCode()
|
|
})
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (u *StocktakeItemUpsertOne) SetZoneCode(v string) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetZoneCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateZoneCode() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateZoneCode()
|
|
})
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (u *StocktakeItemUpsertOne) ClearZoneCode() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.ClearZoneCode()
|
|
})
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (u *StocktakeItemUpsertOne) SetBookQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetBookQty(v)
|
|
})
|
|
}
|
|
|
|
// AddBookQty adds v to the "book_qty" field.
|
|
func (u *StocktakeItemUpsertOne) AddBookQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddBookQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBookQty sets the "book_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateBookQty() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateBookQty()
|
|
})
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsertOne) SetScannedQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetScannedQty(v)
|
|
})
|
|
}
|
|
|
|
// AddScannedQty adds v to the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsertOne) AddScannedQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddScannedQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScannedQty sets the "scanned_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateScannedQty() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateScannedQty()
|
|
})
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (u *StocktakeItemUpsertOne) SetDiffQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetDiffQty(v)
|
|
})
|
|
}
|
|
|
|
// AddDiffQty adds v to the "diff_qty" field.
|
|
func (u *StocktakeItemUpsertOne) AddDiffQty(v int) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddDiffQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDiffQty sets the "diff_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateDiffQty() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateDiffQty()
|
|
})
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (u *StocktakeItemUpsertOne) SetCounted(v bool) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetCounted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCounted sets the "counted" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateCounted() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateCounted()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *StocktakeItemUpsertOne) SetUpdatedAt(v int64) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *StocktakeItemUpsertOne) AddUpdatedAt(v int64) *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertOne) UpdateUpdatedAt() *StocktakeItemUpsertOne {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *StocktakeItemUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for StocktakeItemCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *StocktakeItemUpsertOne) 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 *StocktakeItemUpsertOne) 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 *StocktakeItemUpsertOne) IDX(ctx context.Context) int {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// StocktakeItemCreateBulk is the builder for creating many StocktakeItem entities in bulk.
|
|
type StocktakeItemCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*StocktakeItemCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the StocktakeItem entities in the database.
|
|
func (_c *StocktakeItemCreateBulk) Save(ctx context.Context) ([]*StocktakeItem, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*StocktakeItem, 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.(*StocktakeItemMutation)
|
|
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 *StocktakeItemCreateBulk) SaveX(ctx context.Context) []*StocktakeItem {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *StocktakeItemCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *StocktakeItemCreateBulk) 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.StocktakeItem.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.StocktakeItemUpsert) {
|
|
// SetStocktakeNo(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *StocktakeItemCreateBulk) OnConflict(opts ...sql.ConflictOption) *StocktakeItemUpsertBulk {
|
|
_c.conflict = opts
|
|
return &StocktakeItemUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.StocktakeItem.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *StocktakeItemCreateBulk) OnConflictColumns(columns ...string) *StocktakeItemUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &StocktakeItemUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// StocktakeItemUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of StocktakeItem nodes.
|
|
type StocktakeItemUpsertBulk struct {
|
|
create *StocktakeItemCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.StocktakeItem.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *StocktakeItemUpsertBulk) UpdateNewValues() *StocktakeItemUpsertBulk {
|
|
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.StocktakeItem.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *StocktakeItemUpsertBulk) Ignore() *StocktakeItemUpsertBulk {
|
|
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 *StocktakeItemUpsertBulk) DoNothing() *StocktakeItemUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the StocktakeItemCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *StocktakeItemUpsertBulk) Update(set func(*StocktakeItemUpsert)) *StocktakeItemUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&StocktakeItemUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (u *StocktakeItemUpsertBulk) SetStocktakeNo(v string) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetStocktakeNo(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStocktakeNo sets the "stocktake_no" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateStocktakeNo() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateStocktakeNo()
|
|
})
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (u *StocktakeItemUpsertBulk) SetTargetType(v string) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetTargetType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTargetType sets the "target_type" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateTargetType() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateTargetType()
|
|
})
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (u *StocktakeItemUpsertBulk) SetTargetID(v string) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetTargetID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTargetID sets the "target_id" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateTargetID() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateTargetID()
|
|
})
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (u *StocktakeItemUpsertBulk) SetMaterialCode(v string) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetMaterialCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateMaterialCode() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateMaterialCode()
|
|
})
|
|
}
|
|
|
|
// ClearMaterialCode clears the value of the "material_code" field.
|
|
func (u *StocktakeItemUpsertBulk) ClearMaterialCode() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.ClearMaterialCode()
|
|
})
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (u *StocktakeItemUpsertBulk) SetZoneCode(v string) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetZoneCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateZoneCode() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateZoneCode()
|
|
})
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (u *StocktakeItemUpsertBulk) ClearZoneCode() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.ClearZoneCode()
|
|
})
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) SetBookQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetBookQty(v)
|
|
})
|
|
}
|
|
|
|
// AddBookQty adds v to the "book_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) AddBookQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddBookQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBookQty sets the "book_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateBookQty() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateBookQty()
|
|
})
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) SetScannedQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetScannedQty(v)
|
|
})
|
|
}
|
|
|
|
// AddScannedQty adds v to the "scanned_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) AddScannedQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddScannedQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateScannedQty sets the "scanned_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateScannedQty() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateScannedQty()
|
|
})
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) SetDiffQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetDiffQty(v)
|
|
})
|
|
}
|
|
|
|
// AddDiffQty adds v to the "diff_qty" field.
|
|
func (u *StocktakeItemUpsertBulk) AddDiffQty(v int) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddDiffQty(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDiffQty sets the "diff_qty" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateDiffQty() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateDiffQty()
|
|
})
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (u *StocktakeItemUpsertBulk) SetCounted(v bool) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetCounted(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCounted sets the "counted" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateCounted() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateCounted()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *StocktakeItemUpsertBulk) SetUpdatedAt(v int64) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *StocktakeItemUpsertBulk) AddUpdatedAt(v int64) *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *StocktakeItemUpsertBulk) UpdateUpdatedAt() *StocktakeItemUpsertBulk {
|
|
return u.Update(func(s *StocktakeItemUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *StocktakeItemUpsertBulk) 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 StocktakeItemCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for StocktakeItemCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *StocktakeItemUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|