// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/inventory" "bj_power_wms/ent/predicate" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // InventoryUpdate is the builder for updating Inventory entities. type InventoryUpdate struct { config hooks []Hook mutation *InventoryMutation } // Where appends a list predicates to the InventoryUpdate builder. func (_u *InventoryUpdate) Where(ps ...predicate.Inventory) *InventoryUpdate { _u.mutation.Where(ps...) return _u } // SetManageMode sets the "manage_mode" field. func (_u *InventoryUpdate) SetManageMode(v int) *InventoryUpdate { _u.mutation.ResetManageMode() _u.mutation.SetManageMode(v) return _u } // SetNillableManageMode sets the "manage_mode" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableManageMode(v *int) *InventoryUpdate { if v != nil { _u.SetManageMode(*v) } return _u } // AddManageMode adds value to the "manage_mode" field. func (_u *InventoryUpdate) AddManageMode(v int) *InventoryUpdate { _u.mutation.AddManageMode(v) return _u } // SetCategory sets the "category" field. func (_u *InventoryUpdate) SetCategory(v int) *InventoryUpdate { _u.mutation.ResetCategory() _u.mutation.SetCategory(v) return _u } // SetNillableCategory sets the "category" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableCategory(v *int) *InventoryUpdate { if v != nil { _u.SetCategory(*v) } return _u } // AddCategory adds value to the "category" field. func (_u *InventoryUpdate) AddCategory(v int) *InventoryUpdate { _u.mutation.AddCategory(v) return _u } // SetMaterialCode sets the "material_code" field. func (_u *InventoryUpdate) SetMaterialCode(v string) *InventoryUpdate { _u.mutation.SetMaterialCode(v) return _u } // SetNillableMaterialCode sets the "material_code" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableMaterialCode(v *string) *InventoryUpdate { if v != nil { _u.SetMaterialCode(*v) } return _u } // SetMaterialName sets the "material_name" field. func (_u *InventoryUpdate) SetMaterialName(v string) *InventoryUpdate { _u.mutation.SetMaterialName(v) return _u } // SetNillableMaterialName sets the "material_name" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableMaterialName(v *string) *InventoryUpdate { if v != nil { _u.SetMaterialName(*v) } return _u } // ClearMaterialName clears the value of the "material_name" field. func (_u *InventoryUpdate) ClearMaterialName() *InventoryUpdate { _u.mutation.ClearMaterialName() return _u } // SetBatchNo sets the "batch_no" field. func (_u *InventoryUpdate) SetBatchNo(v string) *InventoryUpdate { _u.mutation.SetBatchNo(v) return _u } // SetNillableBatchNo sets the "batch_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableBatchNo(v *string) *InventoryUpdate { if v != nil { _u.SetBatchNo(*v) } return _u } // ClearBatchNo clears the value of the "batch_no" field. func (_u *InventoryUpdate) ClearBatchNo() *InventoryUpdate { _u.mutation.ClearBatchNo() return _u } // SetSnCode sets the "sn_code" field. func (_u *InventoryUpdate) SetSnCode(v string) *InventoryUpdate { _u.mutation.SetSnCode(v) return _u } // SetNillableSnCode sets the "sn_code" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableSnCode(v *string) *InventoryUpdate { if v != nil { _u.SetSnCode(*v) } return _u } // ClearSnCode clears the value of the "sn_code" field. func (_u *InventoryUpdate) ClearSnCode() *InventoryUpdate { _u.mutation.ClearSnCode() return _u } // SetQuantity sets the "quantity" field. func (_u *InventoryUpdate) SetQuantity(v int) *InventoryUpdate { _u.mutation.ResetQuantity() _u.mutation.SetQuantity(v) return _u } // SetNillableQuantity sets the "quantity" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableQuantity(v *int) *InventoryUpdate { if v != nil { _u.SetQuantity(*v) } return _u } // AddQuantity adds value to the "quantity" field. func (_u *InventoryUpdate) AddQuantity(v int) *InventoryUpdate { _u.mutation.AddQuantity(v) return _u } // SetLockedQty sets the "locked_qty" field. func (_u *InventoryUpdate) SetLockedQty(v int) *InventoryUpdate { _u.mutation.ResetLockedQty() _u.mutation.SetLockedQty(v) return _u } // SetNillableLockedQty sets the "locked_qty" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableLockedQty(v *int) *InventoryUpdate { if v != nil { _u.SetLockedQty(*v) } return _u } // AddLockedQty adds value to the "locked_qty" field. func (_u *InventoryUpdate) AddLockedQty(v int) *InventoryUpdate { _u.mutation.AddLockedQty(v) return _u } // SetQualityStatus sets the "quality_status" field. func (_u *InventoryUpdate) SetQualityStatus(v string) *InventoryUpdate { _u.mutation.SetQualityStatus(v) return _u } // SetNillableQualityStatus sets the "quality_status" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableQualityStatus(v *string) *InventoryUpdate { if v != nil { _u.SetQualityStatus(*v) } return _u } // SetZoneCode sets the "zone_code" field. func (_u *InventoryUpdate) SetZoneCode(v string) *InventoryUpdate { _u.mutation.SetZoneCode(v) return _u } // SetNillableZoneCode sets the "zone_code" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableZoneCode(v *string) *InventoryUpdate { if v != nil { _u.SetZoneCode(*v) } return _u } // ClearZoneCode clears the value of the "zone_code" field. func (_u *InventoryUpdate) ClearZoneCode() *InventoryUpdate { _u.mutation.ClearZoneCode() return _u } // SetShelfNo sets the "shelf_no" field. func (_u *InventoryUpdate) SetShelfNo(v string) *InventoryUpdate { _u.mutation.SetShelfNo(v) return _u } // SetNillableShelfNo sets the "shelf_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableShelfNo(v *string) *InventoryUpdate { if v != nil { _u.SetShelfNo(*v) } return _u } // ClearShelfNo clears the value of the "shelf_no" field. func (_u *InventoryUpdate) ClearShelfNo() *InventoryUpdate { _u.mutation.ClearShelfNo() return _u } // SetLayerNo sets the "layer_no" field. func (_u *InventoryUpdate) SetLayerNo(v string) *InventoryUpdate { _u.mutation.SetLayerNo(v) return _u } // SetNillableLayerNo sets the "layer_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableLayerNo(v *string) *InventoryUpdate { if v != nil { _u.SetLayerNo(*v) } return _u } // ClearLayerNo clears the value of the "layer_no" field. func (_u *InventoryUpdate) ClearLayerNo() *InventoryUpdate { _u.mutation.ClearLayerNo() return _u } // SetPositionNo sets the "position_no" field. func (_u *InventoryUpdate) SetPositionNo(v string) *InventoryUpdate { _u.mutation.SetPositionNo(v) return _u } // SetNillablePositionNo sets the "position_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillablePositionNo(v *string) *InventoryUpdate { if v != nil { _u.SetPositionNo(*v) } return _u } // ClearPositionNo clears the value of the "position_no" field. func (_u *InventoryUpdate) ClearPositionNo() *InventoryUpdate { _u.mutation.ClearPositionNo() return _u } // SetStatus sets the "status" field. func (_u *InventoryUpdate) SetStatus(v string) *InventoryUpdate { _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableStatus(v *string) *InventoryUpdate { if v != nil { _u.SetStatus(*v) } return _u } // SetProductionDate sets the "production_date" field. func (_u *InventoryUpdate) SetProductionDate(v string) *InventoryUpdate { _u.mutation.SetProductionDate(v) return _u } // SetNillableProductionDate sets the "production_date" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableProductionDate(v *string) *InventoryUpdate { if v != nil { _u.SetProductionDate(*v) } return _u } // ClearProductionDate clears the value of the "production_date" field. func (_u *InventoryUpdate) ClearProductionDate() *InventoryUpdate { _u.mutation.ClearProductionDate() return _u } // SetSupplier sets the "supplier" field. func (_u *InventoryUpdate) SetSupplier(v string) *InventoryUpdate { _u.mutation.SetSupplier(v) return _u } // SetNillableSupplier sets the "supplier" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableSupplier(v *string) *InventoryUpdate { if v != nil { _u.SetSupplier(*v) } return _u } // ClearSupplier clears the value of the "supplier" field. func (_u *InventoryUpdate) ClearSupplier() *InventoryUpdate { _u.mutation.ClearSupplier() return _u } // SetInboundNo sets the "inbound_no" field. func (_u *InventoryUpdate) SetInboundNo(v string) *InventoryUpdate { _u.mutation.SetInboundNo(v) return _u } // SetNillableInboundNo sets the "inbound_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableInboundNo(v *string) *InventoryUpdate { if v != nil { _u.SetInboundNo(*v) } return _u } // ClearInboundNo clears the value of the "inbound_no" field. func (_u *InventoryUpdate) ClearInboundNo() *InventoryUpdate { _u.mutation.ClearInboundNo() return _u } // SetOrderNo sets the "order_no" field. func (_u *InventoryUpdate) SetOrderNo(v string) *InventoryUpdate { _u.mutation.SetOrderNo(v) return _u } // SetNillableOrderNo sets the "order_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableOrderNo(v *string) *InventoryUpdate { if v != nil { _u.SetOrderNo(*v) } return _u } // SetCompletedProcess sets the "completed_process" field. func (_u *InventoryUpdate) SetCompletedProcess(v string) *InventoryUpdate { _u.mutation.SetCompletedProcess(v) return _u } // SetNillableCompletedProcess sets the "completed_process" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableCompletedProcess(v *string) *InventoryUpdate { if v != nil { _u.SetCompletedProcess(*v) } return _u } // SetOwnershipType sets the "ownership_type" field. func (_u *InventoryUpdate) SetOwnershipType(v string) *InventoryUpdate { _u.mutation.SetOwnershipType(v) return _u } // SetNillableOwnershipType sets the "ownership_type" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableOwnershipType(v *string) *InventoryUpdate { if v != nil { _u.SetOwnershipType(*v) } return _u } // ClearOwnershipType clears the value of the "ownership_type" field. func (_u *InventoryUpdate) ClearOwnershipType() *InventoryUpdate { _u.mutation.ClearOwnershipType() return _u } // SetOwnershipNo sets the "ownership_no" field. func (_u *InventoryUpdate) SetOwnershipNo(v string) *InventoryUpdate { _u.mutation.SetOwnershipNo(v) return _u } // SetNillableOwnershipNo sets the "ownership_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableOwnershipNo(v *string) *InventoryUpdate { if v != nil { _u.SetOwnershipNo(*v) } return _u } // ClearOwnershipNo clears the value of the "ownership_no" field. func (_u *InventoryUpdate) ClearOwnershipNo() *InventoryUpdate { _u.mutation.ClearOwnershipNo() return _u } // SetProductStatus sets the "product_status" field. func (_u *InventoryUpdate) SetProductStatus(v string) *InventoryUpdate { _u.mutation.SetProductStatus(v) return _u } // SetNillableProductStatus sets the "product_status" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableProductStatus(v *string) *InventoryUpdate { if v != nil { _u.SetProductStatus(*v) } return _u } // ClearProductStatus clears the value of the "product_status" field. func (_u *InventoryUpdate) ClearProductStatus() *InventoryUpdate { _u.mutation.ClearProductStatus() return _u } // SetRelatedStandard sets the "related_standard" field. func (_u *InventoryUpdate) SetRelatedStandard(v string) *InventoryUpdate { _u.mutation.SetRelatedStandard(v) return _u } // SetNillableRelatedStandard sets the "related_standard" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableRelatedStandard(v *string) *InventoryUpdate { if v != nil { _u.SetRelatedStandard(*v) } return _u } // ClearRelatedStandard clears the value of the "related_standard" field. func (_u *InventoryUpdate) ClearRelatedStandard() *InventoryUpdate { _u.mutation.ClearRelatedStandard() return _u } // SetTestRecordNo sets the "test_record_no" field. func (_u *InventoryUpdate) SetTestRecordNo(v string) *InventoryUpdate { _u.mutation.SetTestRecordNo(v) return _u } // SetNillableTestRecordNo sets the "test_record_no" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableTestRecordNo(v *string) *InventoryUpdate { if v != nil { _u.SetTestRecordNo(*v) } return _u } // ClearTestRecordNo clears the value of the "test_record_no" field. func (_u *InventoryUpdate) ClearTestRecordNo() *InventoryUpdate { _u.mutation.ClearTestRecordNo() return _u } // SetRecordedBy sets the "recorded_by" field. func (_u *InventoryUpdate) SetRecordedBy(v string) *InventoryUpdate { _u.mutation.SetRecordedBy(v) return _u } // SetNillableRecordedBy sets the "recorded_by" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableRecordedBy(v *string) *InventoryUpdate { if v != nil { _u.SetRecordedBy(*v) } return _u } // ClearRecordedBy clears the value of the "recorded_by" field. func (_u *InventoryUpdate) ClearRecordedBy() *InventoryUpdate { _u.mutation.ClearRecordedBy() return _u } // SetRecordedAt sets the "recorded_at" field. func (_u *InventoryUpdate) SetRecordedAt(v int64) *InventoryUpdate { _u.mutation.ResetRecordedAt() _u.mutation.SetRecordedAt(v) return _u } // SetNillableRecordedAt sets the "recorded_at" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableRecordedAt(v *int64) *InventoryUpdate { if v != nil { _u.SetRecordedAt(*v) } return _u } // AddRecordedAt adds value to the "recorded_at" field. func (_u *InventoryUpdate) AddRecordedAt(v int64) *InventoryUpdate { _u.mutation.AddRecordedAt(v) return _u } // ClearRecordedAt clears the value of the "recorded_at" field. func (_u *InventoryUpdate) ClearRecordedAt() *InventoryUpdate { _u.mutation.ClearRecordedAt() return _u } // SetOutboundReason sets the "outbound_reason" field. func (_u *InventoryUpdate) SetOutboundReason(v string) *InventoryUpdate { _u.mutation.SetOutboundReason(v) return _u } // SetNillableOutboundReason sets the "outbound_reason" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableOutboundReason(v *string) *InventoryUpdate { if v != nil { _u.SetOutboundReason(*v) } return _u } // ClearOutboundReason clears the value of the "outbound_reason" field. func (_u *InventoryUpdate) ClearOutboundReason() *InventoryUpdate { _u.mutation.ClearOutboundReason() return _u } // SetRemark sets the "remark" field. func (_u *InventoryUpdate) SetRemark(v string) *InventoryUpdate { _u.mutation.SetRemark(v) return _u } // SetNillableRemark sets the "remark" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableRemark(v *string) *InventoryUpdate { if v != nil { _u.SetRemark(*v) } return _u } // ClearRemark clears the value of the "remark" field. func (_u *InventoryUpdate) ClearRemark() *InventoryUpdate { _u.mutation.ClearRemark() return _u } // SetCreatedAt sets the "created_at" field. func (_u *InventoryUpdate) SetCreatedAt(v int64) *InventoryUpdate { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableCreatedAt(v *int64) *InventoryUpdate { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *InventoryUpdate) AddCreatedAt(v int64) *InventoryUpdate { _u.mutation.AddCreatedAt(v) return _u } // SetUpdatedAt sets the "updated_at" field. func (_u *InventoryUpdate) SetUpdatedAt(v int64) *InventoryUpdate { _u.mutation.ResetUpdatedAt() _u.mutation.SetUpdatedAt(v) return _u } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_u *InventoryUpdate) SetNillableUpdatedAt(v *int64) *InventoryUpdate { if v != nil { _u.SetUpdatedAt(*v) } return _u } // AddUpdatedAt adds value to the "updated_at" field. func (_u *InventoryUpdate) AddUpdatedAt(v int64) *InventoryUpdate { _u.mutation.AddUpdatedAt(v) return _u } // Mutation returns the InventoryMutation object of the builder. func (_u *InventoryUpdate) Mutation() *InventoryMutation { return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *InventoryUpdate) 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 *InventoryUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *InventoryUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *InventoryUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *InventoryUpdate) check() error { if v, ok := _u.mutation.OrderNo(); ok { if err := inventory.OrderNoValidator(v); err != nil { return &ValidationError{Name: "order_no", err: fmt.Errorf(`ent: validator failed for field "Inventory.order_no": %w`, err)} } } if v, ok := _u.mutation.CompletedProcess(); ok { if err := inventory.CompletedProcessValidator(v); err != nil { return &ValidationError{Name: "completed_process", err: fmt.Errorf(`ent: validator failed for field "Inventory.completed_process": %w`, err)} } } return nil } func (_u *InventoryUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(inventory.Table, inventory.Columns, sqlgraph.NewFieldSpec(inventory.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.ManageMode(); ok { _spec.SetField(inventory.FieldManageMode, field.TypeInt, value) } if value, ok := _u.mutation.AddedManageMode(); ok { _spec.AddField(inventory.FieldManageMode, field.TypeInt, value) } if value, ok := _u.mutation.Category(); ok { _spec.SetField(inventory.FieldCategory, field.TypeInt, value) } if value, ok := _u.mutation.AddedCategory(); ok { _spec.AddField(inventory.FieldCategory, field.TypeInt, value) } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(inventory.FieldMaterialCode, field.TypeString, value) } if value, ok := _u.mutation.MaterialName(); ok { _spec.SetField(inventory.FieldMaterialName, field.TypeString, value) } if _u.mutation.MaterialNameCleared() { _spec.ClearField(inventory.FieldMaterialName, field.TypeString) } if value, ok := _u.mutation.BatchNo(); ok { _spec.SetField(inventory.FieldBatchNo, field.TypeString, value) } if _u.mutation.BatchNoCleared() { _spec.ClearField(inventory.FieldBatchNo, field.TypeString) } if value, ok := _u.mutation.SnCode(); ok { _spec.SetField(inventory.FieldSnCode, field.TypeString, value) } if _u.mutation.SnCodeCleared() { _spec.ClearField(inventory.FieldSnCode, field.TypeString) } if value, ok := _u.mutation.Quantity(); ok { _spec.SetField(inventory.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.AddedQuantity(); ok { _spec.AddField(inventory.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.LockedQty(); ok { _spec.SetField(inventory.FieldLockedQty, field.TypeInt, value) } if value, ok := _u.mutation.AddedLockedQty(); ok { _spec.AddField(inventory.FieldLockedQty, field.TypeInt, value) } if value, ok := _u.mutation.QualityStatus(); ok { _spec.SetField(inventory.FieldQualityStatus, field.TypeString, value) } if value, ok := _u.mutation.ZoneCode(); ok { _spec.SetField(inventory.FieldZoneCode, field.TypeString, value) } if _u.mutation.ZoneCodeCleared() { _spec.ClearField(inventory.FieldZoneCode, field.TypeString) } if value, ok := _u.mutation.ShelfNo(); ok { _spec.SetField(inventory.FieldShelfNo, field.TypeString, value) } if _u.mutation.ShelfNoCleared() { _spec.ClearField(inventory.FieldShelfNo, field.TypeString) } if value, ok := _u.mutation.LayerNo(); ok { _spec.SetField(inventory.FieldLayerNo, field.TypeString, value) } if _u.mutation.LayerNoCleared() { _spec.ClearField(inventory.FieldLayerNo, field.TypeString) } if value, ok := _u.mutation.PositionNo(); ok { _spec.SetField(inventory.FieldPositionNo, field.TypeString, value) } if _u.mutation.PositionNoCleared() { _spec.ClearField(inventory.FieldPositionNo, field.TypeString) } if value, ok := _u.mutation.Status(); ok { _spec.SetField(inventory.FieldStatus, field.TypeString, value) } if value, ok := _u.mutation.ProductionDate(); ok { _spec.SetField(inventory.FieldProductionDate, field.TypeString, value) } if _u.mutation.ProductionDateCleared() { _spec.ClearField(inventory.FieldProductionDate, field.TypeString) } if value, ok := _u.mutation.Supplier(); ok { _spec.SetField(inventory.FieldSupplier, field.TypeString, value) } if _u.mutation.SupplierCleared() { _spec.ClearField(inventory.FieldSupplier, field.TypeString) } if value, ok := _u.mutation.InboundNo(); ok { _spec.SetField(inventory.FieldInboundNo, field.TypeString, value) } if _u.mutation.InboundNoCleared() { _spec.ClearField(inventory.FieldInboundNo, field.TypeString) } if value, ok := _u.mutation.OrderNo(); ok { _spec.SetField(inventory.FieldOrderNo, field.TypeString, value) } if value, ok := _u.mutation.CompletedProcess(); ok { _spec.SetField(inventory.FieldCompletedProcess, field.TypeString, value) } if value, ok := _u.mutation.OwnershipType(); ok { _spec.SetField(inventory.FieldOwnershipType, field.TypeString, value) } if _u.mutation.OwnershipTypeCleared() { _spec.ClearField(inventory.FieldOwnershipType, field.TypeString) } if value, ok := _u.mutation.OwnershipNo(); ok { _spec.SetField(inventory.FieldOwnershipNo, field.TypeString, value) } if _u.mutation.OwnershipNoCleared() { _spec.ClearField(inventory.FieldOwnershipNo, field.TypeString) } if value, ok := _u.mutation.ProductStatus(); ok { _spec.SetField(inventory.FieldProductStatus, field.TypeString, value) } if _u.mutation.ProductStatusCleared() { _spec.ClearField(inventory.FieldProductStatus, field.TypeString) } if value, ok := _u.mutation.RelatedStandard(); ok { _spec.SetField(inventory.FieldRelatedStandard, field.TypeString, value) } if _u.mutation.RelatedStandardCleared() { _spec.ClearField(inventory.FieldRelatedStandard, field.TypeString) } if value, ok := _u.mutation.TestRecordNo(); ok { _spec.SetField(inventory.FieldTestRecordNo, field.TypeString, value) } if _u.mutation.TestRecordNoCleared() { _spec.ClearField(inventory.FieldTestRecordNo, field.TypeString) } if value, ok := _u.mutation.RecordedBy(); ok { _spec.SetField(inventory.FieldRecordedBy, field.TypeString, value) } if _u.mutation.RecordedByCleared() { _spec.ClearField(inventory.FieldRecordedBy, field.TypeString) } if value, ok := _u.mutation.RecordedAt(); ok { _spec.SetField(inventory.FieldRecordedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedRecordedAt(); ok { _spec.AddField(inventory.FieldRecordedAt, field.TypeInt64, value) } if _u.mutation.RecordedAtCleared() { _spec.ClearField(inventory.FieldRecordedAt, field.TypeInt64) } if value, ok := _u.mutation.OutboundReason(); ok { _spec.SetField(inventory.FieldOutboundReason, field.TypeString, value) } if _u.mutation.OutboundReasonCleared() { _spec.ClearField(inventory.FieldOutboundReason, field.TypeString) } if value, ok := _u.mutation.Remark(); ok { _spec.SetField(inventory.FieldRemark, field.TypeString, value) } if _u.mutation.RemarkCleared() { _spec.ClearField(inventory.FieldRemark, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(inventory.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(inventory.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(inventory.FieldUpdatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedUpdatedAt(); ok { _spec.AddField(inventory.FieldUpdatedAt, field.TypeInt64, value) } if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{inventory.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // InventoryUpdateOne is the builder for updating a single Inventory entity. type InventoryUpdateOne struct { config fields []string hooks []Hook mutation *InventoryMutation } // SetManageMode sets the "manage_mode" field. func (_u *InventoryUpdateOne) SetManageMode(v int) *InventoryUpdateOne { _u.mutation.ResetManageMode() _u.mutation.SetManageMode(v) return _u } // SetNillableManageMode sets the "manage_mode" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableManageMode(v *int) *InventoryUpdateOne { if v != nil { _u.SetManageMode(*v) } return _u } // AddManageMode adds value to the "manage_mode" field. func (_u *InventoryUpdateOne) AddManageMode(v int) *InventoryUpdateOne { _u.mutation.AddManageMode(v) return _u } // SetCategory sets the "category" field. func (_u *InventoryUpdateOne) SetCategory(v int) *InventoryUpdateOne { _u.mutation.ResetCategory() _u.mutation.SetCategory(v) return _u } // SetNillableCategory sets the "category" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableCategory(v *int) *InventoryUpdateOne { if v != nil { _u.SetCategory(*v) } return _u } // AddCategory adds value to the "category" field. func (_u *InventoryUpdateOne) AddCategory(v int) *InventoryUpdateOne { _u.mutation.AddCategory(v) return _u } // SetMaterialCode sets the "material_code" field. func (_u *InventoryUpdateOne) SetMaterialCode(v string) *InventoryUpdateOne { _u.mutation.SetMaterialCode(v) return _u } // SetNillableMaterialCode sets the "material_code" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableMaterialCode(v *string) *InventoryUpdateOne { if v != nil { _u.SetMaterialCode(*v) } return _u } // SetMaterialName sets the "material_name" field. func (_u *InventoryUpdateOne) SetMaterialName(v string) *InventoryUpdateOne { _u.mutation.SetMaterialName(v) return _u } // SetNillableMaterialName sets the "material_name" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableMaterialName(v *string) *InventoryUpdateOne { if v != nil { _u.SetMaterialName(*v) } return _u } // ClearMaterialName clears the value of the "material_name" field. func (_u *InventoryUpdateOne) ClearMaterialName() *InventoryUpdateOne { _u.mutation.ClearMaterialName() return _u } // SetBatchNo sets the "batch_no" field. func (_u *InventoryUpdateOne) SetBatchNo(v string) *InventoryUpdateOne { _u.mutation.SetBatchNo(v) return _u } // SetNillableBatchNo sets the "batch_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableBatchNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetBatchNo(*v) } return _u } // ClearBatchNo clears the value of the "batch_no" field. func (_u *InventoryUpdateOne) ClearBatchNo() *InventoryUpdateOne { _u.mutation.ClearBatchNo() return _u } // SetSnCode sets the "sn_code" field. func (_u *InventoryUpdateOne) SetSnCode(v string) *InventoryUpdateOne { _u.mutation.SetSnCode(v) return _u } // SetNillableSnCode sets the "sn_code" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableSnCode(v *string) *InventoryUpdateOne { if v != nil { _u.SetSnCode(*v) } return _u } // ClearSnCode clears the value of the "sn_code" field. func (_u *InventoryUpdateOne) ClearSnCode() *InventoryUpdateOne { _u.mutation.ClearSnCode() return _u } // SetQuantity sets the "quantity" field. func (_u *InventoryUpdateOne) SetQuantity(v int) *InventoryUpdateOne { _u.mutation.ResetQuantity() _u.mutation.SetQuantity(v) return _u } // SetNillableQuantity sets the "quantity" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableQuantity(v *int) *InventoryUpdateOne { if v != nil { _u.SetQuantity(*v) } return _u } // AddQuantity adds value to the "quantity" field. func (_u *InventoryUpdateOne) AddQuantity(v int) *InventoryUpdateOne { _u.mutation.AddQuantity(v) return _u } // SetLockedQty sets the "locked_qty" field. func (_u *InventoryUpdateOne) SetLockedQty(v int) *InventoryUpdateOne { _u.mutation.ResetLockedQty() _u.mutation.SetLockedQty(v) return _u } // SetNillableLockedQty sets the "locked_qty" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableLockedQty(v *int) *InventoryUpdateOne { if v != nil { _u.SetLockedQty(*v) } return _u } // AddLockedQty adds value to the "locked_qty" field. func (_u *InventoryUpdateOne) AddLockedQty(v int) *InventoryUpdateOne { _u.mutation.AddLockedQty(v) return _u } // SetQualityStatus sets the "quality_status" field. func (_u *InventoryUpdateOne) SetQualityStatus(v string) *InventoryUpdateOne { _u.mutation.SetQualityStatus(v) return _u } // SetNillableQualityStatus sets the "quality_status" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableQualityStatus(v *string) *InventoryUpdateOne { if v != nil { _u.SetQualityStatus(*v) } return _u } // SetZoneCode sets the "zone_code" field. func (_u *InventoryUpdateOne) SetZoneCode(v string) *InventoryUpdateOne { _u.mutation.SetZoneCode(v) return _u } // SetNillableZoneCode sets the "zone_code" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableZoneCode(v *string) *InventoryUpdateOne { if v != nil { _u.SetZoneCode(*v) } return _u } // ClearZoneCode clears the value of the "zone_code" field. func (_u *InventoryUpdateOne) ClearZoneCode() *InventoryUpdateOne { _u.mutation.ClearZoneCode() return _u } // SetShelfNo sets the "shelf_no" field. func (_u *InventoryUpdateOne) SetShelfNo(v string) *InventoryUpdateOne { _u.mutation.SetShelfNo(v) return _u } // SetNillableShelfNo sets the "shelf_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableShelfNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetShelfNo(*v) } return _u } // ClearShelfNo clears the value of the "shelf_no" field. func (_u *InventoryUpdateOne) ClearShelfNo() *InventoryUpdateOne { _u.mutation.ClearShelfNo() return _u } // SetLayerNo sets the "layer_no" field. func (_u *InventoryUpdateOne) SetLayerNo(v string) *InventoryUpdateOne { _u.mutation.SetLayerNo(v) return _u } // SetNillableLayerNo sets the "layer_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableLayerNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetLayerNo(*v) } return _u } // ClearLayerNo clears the value of the "layer_no" field. func (_u *InventoryUpdateOne) ClearLayerNo() *InventoryUpdateOne { _u.mutation.ClearLayerNo() return _u } // SetPositionNo sets the "position_no" field. func (_u *InventoryUpdateOne) SetPositionNo(v string) *InventoryUpdateOne { _u.mutation.SetPositionNo(v) return _u } // SetNillablePositionNo sets the "position_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillablePositionNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetPositionNo(*v) } return _u } // ClearPositionNo clears the value of the "position_no" field. func (_u *InventoryUpdateOne) ClearPositionNo() *InventoryUpdateOne { _u.mutation.ClearPositionNo() return _u } // SetStatus sets the "status" field. func (_u *InventoryUpdateOne) SetStatus(v string) *InventoryUpdateOne { _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableStatus(v *string) *InventoryUpdateOne { if v != nil { _u.SetStatus(*v) } return _u } // SetProductionDate sets the "production_date" field. func (_u *InventoryUpdateOne) SetProductionDate(v string) *InventoryUpdateOne { _u.mutation.SetProductionDate(v) return _u } // SetNillableProductionDate sets the "production_date" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableProductionDate(v *string) *InventoryUpdateOne { if v != nil { _u.SetProductionDate(*v) } return _u } // ClearProductionDate clears the value of the "production_date" field. func (_u *InventoryUpdateOne) ClearProductionDate() *InventoryUpdateOne { _u.mutation.ClearProductionDate() return _u } // SetSupplier sets the "supplier" field. func (_u *InventoryUpdateOne) SetSupplier(v string) *InventoryUpdateOne { _u.mutation.SetSupplier(v) return _u } // SetNillableSupplier sets the "supplier" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableSupplier(v *string) *InventoryUpdateOne { if v != nil { _u.SetSupplier(*v) } return _u } // ClearSupplier clears the value of the "supplier" field. func (_u *InventoryUpdateOne) ClearSupplier() *InventoryUpdateOne { _u.mutation.ClearSupplier() return _u } // SetInboundNo sets the "inbound_no" field. func (_u *InventoryUpdateOne) SetInboundNo(v string) *InventoryUpdateOne { _u.mutation.SetInboundNo(v) return _u } // SetNillableInboundNo sets the "inbound_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableInboundNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetInboundNo(*v) } return _u } // ClearInboundNo clears the value of the "inbound_no" field. func (_u *InventoryUpdateOne) ClearInboundNo() *InventoryUpdateOne { _u.mutation.ClearInboundNo() return _u } // SetOrderNo sets the "order_no" field. func (_u *InventoryUpdateOne) SetOrderNo(v string) *InventoryUpdateOne { _u.mutation.SetOrderNo(v) return _u } // SetNillableOrderNo sets the "order_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableOrderNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetOrderNo(*v) } return _u } // SetCompletedProcess sets the "completed_process" field. func (_u *InventoryUpdateOne) SetCompletedProcess(v string) *InventoryUpdateOne { _u.mutation.SetCompletedProcess(v) return _u } // SetNillableCompletedProcess sets the "completed_process" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableCompletedProcess(v *string) *InventoryUpdateOne { if v != nil { _u.SetCompletedProcess(*v) } return _u } // SetOwnershipType sets the "ownership_type" field. func (_u *InventoryUpdateOne) SetOwnershipType(v string) *InventoryUpdateOne { _u.mutation.SetOwnershipType(v) return _u } // SetNillableOwnershipType sets the "ownership_type" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableOwnershipType(v *string) *InventoryUpdateOne { if v != nil { _u.SetOwnershipType(*v) } return _u } // ClearOwnershipType clears the value of the "ownership_type" field. func (_u *InventoryUpdateOne) ClearOwnershipType() *InventoryUpdateOne { _u.mutation.ClearOwnershipType() return _u } // SetOwnershipNo sets the "ownership_no" field. func (_u *InventoryUpdateOne) SetOwnershipNo(v string) *InventoryUpdateOne { _u.mutation.SetOwnershipNo(v) return _u } // SetNillableOwnershipNo sets the "ownership_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableOwnershipNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetOwnershipNo(*v) } return _u } // ClearOwnershipNo clears the value of the "ownership_no" field. func (_u *InventoryUpdateOne) ClearOwnershipNo() *InventoryUpdateOne { _u.mutation.ClearOwnershipNo() return _u } // SetProductStatus sets the "product_status" field. func (_u *InventoryUpdateOne) SetProductStatus(v string) *InventoryUpdateOne { _u.mutation.SetProductStatus(v) return _u } // SetNillableProductStatus sets the "product_status" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableProductStatus(v *string) *InventoryUpdateOne { if v != nil { _u.SetProductStatus(*v) } return _u } // ClearProductStatus clears the value of the "product_status" field. func (_u *InventoryUpdateOne) ClearProductStatus() *InventoryUpdateOne { _u.mutation.ClearProductStatus() return _u } // SetRelatedStandard sets the "related_standard" field. func (_u *InventoryUpdateOne) SetRelatedStandard(v string) *InventoryUpdateOne { _u.mutation.SetRelatedStandard(v) return _u } // SetNillableRelatedStandard sets the "related_standard" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableRelatedStandard(v *string) *InventoryUpdateOne { if v != nil { _u.SetRelatedStandard(*v) } return _u } // ClearRelatedStandard clears the value of the "related_standard" field. func (_u *InventoryUpdateOne) ClearRelatedStandard() *InventoryUpdateOne { _u.mutation.ClearRelatedStandard() return _u } // SetTestRecordNo sets the "test_record_no" field. func (_u *InventoryUpdateOne) SetTestRecordNo(v string) *InventoryUpdateOne { _u.mutation.SetTestRecordNo(v) return _u } // SetNillableTestRecordNo sets the "test_record_no" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableTestRecordNo(v *string) *InventoryUpdateOne { if v != nil { _u.SetTestRecordNo(*v) } return _u } // ClearTestRecordNo clears the value of the "test_record_no" field. func (_u *InventoryUpdateOne) ClearTestRecordNo() *InventoryUpdateOne { _u.mutation.ClearTestRecordNo() return _u } // SetRecordedBy sets the "recorded_by" field. func (_u *InventoryUpdateOne) SetRecordedBy(v string) *InventoryUpdateOne { _u.mutation.SetRecordedBy(v) return _u } // SetNillableRecordedBy sets the "recorded_by" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableRecordedBy(v *string) *InventoryUpdateOne { if v != nil { _u.SetRecordedBy(*v) } return _u } // ClearRecordedBy clears the value of the "recorded_by" field. func (_u *InventoryUpdateOne) ClearRecordedBy() *InventoryUpdateOne { _u.mutation.ClearRecordedBy() return _u } // SetRecordedAt sets the "recorded_at" field. func (_u *InventoryUpdateOne) SetRecordedAt(v int64) *InventoryUpdateOne { _u.mutation.ResetRecordedAt() _u.mutation.SetRecordedAt(v) return _u } // SetNillableRecordedAt sets the "recorded_at" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableRecordedAt(v *int64) *InventoryUpdateOne { if v != nil { _u.SetRecordedAt(*v) } return _u } // AddRecordedAt adds value to the "recorded_at" field. func (_u *InventoryUpdateOne) AddRecordedAt(v int64) *InventoryUpdateOne { _u.mutation.AddRecordedAt(v) return _u } // ClearRecordedAt clears the value of the "recorded_at" field. func (_u *InventoryUpdateOne) ClearRecordedAt() *InventoryUpdateOne { _u.mutation.ClearRecordedAt() return _u } // SetOutboundReason sets the "outbound_reason" field. func (_u *InventoryUpdateOne) SetOutboundReason(v string) *InventoryUpdateOne { _u.mutation.SetOutboundReason(v) return _u } // SetNillableOutboundReason sets the "outbound_reason" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableOutboundReason(v *string) *InventoryUpdateOne { if v != nil { _u.SetOutboundReason(*v) } return _u } // ClearOutboundReason clears the value of the "outbound_reason" field. func (_u *InventoryUpdateOne) ClearOutboundReason() *InventoryUpdateOne { _u.mutation.ClearOutboundReason() return _u } // SetRemark sets the "remark" field. func (_u *InventoryUpdateOne) SetRemark(v string) *InventoryUpdateOne { _u.mutation.SetRemark(v) return _u } // SetNillableRemark sets the "remark" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableRemark(v *string) *InventoryUpdateOne { if v != nil { _u.SetRemark(*v) } return _u } // ClearRemark clears the value of the "remark" field. func (_u *InventoryUpdateOne) ClearRemark() *InventoryUpdateOne { _u.mutation.ClearRemark() return _u } // SetCreatedAt sets the "created_at" field. func (_u *InventoryUpdateOne) SetCreatedAt(v int64) *InventoryUpdateOne { _u.mutation.ResetCreatedAt() _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableCreatedAt(v *int64) *InventoryUpdateOne { if v != nil { _u.SetCreatedAt(*v) } return _u } // AddCreatedAt adds value to the "created_at" field. func (_u *InventoryUpdateOne) AddCreatedAt(v int64) *InventoryUpdateOne { _u.mutation.AddCreatedAt(v) return _u } // SetUpdatedAt sets the "updated_at" field. func (_u *InventoryUpdateOne) SetUpdatedAt(v int64) *InventoryUpdateOne { _u.mutation.ResetUpdatedAt() _u.mutation.SetUpdatedAt(v) return _u } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_u *InventoryUpdateOne) SetNillableUpdatedAt(v *int64) *InventoryUpdateOne { if v != nil { _u.SetUpdatedAt(*v) } return _u } // AddUpdatedAt adds value to the "updated_at" field. func (_u *InventoryUpdateOne) AddUpdatedAt(v int64) *InventoryUpdateOne { _u.mutation.AddUpdatedAt(v) return _u } // Mutation returns the InventoryMutation object of the builder. func (_u *InventoryUpdateOne) Mutation() *InventoryMutation { return _u.mutation } // Where appends a list predicates to the InventoryUpdate builder. func (_u *InventoryUpdateOne) Where(ps ...predicate.Inventory) *InventoryUpdateOne { _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 *InventoryUpdateOne) Select(field string, fields ...string) *InventoryUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated Inventory entity. func (_u *InventoryUpdateOne) Save(ctx context.Context) (*Inventory, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *InventoryUpdateOne) SaveX(ctx context.Context) *Inventory { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *InventoryUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *InventoryUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *InventoryUpdateOne) check() error { if v, ok := _u.mutation.OrderNo(); ok { if err := inventory.OrderNoValidator(v); err != nil { return &ValidationError{Name: "order_no", err: fmt.Errorf(`ent: validator failed for field "Inventory.order_no": %w`, err)} } } if v, ok := _u.mutation.CompletedProcess(); ok { if err := inventory.CompletedProcessValidator(v); err != nil { return &ValidationError{Name: "completed_process", err: fmt.Errorf(`ent: validator failed for field "Inventory.completed_process": %w`, err)} } } return nil } func (_u *InventoryUpdateOne) sqlSave(ctx context.Context) (_node *Inventory, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(inventory.Table, inventory.Columns, sqlgraph.NewFieldSpec(inventory.FieldID, field.TypeInt)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Inventory.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, inventory.FieldID) for _, f := range fields { if !inventory.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != inventory.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.ManageMode(); ok { _spec.SetField(inventory.FieldManageMode, field.TypeInt, value) } if value, ok := _u.mutation.AddedManageMode(); ok { _spec.AddField(inventory.FieldManageMode, field.TypeInt, value) } if value, ok := _u.mutation.Category(); ok { _spec.SetField(inventory.FieldCategory, field.TypeInt, value) } if value, ok := _u.mutation.AddedCategory(); ok { _spec.AddField(inventory.FieldCategory, field.TypeInt, value) } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(inventory.FieldMaterialCode, field.TypeString, value) } if value, ok := _u.mutation.MaterialName(); ok { _spec.SetField(inventory.FieldMaterialName, field.TypeString, value) } if _u.mutation.MaterialNameCleared() { _spec.ClearField(inventory.FieldMaterialName, field.TypeString) } if value, ok := _u.mutation.BatchNo(); ok { _spec.SetField(inventory.FieldBatchNo, field.TypeString, value) } if _u.mutation.BatchNoCleared() { _spec.ClearField(inventory.FieldBatchNo, field.TypeString) } if value, ok := _u.mutation.SnCode(); ok { _spec.SetField(inventory.FieldSnCode, field.TypeString, value) } if _u.mutation.SnCodeCleared() { _spec.ClearField(inventory.FieldSnCode, field.TypeString) } if value, ok := _u.mutation.Quantity(); ok { _spec.SetField(inventory.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.AddedQuantity(); ok { _spec.AddField(inventory.FieldQuantity, field.TypeInt, value) } if value, ok := _u.mutation.LockedQty(); ok { _spec.SetField(inventory.FieldLockedQty, field.TypeInt, value) } if value, ok := _u.mutation.AddedLockedQty(); ok { _spec.AddField(inventory.FieldLockedQty, field.TypeInt, value) } if value, ok := _u.mutation.QualityStatus(); ok { _spec.SetField(inventory.FieldQualityStatus, field.TypeString, value) } if value, ok := _u.mutation.ZoneCode(); ok { _spec.SetField(inventory.FieldZoneCode, field.TypeString, value) } if _u.mutation.ZoneCodeCleared() { _spec.ClearField(inventory.FieldZoneCode, field.TypeString) } if value, ok := _u.mutation.ShelfNo(); ok { _spec.SetField(inventory.FieldShelfNo, field.TypeString, value) } if _u.mutation.ShelfNoCleared() { _spec.ClearField(inventory.FieldShelfNo, field.TypeString) } if value, ok := _u.mutation.LayerNo(); ok { _spec.SetField(inventory.FieldLayerNo, field.TypeString, value) } if _u.mutation.LayerNoCleared() { _spec.ClearField(inventory.FieldLayerNo, field.TypeString) } if value, ok := _u.mutation.PositionNo(); ok { _spec.SetField(inventory.FieldPositionNo, field.TypeString, value) } if _u.mutation.PositionNoCleared() { _spec.ClearField(inventory.FieldPositionNo, field.TypeString) } if value, ok := _u.mutation.Status(); ok { _spec.SetField(inventory.FieldStatus, field.TypeString, value) } if value, ok := _u.mutation.ProductionDate(); ok { _spec.SetField(inventory.FieldProductionDate, field.TypeString, value) } if _u.mutation.ProductionDateCleared() { _spec.ClearField(inventory.FieldProductionDate, field.TypeString) } if value, ok := _u.mutation.Supplier(); ok { _spec.SetField(inventory.FieldSupplier, field.TypeString, value) } if _u.mutation.SupplierCleared() { _spec.ClearField(inventory.FieldSupplier, field.TypeString) } if value, ok := _u.mutation.InboundNo(); ok { _spec.SetField(inventory.FieldInboundNo, field.TypeString, value) } if _u.mutation.InboundNoCleared() { _spec.ClearField(inventory.FieldInboundNo, field.TypeString) } if value, ok := _u.mutation.OrderNo(); ok { _spec.SetField(inventory.FieldOrderNo, field.TypeString, value) } if value, ok := _u.mutation.CompletedProcess(); ok { _spec.SetField(inventory.FieldCompletedProcess, field.TypeString, value) } if value, ok := _u.mutation.OwnershipType(); ok { _spec.SetField(inventory.FieldOwnershipType, field.TypeString, value) } if _u.mutation.OwnershipTypeCleared() { _spec.ClearField(inventory.FieldOwnershipType, field.TypeString) } if value, ok := _u.mutation.OwnershipNo(); ok { _spec.SetField(inventory.FieldOwnershipNo, field.TypeString, value) } if _u.mutation.OwnershipNoCleared() { _spec.ClearField(inventory.FieldOwnershipNo, field.TypeString) } if value, ok := _u.mutation.ProductStatus(); ok { _spec.SetField(inventory.FieldProductStatus, field.TypeString, value) } if _u.mutation.ProductStatusCleared() { _spec.ClearField(inventory.FieldProductStatus, field.TypeString) } if value, ok := _u.mutation.RelatedStandard(); ok { _spec.SetField(inventory.FieldRelatedStandard, field.TypeString, value) } if _u.mutation.RelatedStandardCleared() { _spec.ClearField(inventory.FieldRelatedStandard, field.TypeString) } if value, ok := _u.mutation.TestRecordNo(); ok { _spec.SetField(inventory.FieldTestRecordNo, field.TypeString, value) } if _u.mutation.TestRecordNoCleared() { _spec.ClearField(inventory.FieldTestRecordNo, field.TypeString) } if value, ok := _u.mutation.RecordedBy(); ok { _spec.SetField(inventory.FieldRecordedBy, field.TypeString, value) } if _u.mutation.RecordedByCleared() { _spec.ClearField(inventory.FieldRecordedBy, field.TypeString) } if value, ok := _u.mutation.RecordedAt(); ok { _spec.SetField(inventory.FieldRecordedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedRecordedAt(); ok { _spec.AddField(inventory.FieldRecordedAt, field.TypeInt64, value) } if _u.mutation.RecordedAtCleared() { _spec.ClearField(inventory.FieldRecordedAt, field.TypeInt64) } if value, ok := _u.mutation.OutboundReason(); ok { _spec.SetField(inventory.FieldOutboundReason, field.TypeString, value) } if _u.mutation.OutboundReasonCleared() { _spec.ClearField(inventory.FieldOutboundReason, field.TypeString) } if value, ok := _u.mutation.Remark(); ok { _spec.SetField(inventory.FieldRemark, field.TypeString, value) } if _u.mutation.RemarkCleared() { _spec.ClearField(inventory.FieldRemark, field.TypeString) } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(inventory.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedCreatedAt(); ok { _spec.AddField(inventory.FieldCreatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(inventory.FieldUpdatedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedUpdatedAt(); ok { _spec.AddField(inventory.FieldUpdatedAt, field.TypeInt64, value) } _node = &Inventory{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{inventory.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }