632 lines
19 KiB
Go
632 lines
19 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/predicate"
|
|
"bj_power_wms/ent/stocktakeitem"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// StocktakeItemUpdate is the builder for updating StocktakeItem entities.
|
|
type StocktakeItemUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *StocktakeItemMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the StocktakeItemUpdate builder.
|
|
func (_u *StocktakeItemUpdate) Where(ps ...predicate.StocktakeItem) *StocktakeItemUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (_u *StocktakeItemUpdate) SetStocktakeNo(v string) *StocktakeItemUpdate {
|
|
_u.mutation.SetStocktakeNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStocktakeNo sets the "stocktake_no" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableStocktakeNo(v *string) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetStocktakeNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (_u *StocktakeItemUpdate) SetTargetType(v string) *StocktakeItemUpdate {
|
|
_u.mutation.SetTargetType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetType sets the "target_type" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableTargetType(v *string) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetTargetType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (_u *StocktakeItemUpdate) SetTargetID(v string) *StocktakeItemUpdate {
|
|
_u.mutation.SetTargetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableTargetID(v *string) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetTargetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *StocktakeItemUpdate) SetMaterialCode(v string) *StocktakeItemUpdate {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableMaterialCode(v *string) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialCode clears the value of the "material_code" field.
|
|
func (_u *StocktakeItemUpdate) ClearMaterialCode() *StocktakeItemUpdate {
|
|
_u.mutation.ClearMaterialCode()
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *StocktakeItemUpdate) SetZoneCode(v string) *StocktakeItemUpdate {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableZoneCode(v *string) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *StocktakeItemUpdate) ClearZoneCode() *StocktakeItemUpdate {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (_u *StocktakeItemUpdate) SetBookQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.ResetBookQty()
|
|
_u.mutation.SetBookQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBookQty sets the "book_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableBookQty(v *int) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetBookQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddBookQty adds value to the "book_qty" field.
|
|
func (_u *StocktakeItemUpdate) AddBookQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.AddBookQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (_u *StocktakeItemUpdate) SetScannedQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.ResetScannedQty()
|
|
_u.mutation.SetScannedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScannedQty sets the "scanned_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableScannedQty(v *int) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetScannedQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScannedQty adds value to the "scanned_qty" field.
|
|
func (_u *StocktakeItemUpdate) AddScannedQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.AddScannedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (_u *StocktakeItemUpdate) SetDiffQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.ResetDiffQty()
|
|
_u.mutation.SetDiffQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDiffQty sets the "diff_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableDiffQty(v *int) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetDiffQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDiffQty adds value to the "diff_qty" field.
|
|
func (_u *StocktakeItemUpdate) AddDiffQty(v int) *StocktakeItemUpdate {
|
|
_u.mutation.AddDiffQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (_u *StocktakeItemUpdate) SetCounted(v bool) *StocktakeItemUpdate {
|
|
_u.mutation.SetCounted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCounted sets the "counted" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableCounted(v *bool) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetCounted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *StocktakeItemUpdate) SetUpdatedAt(v int64) *StocktakeItemUpdate {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdate) SetNillableUpdatedAt(v *int64) *StocktakeItemUpdate {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *StocktakeItemUpdate) AddUpdatedAt(v int64) *StocktakeItemUpdate {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the StocktakeItemMutation object of the builder.
|
|
func (_u *StocktakeItemUpdate) Mutation() *StocktakeItemMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *StocktakeItemUpdate) 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 *StocktakeItemUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *StocktakeItemUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *StocktakeItemUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *StocktakeItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(stocktakeitem.Table, stocktakeitem.Columns, sqlgraph.NewFieldSpec(stocktakeitem.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.StocktakeNo(); ok {
|
|
_spec.SetField(stocktakeitem.FieldStocktakeNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TargetType(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TargetID(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialCodeCleared() {
|
|
_spec.ClearField(stocktakeitem.FieldMaterialCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(stocktakeitem.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.BookQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldBookQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedBookQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldBookQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ScannedQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldScannedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScannedQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldScannedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DiffQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldDiffQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDiffQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldDiffQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Counted(); ok {
|
|
_spec.SetField(stocktakeitem.FieldCounted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(stocktakeitem.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(stocktakeitem.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{stocktakeitem.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// StocktakeItemUpdateOne is the builder for updating a single StocktakeItem entity.
|
|
type StocktakeItemUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *StocktakeItemMutation
|
|
}
|
|
|
|
// SetStocktakeNo sets the "stocktake_no" field.
|
|
func (_u *StocktakeItemUpdateOne) SetStocktakeNo(v string) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetStocktakeNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStocktakeNo sets the "stocktake_no" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableStocktakeNo(v *string) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetStocktakeNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetType sets the "target_type" field.
|
|
func (_u *StocktakeItemUpdateOne) SetTargetType(v string) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetTargetType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetType sets the "target_type" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableTargetType(v *string) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetTargetType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetID sets the "target_id" field.
|
|
func (_u *StocktakeItemUpdateOne) SetTargetID(v string) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetTargetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableTargetID(v *string) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetTargetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *StocktakeItemUpdateOne) SetMaterialCode(v string) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableMaterialCode(v *string) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialCode clears the value of the "material_code" field.
|
|
func (_u *StocktakeItemUpdateOne) ClearMaterialCode() *StocktakeItemUpdateOne {
|
|
_u.mutation.ClearMaterialCode()
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *StocktakeItemUpdateOne) SetZoneCode(v string) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableZoneCode(v *string) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *StocktakeItemUpdateOne) ClearZoneCode() *StocktakeItemUpdateOne {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetBookQty sets the "book_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) SetBookQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.ResetBookQty()
|
|
_u.mutation.SetBookQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBookQty sets the "book_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableBookQty(v *int) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetBookQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddBookQty adds value to the "book_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) AddBookQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.AddBookQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetScannedQty sets the "scanned_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) SetScannedQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.ResetScannedQty()
|
|
_u.mutation.SetScannedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScannedQty sets the "scanned_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableScannedQty(v *int) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetScannedQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScannedQty adds value to the "scanned_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) AddScannedQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.AddScannedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDiffQty sets the "diff_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) SetDiffQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.ResetDiffQty()
|
|
_u.mutation.SetDiffQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDiffQty sets the "diff_qty" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableDiffQty(v *int) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetDiffQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDiffQty adds value to the "diff_qty" field.
|
|
func (_u *StocktakeItemUpdateOne) AddDiffQty(v int) *StocktakeItemUpdateOne {
|
|
_u.mutation.AddDiffQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCounted sets the "counted" field.
|
|
func (_u *StocktakeItemUpdateOne) SetCounted(v bool) *StocktakeItemUpdateOne {
|
|
_u.mutation.SetCounted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCounted sets the "counted" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableCounted(v *bool) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetCounted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *StocktakeItemUpdateOne) SetUpdatedAt(v int64) *StocktakeItemUpdateOne {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *StocktakeItemUpdateOne) SetNillableUpdatedAt(v *int64) *StocktakeItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *StocktakeItemUpdateOne) AddUpdatedAt(v int64) *StocktakeItemUpdateOne {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the StocktakeItemMutation object of the builder.
|
|
func (_u *StocktakeItemUpdateOne) Mutation() *StocktakeItemMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the StocktakeItemUpdate builder.
|
|
func (_u *StocktakeItemUpdateOne) Where(ps ...predicate.StocktakeItem) *StocktakeItemUpdateOne {
|
|
_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 *StocktakeItemUpdateOne) Select(field string, fields ...string) *StocktakeItemUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated StocktakeItem entity.
|
|
func (_u *StocktakeItemUpdateOne) Save(ctx context.Context) (*StocktakeItem, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *StocktakeItemUpdateOne) SaveX(ctx context.Context) *StocktakeItem {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *StocktakeItemUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *StocktakeItemUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *StocktakeItemUpdateOne) sqlSave(ctx context.Context) (_node *StocktakeItem, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(stocktakeitem.Table, stocktakeitem.Columns, sqlgraph.NewFieldSpec(stocktakeitem.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "StocktakeItem.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, stocktakeitem.FieldID)
|
|
for _, f := range fields {
|
|
if !stocktakeitem.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != stocktakeitem.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.StocktakeNo(); ok {
|
|
_spec.SetField(stocktakeitem.FieldStocktakeNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TargetType(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TargetID(); ok {
|
|
_spec.SetField(stocktakeitem.FieldTargetID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialCodeCleared() {
|
|
_spec.ClearField(stocktakeitem.FieldMaterialCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(stocktakeitem.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(stocktakeitem.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.BookQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldBookQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedBookQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldBookQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ScannedQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldScannedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScannedQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldScannedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DiffQty(); ok {
|
|
_spec.SetField(stocktakeitem.FieldDiffQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDiffQty(); ok {
|
|
_spec.AddField(stocktakeitem.FieldDiffQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Counted(); ok {
|
|
_spec.SetField(stocktakeitem.FieldCounted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(stocktakeitem.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(stocktakeitem.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
_node = &StocktakeItem{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{stocktakeitem.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|