// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/outbounddetail" "bj_power_wms/ent/predicate" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // OutboundDetailUpdate is the builder for updating OutboundDetail entities. type OutboundDetailUpdate struct { config hooks []Hook mutation *OutboundDetailMutation } // Where appends a list predicates to the OutboundDetailUpdate builder. func (_u *OutboundDetailUpdate) Where(ps ...predicate.OutboundDetail) *OutboundDetailUpdate { _u.mutation.Where(ps...) return _u } // SetOutboundNo sets the "outbound_no" field. func (_u *OutboundDetailUpdate) SetOutboundNo(v string) *OutboundDetailUpdate { _u.mutation.SetOutboundNo(v) return _u } // SetNillableOutboundNo sets the "outbound_no" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableOutboundNo(v *string) *OutboundDetailUpdate { if v != nil { _u.SetOutboundNo(*v) } return _u } // SetSnCode sets the "sn_code" field. func (_u *OutboundDetailUpdate) SetSnCode(v string) *OutboundDetailUpdate { _u.mutation.SetSnCode(v) return _u } // SetNillableSnCode sets the "sn_code" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableSnCode(v *string) *OutboundDetailUpdate { if v != nil { _u.SetSnCode(*v) } return _u } // ClearSnCode clears the value of the "sn_code" field. func (_u *OutboundDetailUpdate) ClearSnCode() *OutboundDetailUpdate { _u.mutation.ClearSnCode() return _u } // SetBatchNo sets the "batch_no" field. func (_u *OutboundDetailUpdate) SetBatchNo(v string) *OutboundDetailUpdate { _u.mutation.SetBatchNo(v) return _u } // SetNillableBatchNo sets the "batch_no" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableBatchNo(v *string) *OutboundDetailUpdate { if v != nil { _u.SetBatchNo(*v) } return _u } // ClearBatchNo clears the value of the "batch_no" field. func (_u *OutboundDetailUpdate) ClearBatchNo() *OutboundDetailUpdate { _u.mutation.ClearBatchNo() return _u } // SetMaterialCode sets the "material_code" field. func (_u *OutboundDetailUpdate) SetMaterialCode(v string) *OutboundDetailUpdate { _u.mutation.SetMaterialCode(v) return _u } // SetNillableMaterialCode sets the "material_code" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableMaterialCode(v *string) *OutboundDetailUpdate { if v != nil { _u.SetMaterialCode(*v) } return _u } // SetQuantity sets the "quantity" field. func (_u *OutboundDetailUpdate) SetQuantity(v int) *OutboundDetailUpdate { _u.mutation.ResetQuantity() _u.mutation.SetQuantity(v) return _u } // SetNillableQuantity sets the "quantity" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableQuantity(v *int) *OutboundDetailUpdate { if v != nil { _u.SetQuantity(*v) } return _u } // AddQuantity adds value to the "quantity" field. func (_u *OutboundDetailUpdate) AddQuantity(v int) *OutboundDetailUpdate { _u.mutation.AddQuantity(v) return _u } // SetOrderNo sets the "order_no" field. func (_u *OutboundDetailUpdate) SetOrderNo(v string) *OutboundDetailUpdate { _u.mutation.SetOrderNo(v) return _u } // SetNillableOrderNo sets the "order_no" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableOrderNo(v *string) *OutboundDetailUpdate { if v != nil { _u.SetOrderNo(*v) } return _u } // ClearOrderNo clears the value of the "order_no" field. func (_u *OutboundDetailUpdate) ClearOrderNo() *OutboundDetailUpdate { _u.mutation.ClearOrderNo() return _u } // SetCreatedAt sets the "created_at" field. func (_u *OutboundDetailUpdate) SetCreatedAt(v int64) *OutboundDetailUpdate { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *OutboundDetailUpdate) SetNillableCreatedAt(v *int64) *OutboundDetailUpdate { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *OutboundDetailUpdate) AddCreatedAt(v int64) *OutboundDetailUpdate { _u.mutation.AddCreatedAt(v) return _u } // Mutation returns the OutboundDetailMutation object of the builder. func (_u *OutboundDetailUpdate) Mutation() *OutboundDetailMutation { return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *OutboundDetailUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *OutboundDetailUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *OutboundDetailUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *OutboundDetailUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } func (_u *OutboundDetailUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(outbounddetail.Table, outbounddetail.Columns, sqlgraph.NewFieldSpec(outbounddetail.FieldID, field.TypeInt)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.OutboundNo(); ok { _spec.SetField(outbounddetail.FieldOutboundNo, field.TypeString, value) } if value, ok := _u.mutation.SnCode(); ok { _spec.SetField(outbounddetail.FieldSnCode, field.TypeString, value) } if _u.mutation.SnCodeCleared() { _spec.ClearField(outbounddetail.FieldSnCode, field.TypeString) } if value, ok := _u.mutation.BatchNo(); ok { _spec.SetField(outbounddetail.FieldBatchNo, field.TypeString, value) } if _u.mutation.BatchNoCleared() { _spec.ClearField(outbounddetail.FieldBatchNo, field.TypeString) } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(outbounddetail.FieldMaterialCode, field.TypeString, value) } if value, ok := _u.mutation.Quantity(); ok { _spec.SetField(outbounddetail.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.AddedQuantity(); ok { _spec.AddField(outbounddetail.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.OrderNo(); ok { _spec.SetField(outbounddetail.FieldOrderNo, field.TypeString, value) } if _u.mutation.OrderNoCleared() { _spec.ClearField(outbounddetail.FieldOrderNo, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(outbounddetail.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(outbounddetail.FieldCreatedAt, field.TypeInt64, value) } if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{outbounddetail.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // OutboundDetailUpdateOne is the builder for updating a single OutboundDetail entity. type OutboundDetailUpdateOne struct { config fields []string hooks []Hook mutation *OutboundDetailMutation } // SetOutboundNo sets the "outbound_no" field. func (_u *OutboundDetailUpdateOne) SetOutboundNo(v string) *OutboundDetailUpdateOne { _u.mutation.SetOutboundNo(v) return _u } // SetNillableOutboundNo sets the "outbound_no" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableOutboundNo(v *string) *OutboundDetailUpdateOne { if v != nil { _u.SetOutboundNo(*v) } return _u } // SetSnCode sets the "sn_code" field. func (_u *OutboundDetailUpdateOne) SetSnCode(v string) *OutboundDetailUpdateOne { _u.mutation.SetSnCode(v) return _u } // SetNillableSnCode sets the "sn_code" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableSnCode(v *string) *OutboundDetailUpdateOne { if v != nil { _u.SetSnCode(*v) } return _u } // ClearSnCode clears the value of the "sn_code" field. func (_u *OutboundDetailUpdateOne) ClearSnCode() *OutboundDetailUpdateOne { _u.mutation.ClearSnCode() return _u } // SetBatchNo sets the "batch_no" field. func (_u *OutboundDetailUpdateOne) SetBatchNo(v string) *OutboundDetailUpdateOne { _u.mutation.SetBatchNo(v) return _u } // SetNillableBatchNo sets the "batch_no" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableBatchNo(v *string) *OutboundDetailUpdateOne { if v != nil { _u.SetBatchNo(*v) } return _u } // ClearBatchNo clears the value of the "batch_no" field. func (_u *OutboundDetailUpdateOne) ClearBatchNo() *OutboundDetailUpdateOne { _u.mutation.ClearBatchNo() return _u } // SetMaterialCode sets the "material_code" field. func (_u *OutboundDetailUpdateOne) SetMaterialCode(v string) *OutboundDetailUpdateOne { _u.mutation.SetMaterialCode(v) return _u } // SetNillableMaterialCode sets the "material_code" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableMaterialCode(v *string) *OutboundDetailUpdateOne { if v != nil { _u.SetMaterialCode(*v) } return _u } // SetQuantity sets the "quantity" field. func (_u *OutboundDetailUpdateOne) SetQuantity(v int) *OutboundDetailUpdateOne { _u.mutation.ResetQuantity() _u.mutation.SetQuantity(v) return _u } // SetNillableQuantity sets the "quantity" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableQuantity(v *int) *OutboundDetailUpdateOne { if v != nil { _u.SetQuantity(*v) } return _u } // AddQuantity adds value to the "quantity" field. func (_u *OutboundDetailUpdateOne) AddQuantity(v int) *OutboundDetailUpdateOne { _u.mutation.AddQuantity(v) return _u } // SetOrderNo sets the "order_no" field. func (_u *OutboundDetailUpdateOne) SetOrderNo(v string) *OutboundDetailUpdateOne { _u.mutation.SetOrderNo(v) return _u } // SetNillableOrderNo sets the "order_no" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableOrderNo(v *string) *OutboundDetailUpdateOne { if v != nil { _u.SetOrderNo(*v) } return _u } // ClearOrderNo clears the value of the "order_no" field. func (_u *OutboundDetailUpdateOne) ClearOrderNo() *OutboundDetailUpdateOne { _u.mutation.ClearOrderNo() return _u } // SetCreatedAt sets the "created_at" field. func (_u *OutboundDetailUpdateOne) SetCreatedAt(v int64) *OutboundDetailUpdateOne { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *OutboundDetailUpdateOne) SetNillableCreatedAt(v *int64) *OutboundDetailUpdateOne { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *OutboundDetailUpdateOne) AddCreatedAt(v int64) *OutboundDetailUpdateOne { _u.mutation.AddCreatedAt(v) return _u } // Mutation returns the OutboundDetailMutation object of the builder. func (_u *OutboundDetailUpdateOne) Mutation() *OutboundDetailMutation { return _u.mutation } // Where appends a list predicates to the OutboundDetailUpdate builder. func (_u *OutboundDetailUpdateOne) Where(ps ...predicate.OutboundDetail) *OutboundDetailUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *OutboundDetailUpdateOne) Select(field string, fields ...string) *OutboundDetailUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated OutboundDetail entity. func (_u *OutboundDetailUpdateOne) Save(ctx context.Context) (*OutboundDetail, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *OutboundDetailUpdateOne) SaveX(ctx context.Context) *OutboundDetail { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *OutboundDetailUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *OutboundDetailUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } func (_u *OutboundDetailUpdateOne) sqlSave(ctx context.Context) (_node *OutboundDetail, err error) { _spec := sqlgraph.NewUpdateSpec(outbounddetail.Table, outbounddetail.Columns, sqlgraph.NewFieldSpec(outbounddetail.FieldID, field.TypeInt)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "OutboundDetail.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, outbounddetail.FieldID) for _, f := range fields { if !outbounddetail.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != outbounddetail.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.OutboundNo(); ok { _spec.SetField(outbounddetail.FieldOutboundNo, field.TypeString, value) } if value, ok := _u.mutation.SnCode(); ok { _spec.SetField(outbounddetail.FieldSnCode, field.TypeString, value) } if _u.mutation.SnCodeCleared() { _spec.ClearField(outbounddetail.FieldSnCode, field.TypeString) } if value, ok := _u.mutation.BatchNo(); ok { _spec.SetField(outbounddetail.FieldBatchNo, field.TypeString, value) } if _u.mutation.BatchNoCleared() { _spec.ClearField(outbounddetail.FieldBatchNo, field.TypeString) } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(outbounddetail.FieldMaterialCode, field.TypeString, value) } if value, ok := _u.mutation.Quantity(); ok { _spec.SetField(outbounddetail.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.AddedQuantity(); ok { _spec.AddField(outbounddetail.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.OrderNo(); ok { _spec.SetField(outbounddetail.FieldOrderNo, field.TypeString, value) } if _u.mutation.OrderNoCleared() { _spec.ClearField(outbounddetail.FieldOrderNo, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(outbounddetail.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(outbounddetail.FieldCreatedAt, field.TypeInt64, value) } _node = &OutboundDetail{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{outbounddetail.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }