Files
bj_power/bj_power_wms/ent/packagebox_create.go
T

943 lines
27 KiB
Go
Raw Normal View History

2026-08-27 19:50:57 +08:00
// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/packagebox"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// PackageBoxCreate is the builder for creating a PackageBox entity.
type PackageBoxCreate struct {
config
mutation *PackageBoxMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetBoxNo sets the "box_no" field.
func (_c *PackageBoxCreate) SetBoxNo(v string) *PackageBoxCreate {
_c.mutation.SetBoxNo(v)
return _c
}
// SetSnList sets the "sn_list" field.
func (_c *PackageBoxCreate) SetSnList(v string) *PackageBoxCreate {
_c.mutation.SetSnList(v)
return _c
}
// SetNillableSnList sets the "sn_list" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableSnList(v *string) *PackageBoxCreate {
if v != nil {
_c.SetSnList(*v)
}
return _c
}
// SetMaterialCode sets the "material_code" field.
func (_c *PackageBoxCreate) SetMaterialCode(v string) *PackageBoxCreate {
_c.mutation.SetMaterialCode(v)
return _c
}
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableMaterialCode(v *string) *PackageBoxCreate {
if v != nil {
_c.SetMaterialCode(*v)
}
return _c
}
// SetQuantity sets the "quantity" field.
func (_c *PackageBoxCreate) SetQuantity(v int) *PackageBoxCreate {
_c.mutation.SetQuantity(v)
return _c
}
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableQuantity(v *int) *PackageBoxCreate {
if v != nil {
_c.SetQuantity(*v)
}
return _c
}
// SetOperator sets the "operator" field.
func (_c *PackageBoxCreate) SetOperator(v string) *PackageBoxCreate {
_c.mutation.SetOperator(v)
return _c
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableOperator(v *string) *PackageBoxCreate {
if v != nil {
_c.SetOperator(*v)
}
return _c
}
// SetRemark sets the "remark" field.
func (_c *PackageBoxCreate) SetRemark(v string) *PackageBoxCreate {
_c.mutation.SetRemark(v)
return _c
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableRemark(v *string) *PackageBoxCreate {
if v != nil {
_c.SetRemark(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *PackageBoxCreate) SetCreatedAt(v int64) *PackageBoxCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *PackageBoxCreate) SetNillableCreatedAt(v *int64) *PackageBoxCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// Mutation returns the PackageBoxMutation object of the builder.
func (_c *PackageBoxCreate) Mutation() *PackageBoxMutation {
return _c.mutation
}
// Save creates the PackageBox in the database.
func (_c *PackageBoxCreate) Save(ctx context.Context) (*PackageBox, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *PackageBoxCreate) SaveX(ctx context.Context) *PackageBox {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *PackageBoxCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *PackageBoxCreate) 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 *PackageBoxCreate) defaults() {
if _, ok := _c.mutation.Quantity(); !ok {
v := packagebox.DefaultQuantity
_c.mutation.SetQuantity(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := packagebox.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *PackageBoxCreate) check() error {
if _, ok := _c.mutation.BoxNo(); !ok {
return &ValidationError{Name: "box_no", err: errors.New(`ent: missing required field "PackageBox.box_no"`)}
}
if _, ok := _c.mutation.Quantity(); !ok {
return &ValidationError{Name: "quantity", err: errors.New(`ent: missing required field "PackageBox.quantity"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PackageBox.created_at"`)}
}
return nil
}
func (_c *PackageBoxCreate) sqlSave(ctx context.Context) (*PackageBox, 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 *PackageBoxCreate) createSpec() (*PackageBox, *sqlgraph.CreateSpec) {
var (
_node = &PackageBox{config: _c.config}
_spec = sqlgraph.NewCreateSpec(packagebox.Table, sqlgraph.NewFieldSpec(packagebox.FieldID, field.TypeInt))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.BoxNo(); ok {
_spec.SetField(packagebox.FieldBoxNo, field.TypeString, value)
_node.BoxNo = value
}
if value, ok := _c.mutation.SnList(); ok {
_spec.SetField(packagebox.FieldSnList, field.TypeString, value)
_node.SnList = value
}
if value, ok := _c.mutation.MaterialCode(); ok {
_spec.SetField(packagebox.FieldMaterialCode, field.TypeString, value)
_node.MaterialCode = value
}
if value, ok := _c.mutation.Quantity(); ok {
_spec.SetField(packagebox.FieldQuantity, field.TypeInt, value)
_node.Quantity = value
}
if value, ok := _c.mutation.Operator(); ok {
_spec.SetField(packagebox.FieldOperator, field.TypeString, value)
_node.Operator = value
}
if value, ok := _c.mutation.Remark(); ok {
_spec.SetField(packagebox.FieldRemark, field.TypeString, value)
_node.Remark = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(packagebox.FieldCreatedAt, field.TypeInt64, value)
_node.CreatedAt = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.PackageBox.Create().
// SetBoxNo(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.PackageBoxUpsert) {
// SetBoxNo(v+v).
// }).
// Exec(ctx)
func (_c *PackageBoxCreate) OnConflict(opts ...sql.ConflictOption) *PackageBoxUpsertOne {
_c.conflict = opts
return &PackageBoxUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.PackageBox.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *PackageBoxCreate) OnConflictColumns(columns ...string) *PackageBoxUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &PackageBoxUpsertOne{
create: _c,
}
}
type (
// PackageBoxUpsertOne is the builder for "upsert"-ing
// one PackageBox node.
PackageBoxUpsertOne struct {
create *PackageBoxCreate
}
// PackageBoxUpsert is the "OnConflict" setter.
PackageBoxUpsert struct {
*sql.UpdateSet
}
)
// SetBoxNo sets the "box_no" field.
func (u *PackageBoxUpsert) SetBoxNo(v string) *PackageBoxUpsert {
u.Set(packagebox.FieldBoxNo, v)
return u
}
// UpdateBoxNo sets the "box_no" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateBoxNo() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldBoxNo)
return u
}
// SetSnList sets the "sn_list" field.
func (u *PackageBoxUpsert) SetSnList(v string) *PackageBoxUpsert {
u.Set(packagebox.FieldSnList, v)
return u
}
// UpdateSnList sets the "sn_list" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateSnList() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldSnList)
return u
}
// ClearSnList clears the value of the "sn_list" field.
func (u *PackageBoxUpsert) ClearSnList() *PackageBoxUpsert {
u.SetNull(packagebox.FieldSnList)
return u
}
// SetMaterialCode sets the "material_code" field.
func (u *PackageBoxUpsert) SetMaterialCode(v string) *PackageBoxUpsert {
u.Set(packagebox.FieldMaterialCode, v)
return u
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateMaterialCode() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldMaterialCode)
return u
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *PackageBoxUpsert) ClearMaterialCode() *PackageBoxUpsert {
u.SetNull(packagebox.FieldMaterialCode)
return u
}
// SetQuantity sets the "quantity" field.
func (u *PackageBoxUpsert) SetQuantity(v int) *PackageBoxUpsert {
u.Set(packagebox.FieldQuantity, v)
return u
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateQuantity() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldQuantity)
return u
}
// AddQuantity adds v to the "quantity" field.
func (u *PackageBoxUpsert) AddQuantity(v int) *PackageBoxUpsert {
u.Add(packagebox.FieldQuantity, v)
return u
}
// SetOperator sets the "operator" field.
func (u *PackageBoxUpsert) SetOperator(v string) *PackageBoxUpsert {
u.Set(packagebox.FieldOperator, v)
return u
}
// UpdateOperator sets the "operator" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateOperator() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldOperator)
return u
}
// ClearOperator clears the value of the "operator" field.
func (u *PackageBoxUpsert) ClearOperator() *PackageBoxUpsert {
u.SetNull(packagebox.FieldOperator)
return u
}
// SetRemark sets the "remark" field.
func (u *PackageBoxUpsert) SetRemark(v string) *PackageBoxUpsert {
u.Set(packagebox.FieldRemark, v)
return u
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateRemark() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldRemark)
return u
}
// ClearRemark clears the value of the "remark" field.
func (u *PackageBoxUpsert) ClearRemark() *PackageBoxUpsert {
u.SetNull(packagebox.FieldRemark)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *PackageBoxUpsert) SetCreatedAt(v int64) *PackageBoxUpsert {
u.Set(packagebox.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *PackageBoxUpsert) UpdateCreatedAt() *PackageBoxUpsert {
u.SetExcluded(packagebox.FieldCreatedAt)
return u
}
// AddCreatedAt adds v to the "created_at" field.
func (u *PackageBoxUpsert) AddCreatedAt(v int64) *PackageBoxUpsert {
u.Add(packagebox.FieldCreatedAt, 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.PackageBox.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *PackageBoxUpsertOne) UpdateNewValues() *PackageBoxUpsertOne {
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.PackageBox.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *PackageBoxUpsertOne) Ignore() *PackageBoxUpsertOne {
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 *PackageBoxUpsertOne) DoNothing() *PackageBoxUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the PackageBoxCreate.OnConflict
// documentation for more info.
func (u *PackageBoxUpsertOne) Update(set func(*PackageBoxUpsert)) *PackageBoxUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&PackageBoxUpsert{UpdateSet: update})
}))
return u
}
// SetBoxNo sets the "box_no" field.
func (u *PackageBoxUpsertOne) SetBoxNo(v string) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetBoxNo(v)
})
}
// UpdateBoxNo sets the "box_no" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateBoxNo() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateBoxNo()
})
}
// SetSnList sets the "sn_list" field.
func (u *PackageBoxUpsertOne) SetSnList(v string) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetSnList(v)
})
}
// UpdateSnList sets the "sn_list" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateSnList() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateSnList()
})
}
// ClearSnList clears the value of the "sn_list" field.
func (u *PackageBoxUpsertOne) ClearSnList() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearSnList()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *PackageBoxUpsertOne) SetMaterialCode(v string) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateMaterialCode() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateMaterialCode()
})
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *PackageBoxUpsertOne) ClearMaterialCode() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearMaterialCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *PackageBoxUpsertOne) SetQuantity(v int) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *PackageBoxUpsertOne) AddQuantity(v int) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateQuantity() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateQuantity()
})
}
// SetOperator sets the "operator" field.
func (u *PackageBoxUpsertOne) SetOperator(v string) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetOperator(v)
})
}
// UpdateOperator sets the "operator" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateOperator() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateOperator()
})
}
// ClearOperator clears the value of the "operator" field.
func (u *PackageBoxUpsertOne) ClearOperator() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearOperator()
})
}
// SetRemark sets the "remark" field.
func (u *PackageBoxUpsertOne) SetRemark(v string) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateRemark() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *PackageBoxUpsertOne) ClearRemark() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *PackageBoxUpsertOne) SetCreatedAt(v int64) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *PackageBoxUpsertOne) AddCreatedAt(v int64) *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *PackageBoxUpsertOne) UpdateCreatedAt() *PackageBoxUpsertOne {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *PackageBoxUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for PackageBoxCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *PackageBoxUpsertOne) 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 *PackageBoxUpsertOne) 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 *PackageBoxUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// PackageBoxCreateBulk is the builder for creating many PackageBox entities in bulk.
type PackageBoxCreateBulk struct {
config
err error
builders []*PackageBoxCreate
conflict []sql.ConflictOption
}
// Save creates the PackageBox entities in the database.
func (_c *PackageBoxCreateBulk) Save(ctx context.Context) ([]*PackageBox, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*PackageBox, 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.(*PackageBoxMutation)
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 *PackageBoxCreateBulk) SaveX(ctx context.Context) []*PackageBox {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *PackageBoxCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *PackageBoxCreateBulk) 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.PackageBox.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.PackageBoxUpsert) {
// SetBoxNo(v+v).
// }).
// Exec(ctx)
func (_c *PackageBoxCreateBulk) OnConflict(opts ...sql.ConflictOption) *PackageBoxUpsertBulk {
_c.conflict = opts
return &PackageBoxUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.PackageBox.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *PackageBoxCreateBulk) OnConflictColumns(columns ...string) *PackageBoxUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &PackageBoxUpsertBulk{
create: _c,
}
}
// PackageBoxUpsertBulk is the builder for "upsert"-ing
// a bulk of PackageBox nodes.
type PackageBoxUpsertBulk struct {
create *PackageBoxCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.PackageBox.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *PackageBoxUpsertBulk) UpdateNewValues() *PackageBoxUpsertBulk {
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.PackageBox.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *PackageBoxUpsertBulk) Ignore() *PackageBoxUpsertBulk {
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 *PackageBoxUpsertBulk) DoNothing() *PackageBoxUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the PackageBoxCreateBulk.OnConflict
// documentation for more info.
func (u *PackageBoxUpsertBulk) Update(set func(*PackageBoxUpsert)) *PackageBoxUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&PackageBoxUpsert{UpdateSet: update})
}))
return u
}
// SetBoxNo sets the "box_no" field.
func (u *PackageBoxUpsertBulk) SetBoxNo(v string) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetBoxNo(v)
})
}
// UpdateBoxNo sets the "box_no" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateBoxNo() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateBoxNo()
})
}
// SetSnList sets the "sn_list" field.
func (u *PackageBoxUpsertBulk) SetSnList(v string) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetSnList(v)
})
}
// UpdateSnList sets the "sn_list" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateSnList() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateSnList()
})
}
// ClearSnList clears the value of the "sn_list" field.
func (u *PackageBoxUpsertBulk) ClearSnList() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearSnList()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *PackageBoxUpsertBulk) SetMaterialCode(v string) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateMaterialCode() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateMaterialCode()
})
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *PackageBoxUpsertBulk) ClearMaterialCode() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearMaterialCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *PackageBoxUpsertBulk) SetQuantity(v int) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *PackageBoxUpsertBulk) AddQuantity(v int) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateQuantity() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateQuantity()
})
}
// SetOperator sets the "operator" field.
func (u *PackageBoxUpsertBulk) SetOperator(v string) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetOperator(v)
})
}
// UpdateOperator sets the "operator" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateOperator() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateOperator()
})
}
// ClearOperator clears the value of the "operator" field.
func (u *PackageBoxUpsertBulk) ClearOperator() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearOperator()
})
}
// SetRemark sets the "remark" field.
func (u *PackageBoxUpsertBulk) SetRemark(v string) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetRemark(v)
})
}
// UpdateRemark sets the "remark" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateRemark() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateRemark()
})
}
// ClearRemark clears the value of the "remark" field.
func (u *PackageBoxUpsertBulk) ClearRemark() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.ClearRemark()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *PackageBoxUpsertBulk) SetCreatedAt(v int64) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *PackageBoxUpsertBulk) AddCreatedAt(v int64) *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *PackageBoxUpsertBulk) UpdateCreatedAt() *PackageBoxUpsertBulk {
return u.Update(func(s *PackageBoxUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *PackageBoxUpsertBulk) 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 PackageBoxCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for PackageBoxCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *PackageBoxUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}