Files
bj_power/bj_power_wms/ent/outbounddetail_create.go
T

918 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/outbounddetail"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// OutboundDetailCreate is the builder for creating a OutboundDetail entity.
type OutboundDetailCreate struct {
config
mutation *OutboundDetailMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetOutboundNo sets the "outbound_no" field.
func (_c *OutboundDetailCreate) SetOutboundNo(v string) *OutboundDetailCreate {
_c.mutation.SetOutboundNo(v)
return _c
}
// SetSnCode sets the "sn_code" field.
func (_c *OutboundDetailCreate) SetSnCode(v string) *OutboundDetailCreate {
_c.mutation.SetSnCode(v)
return _c
}
// SetNillableSnCode sets the "sn_code" field if the given value is not nil.
func (_c *OutboundDetailCreate) SetNillableSnCode(v *string) *OutboundDetailCreate {
if v != nil {
_c.SetSnCode(*v)
}
return _c
}
// SetBatchNo sets the "batch_no" field.
func (_c *OutboundDetailCreate) SetBatchNo(v string) *OutboundDetailCreate {
_c.mutation.SetBatchNo(v)
return _c
}
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
func (_c *OutboundDetailCreate) SetNillableBatchNo(v *string) *OutboundDetailCreate {
if v != nil {
_c.SetBatchNo(*v)
}
return _c
}
// SetMaterialCode sets the "material_code" field.
func (_c *OutboundDetailCreate) SetMaterialCode(v string) *OutboundDetailCreate {
_c.mutation.SetMaterialCode(v)
return _c
}
// SetQuantity sets the "quantity" field.
func (_c *OutboundDetailCreate) SetQuantity(v int) *OutboundDetailCreate {
_c.mutation.SetQuantity(v)
return _c
}
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
func (_c *OutboundDetailCreate) SetNillableQuantity(v *int) *OutboundDetailCreate {
if v != nil {
_c.SetQuantity(*v)
}
return _c
}
// SetOrderNo sets the "order_no" field.
func (_c *OutboundDetailCreate) SetOrderNo(v string) *OutboundDetailCreate {
_c.mutation.SetOrderNo(v)
return _c
}
// SetNillableOrderNo sets the "order_no" field if the given value is not nil.
func (_c *OutboundDetailCreate) SetNillableOrderNo(v *string) *OutboundDetailCreate {
if v != nil {
_c.SetOrderNo(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *OutboundDetailCreate) SetCreatedAt(v int64) *OutboundDetailCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *OutboundDetailCreate) SetNillableCreatedAt(v *int64) *OutboundDetailCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// Mutation returns the OutboundDetailMutation object of the builder.
func (_c *OutboundDetailCreate) Mutation() *OutboundDetailMutation {
return _c.mutation
}
// Save creates the OutboundDetail in the database.
func (_c *OutboundDetailCreate) Save(ctx context.Context) (*OutboundDetail, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *OutboundDetailCreate) SaveX(ctx context.Context) *OutboundDetail {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *OutboundDetailCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *OutboundDetailCreate) 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 *OutboundDetailCreate) defaults() {
if _, ok := _c.mutation.Quantity(); !ok {
v := outbounddetail.DefaultQuantity
_c.mutation.SetQuantity(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := outbounddetail.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *OutboundDetailCreate) check() error {
if _, ok := _c.mutation.OutboundNo(); !ok {
return &ValidationError{Name: "outbound_no", err: errors.New(`ent: missing required field "OutboundDetail.outbound_no"`)}
}
if _, ok := _c.mutation.MaterialCode(); !ok {
return &ValidationError{Name: "material_code", err: errors.New(`ent: missing required field "OutboundDetail.material_code"`)}
}
if _, ok := _c.mutation.Quantity(); !ok {
return &ValidationError{Name: "quantity", err: errors.New(`ent: missing required field "OutboundDetail.quantity"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "OutboundDetail.created_at"`)}
}
return nil
}
func (_c *OutboundDetailCreate) sqlSave(ctx context.Context) (*OutboundDetail, 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 *OutboundDetailCreate) createSpec() (*OutboundDetail, *sqlgraph.CreateSpec) {
var (
_node = &OutboundDetail{config: _c.config}
_spec = sqlgraph.NewCreateSpec(outbounddetail.Table, sqlgraph.NewFieldSpec(outbounddetail.FieldID, field.TypeInt))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.OutboundNo(); ok {
_spec.SetField(outbounddetail.FieldOutboundNo, field.TypeString, value)
_node.OutboundNo = value
}
if value, ok := _c.mutation.SnCode(); ok {
_spec.SetField(outbounddetail.FieldSnCode, field.TypeString, value)
_node.SnCode = value
}
if value, ok := _c.mutation.BatchNo(); ok {
_spec.SetField(outbounddetail.FieldBatchNo, field.TypeString, value)
_node.BatchNo = value
}
if value, ok := _c.mutation.MaterialCode(); ok {
_spec.SetField(outbounddetail.FieldMaterialCode, field.TypeString, value)
_node.MaterialCode = value
}
if value, ok := _c.mutation.Quantity(); ok {
_spec.SetField(outbounddetail.FieldQuantity, field.TypeInt, value)
_node.Quantity = value
}
if value, ok := _c.mutation.OrderNo(); ok {
_spec.SetField(outbounddetail.FieldOrderNo, field.TypeString, value)
_node.OrderNo = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(outbounddetail.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.OutboundDetail.Create().
// SetOutboundNo(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.OutboundDetailUpsert) {
// SetOutboundNo(v+v).
// }).
// Exec(ctx)
func (_c *OutboundDetailCreate) OnConflict(opts ...sql.ConflictOption) *OutboundDetailUpsertOne {
_c.conflict = opts
return &OutboundDetailUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.OutboundDetail.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *OutboundDetailCreate) OnConflictColumns(columns ...string) *OutboundDetailUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &OutboundDetailUpsertOne{
create: _c,
}
}
type (
// OutboundDetailUpsertOne is the builder for "upsert"-ing
// one OutboundDetail node.
OutboundDetailUpsertOne struct {
create *OutboundDetailCreate
}
// OutboundDetailUpsert is the "OnConflict" setter.
OutboundDetailUpsert struct {
*sql.UpdateSet
}
)
// SetOutboundNo sets the "outbound_no" field.
func (u *OutboundDetailUpsert) SetOutboundNo(v string) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldOutboundNo, v)
return u
}
// UpdateOutboundNo sets the "outbound_no" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateOutboundNo() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldOutboundNo)
return u
}
// SetSnCode sets the "sn_code" field.
func (u *OutboundDetailUpsert) SetSnCode(v string) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldSnCode, v)
return u
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateSnCode() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldSnCode)
return u
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *OutboundDetailUpsert) ClearSnCode() *OutboundDetailUpsert {
u.SetNull(outbounddetail.FieldSnCode)
return u
}
// SetBatchNo sets the "batch_no" field.
func (u *OutboundDetailUpsert) SetBatchNo(v string) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldBatchNo, v)
return u
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateBatchNo() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldBatchNo)
return u
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *OutboundDetailUpsert) ClearBatchNo() *OutboundDetailUpsert {
u.SetNull(outbounddetail.FieldBatchNo)
return u
}
// SetMaterialCode sets the "material_code" field.
func (u *OutboundDetailUpsert) SetMaterialCode(v string) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldMaterialCode, v)
return u
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateMaterialCode() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldMaterialCode)
return u
}
// SetQuantity sets the "quantity" field.
func (u *OutboundDetailUpsert) SetQuantity(v int) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldQuantity, v)
return u
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateQuantity() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldQuantity)
return u
}
// AddQuantity adds v to the "quantity" field.
func (u *OutboundDetailUpsert) AddQuantity(v int) *OutboundDetailUpsert {
u.Add(outbounddetail.FieldQuantity, v)
return u
}
// SetOrderNo sets the "order_no" field.
func (u *OutboundDetailUpsert) SetOrderNo(v string) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldOrderNo, v)
return u
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateOrderNo() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldOrderNo)
return u
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *OutboundDetailUpsert) ClearOrderNo() *OutboundDetailUpsert {
u.SetNull(outbounddetail.FieldOrderNo)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *OutboundDetailUpsert) SetCreatedAt(v int64) *OutboundDetailUpsert {
u.Set(outbounddetail.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *OutboundDetailUpsert) UpdateCreatedAt() *OutboundDetailUpsert {
u.SetExcluded(outbounddetail.FieldCreatedAt)
return u
}
// AddCreatedAt adds v to the "created_at" field.
func (u *OutboundDetailUpsert) AddCreatedAt(v int64) *OutboundDetailUpsert {
u.Add(outbounddetail.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.OutboundDetail.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *OutboundDetailUpsertOne) UpdateNewValues() *OutboundDetailUpsertOne {
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.OutboundDetail.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *OutboundDetailUpsertOne) Ignore() *OutboundDetailUpsertOne {
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 *OutboundDetailUpsertOne) DoNothing() *OutboundDetailUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the OutboundDetailCreate.OnConflict
// documentation for more info.
func (u *OutboundDetailUpsertOne) Update(set func(*OutboundDetailUpsert)) *OutboundDetailUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&OutboundDetailUpsert{UpdateSet: update})
}))
return u
}
// SetOutboundNo sets the "outbound_no" field.
func (u *OutboundDetailUpsertOne) SetOutboundNo(v string) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetOutboundNo(v)
})
}
// UpdateOutboundNo sets the "outbound_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateOutboundNo() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateOutboundNo()
})
}
// SetSnCode sets the "sn_code" field.
func (u *OutboundDetailUpsertOne) SetSnCode(v string) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetSnCode(v)
})
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateSnCode() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateSnCode()
})
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *OutboundDetailUpsertOne) ClearSnCode() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearSnCode()
})
}
// SetBatchNo sets the "batch_no" field.
func (u *OutboundDetailUpsertOne) SetBatchNo(v string) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetBatchNo(v)
})
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateBatchNo() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateBatchNo()
})
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *OutboundDetailUpsertOne) ClearBatchNo() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearBatchNo()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *OutboundDetailUpsertOne) SetMaterialCode(v string) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateMaterialCode() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateMaterialCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *OutboundDetailUpsertOne) SetQuantity(v int) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *OutboundDetailUpsertOne) AddQuantity(v int) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateQuantity() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateQuantity()
})
}
// SetOrderNo sets the "order_no" field.
func (u *OutboundDetailUpsertOne) SetOrderNo(v string) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetOrderNo(v)
})
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateOrderNo() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateOrderNo()
})
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *OutboundDetailUpsertOne) ClearOrderNo() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearOrderNo()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *OutboundDetailUpsertOne) SetCreatedAt(v int64) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *OutboundDetailUpsertOne) AddCreatedAt(v int64) *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *OutboundDetailUpsertOne) UpdateCreatedAt() *OutboundDetailUpsertOne {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *OutboundDetailUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for OutboundDetailCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *OutboundDetailUpsertOne) 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 *OutboundDetailUpsertOne) 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 *OutboundDetailUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// OutboundDetailCreateBulk is the builder for creating many OutboundDetail entities in bulk.
type OutboundDetailCreateBulk struct {
config
err error
builders []*OutboundDetailCreate
conflict []sql.ConflictOption
}
// Save creates the OutboundDetail entities in the database.
func (_c *OutboundDetailCreateBulk) Save(ctx context.Context) ([]*OutboundDetail, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*OutboundDetail, 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.(*OutboundDetailMutation)
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 *OutboundDetailCreateBulk) SaveX(ctx context.Context) []*OutboundDetail {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *OutboundDetailCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *OutboundDetailCreateBulk) 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.OutboundDetail.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.OutboundDetailUpsert) {
// SetOutboundNo(v+v).
// }).
// Exec(ctx)
func (_c *OutboundDetailCreateBulk) OnConflict(opts ...sql.ConflictOption) *OutboundDetailUpsertBulk {
_c.conflict = opts
return &OutboundDetailUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.OutboundDetail.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *OutboundDetailCreateBulk) OnConflictColumns(columns ...string) *OutboundDetailUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &OutboundDetailUpsertBulk{
create: _c,
}
}
// OutboundDetailUpsertBulk is the builder for "upsert"-ing
// a bulk of OutboundDetail nodes.
type OutboundDetailUpsertBulk struct {
create *OutboundDetailCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.OutboundDetail.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *OutboundDetailUpsertBulk) UpdateNewValues() *OutboundDetailUpsertBulk {
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.OutboundDetail.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *OutboundDetailUpsertBulk) Ignore() *OutboundDetailUpsertBulk {
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 *OutboundDetailUpsertBulk) DoNothing() *OutboundDetailUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the OutboundDetailCreateBulk.OnConflict
// documentation for more info.
func (u *OutboundDetailUpsertBulk) Update(set func(*OutboundDetailUpsert)) *OutboundDetailUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&OutboundDetailUpsert{UpdateSet: update})
}))
return u
}
// SetOutboundNo sets the "outbound_no" field.
func (u *OutboundDetailUpsertBulk) SetOutboundNo(v string) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetOutboundNo(v)
})
}
// UpdateOutboundNo sets the "outbound_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateOutboundNo() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateOutboundNo()
})
}
// SetSnCode sets the "sn_code" field.
func (u *OutboundDetailUpsertBulk) SetSnCode(v string) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetSnCode(v)
})
}
// UpdateSnCode sets the "sn_code" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateSnCode() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateSnCode()
})
}
// ClearSnCode clears the value of the "sn_code" field.
func (u *OutboundDetailUpsertBulk) ClearSnCode() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearSnCode()
})
}
// SetBatchNo sets the "batch_no" field.
func (u *OutboundDetailUpsertBulk) SetBatchNo(v string) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetBatchNo(v)
})
}
// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateBatchNo() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateBatchNo()
})
}
// ClearBatchNo clears the value of the "batch_no" field.
func (u *OutboundDetailUpsertBulk) ClearBatchNo() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearBatchNo()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *OutboundDetailUpsertBulk) SetMaterialCode(v string) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateMaterialCode() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateMaterialCode()
})
}
// SetQuantity sets the "quantity" field.
func (u *OutboundDetailUpsertBulk) SetQuantity(v int) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *OutboundDetailUpsertBulk) AddQuantity(v int) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateQuantity() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateQuantity()
})
}
// SetOrderNo sets the "order_no" field.
func (u *OutboundDetailUpsertBulk) SetOrderNo(v string) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetOrderNo(v)
})
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateOrderNo() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateOrderNo()
})
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *OutboundDetailUpsertBulk) ClearOrderNo() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.ClearOrderNo()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *OutboundDetailUpsertBulk) SetCreatedAt(v int64) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *OutboundDetailUpsertBulk) AddCreatedAt(v int64) *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *OutboundDetailUpsertBulk) UpdateCreatedAt() *OutboundDetailUpsertBulk {
return u.Update(func(s *OutboundDetailUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *OutboundDetailUpsertBulk) 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 OutboundDetailCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for OutboundDetailCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *OutboundDetailUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}