- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE - WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置 - WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页 - 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面 - Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理 - 清理各项目球形磨遗留代码,新增部署手册.md
754 lines
23 KiB
Go
754 lines
23 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/inventorybatch"
|
|
"bj_power_wms/ent/predicate"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// InventoryBatchUpdate is the builder for updating InventoryBatch entities.
|
|
type InventoryBatchUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *InventoryBatchMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the InventoryBatchUpdate builder.
|
|
func (_u *InventoryBatchUpdate) Where(ps ...predicate.InventoryBatch) *InventoryBatchUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetBatchNo sets the "batch_no" field.
|
|
func (_u *InventoryBatchUpdate) SetBatchNo(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetBatchNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableBatchNo(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetBatchNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *InventoryBatchUpdate) SetMaterialCode(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableMaterialCode(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "material_name" field.
|
|
func (_u *InventoryBatchUpdate) SetMaterialName(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "material_name" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableMaterialName(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialName clears the value of the "material_name" field.
|
|
func (_u *InventoryBatchUpdate) ClearMaterialName() *InventoryBatchUpdate {
|
|
_u.mutation.ClearMaterialName()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *InventoryBatchUpdate) SetQuantity(v int) *InventoryBatchUpdate {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableQuantity(v *int) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *InventoryBatchUpdate) AddQuantity(v int) *InventoryBatchUpdate {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLockedQty sets the "locked_qty" field.
|
|
func (_u *InventoryBatchUpdate) SetLockedQty(v int) *InventoryBatchUpdate {
|
|
_u.mutation.ResetLockedQty()
|
|
_u.mutation.SetLockedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLockedQty sets the "locked_qty" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableLockedQty(v *int) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetLockedQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLockedQty adds value to the "locked_qty" field.
|
|
func (_u *InventoryBatchUpdate) AddLockedQty(v int) *InventoryBatchUpdate {
|
|
_u.mutation.AddLockedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetProductionDate sets the "production_date" field.
|
|
func (_u *InventoryBatchUpdate) SetProductionDate(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetProductionDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductionDate sets the "production_date" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableProductionDate(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetProductionDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearProductionDate clears the value of the "production_date" field.
|
|
func (_u *InventoryBatchUpdate) ClearProductionDate() *InventoryBatchUpdate {
|
|
_u.mutation.ClearProductionDate()
|
|
return _u
|
|
}
|
|
|
|
// SetSupplier sets the "supplier" field.
|
|
func (_u *InventoryBatchUpdate) SetSupplier(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetSupplier(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSupplier sets the "supplier" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableSupplier(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetSupplier(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSupplier clears the value of the "supplier" field.
|
|
func (_u *InventoryBatchUpdate) ClearSupplier() *InventoryBatchUpdate {
|
|
_u.mutation.ClearSupplier()
|
|
return _u
|
|
}
|
|
|
|
// SetQualityStatus sets the "quality_status" field.
|
|
func (_u *InventoryBatchUpdate) SetQualityStatus(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetQualityStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQualityStatus sets the "quality_status" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableQualityStatus(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetQualityStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *InventoryBatchUpdate) SetZoneCode(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableZoneCode(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *InventoryBatchUpdate) ClearZoneCode() *InventoryBatchUpdate {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *InventoryBatchUpdate) SetRemark(v string) *InventoryBatchUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableRemark(v *string) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *InventoryBatchUpdate) ClearRemark() *InventoryBatchUpdate {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *InventoryBatchUpdate) SetCreatedAt(v int64) *InventoryBatchUpdate {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableCreatedAt(v *int64) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *InventoryBatchUpdate) AddCreatedAt(v int64) *InventoryBatchUpdate {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *InventoryBatchUpdate) SetUpdatedAt(v int64) *InventoryBatchUpdate {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdate) SetNillableUpdatedAt(v *int64) *InventoryBatchUpdate {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *InventoryBatchUpdate) AddUpdatedAt(v int64) *InventoryBatchUpdate {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the InventoryBatchMutation object of the builder.
|
|
func (_u *InventoryBatchUpdate) Mutation() *InventoryBatchMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *InventoryBatchUpdate) 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 *InventoryBatchUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *InventoryBatchUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *InventoryBatchUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *InventoryBatchUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(inventorybatch.Table, inventorybatch.Columns, sqlgraph.NewFieldSpec(inventorybatch.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.BatchNo(); ok {
|
|
_spec.SetField(inventorybatch.FieldBatchNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(inventorybatch.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(inventorybatch.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialNameCleared() {
|
|
_spec.ClearField(inventorybatch.FieldMaterialName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(inventorybatch.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(inventorybatch.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.LockedQty(); ok {
|
|
_spec.SetField(inventorybatch.FieldLockedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLockedQty(); ok {
|
|
_spec.AddField(inventorybatch.FieldLockedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ProductionDate(); ok {
|
|
_spec.SetField(inventorybatch.FieldProductionDate, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ProductionDateCleared() {
|
|
_spec.ClearField(inventorybatch.FieldProductionDate, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Supplier(); ok {
|
|
_spec.SetField(inventorybatch.FieldSupplier, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SupplierCleared() {
|
|
_spec.ClearField(inventorybatch.FieldSupplier, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.QualityStatus(); ok {
|
|
_spec.SetField(inventorybatch.FieldQualityStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(inventorybatch.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(inventorybatch.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(inventorybatch.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(inventorybatch.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(inventorybatch.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(inventorybatch.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(inventorybatch.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(inventorybatch.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{inventorybatch.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// InventoryBatchUpdateOne is the builder for updating a single InventoryBatch entity.
|
|
type InventoryBatchUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *InventoryBatchMutation
|
|
}
|
|
|
|
// SetBatchNo sets the "batch_no" field.
|
|
func (_u *InventoryBatchUpdateOne) SetBatchNo(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetBatchNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableBatchNo(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetBatchNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *InventoryBatchUpdateOne) SetMaterialCode(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableMaterialCode(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "material_name" field.
|
|
func (_u *InventoryBatchUpdateOne) SetMaterialName(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "material_name" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableMaterialName(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialName clears the value of the "material_name" field.
|
|
func (_u *InventoryBatchUpdateOne) ClearMaterialName() *InventoryBatchUpdateOne {
|
|
_u.mutation.ClearMaterialName()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *InventoryBatchUpdateOne) SetQuantity(v int) *InventoryBatchUpdateOne {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableQuantity(v *int) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *InventoryBatchUpdateOne) AddQuantity(v int) *InventoryBatchUpdateOne {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLockedQty sets the "locked_qty" field.
|
|
func (_u *InventoryBatchUpdateOne) SetLockedQty(v int) *InventoryBatchUpdateOne {
|
|
_u.mutation.ResetLockedQty()
|
|
_u.mutation.SetLockedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLockedQty sets the "locked_qty" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableLockedQty(v *int) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetLockedQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLockedQty adds value to the "locked_qty" field.
|
|
func (_u *InventoryBatchUpdateOne) AddLockedQty(v int) *InventoryBatchUpdateOne {
|
|
_u.mutation.AddLockedQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetProductionDate sets the "production_date" field.
|
|
func (_u *InventoryBatchUpdateOne) SetProductionDate(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetProductionDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductionDate sets the "production_date" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableProductionDate(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetProductionDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearProductionDate clears the value of the "production_date" field.
|
|
func (_u *InventoryBatchUpdateOne) ClearProductionDate() *InventoryBatchUpdateOne {
|
|
_u.mutation.ClearProductionDate()
|
|
return _u
|
|
}
|
|
|
|
// SetSupplier sets the "supplier" field.
|
|
func (_u *InventoryBatchUpdateOne) SetSupplier(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetSupplier(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSupplier sets the "supplier" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableSupplier(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetSupplier(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSupplier clears the value of the "supplier" field.
|
|
func (_u *InventoryBatchUpdateOne) ClearSupplier() *InventoryBatchUpdateOne {
|
|
_u.mutation.ClearSupplier()
|
|
return _u
|
|
}
|
|
|
|
// SetQualityStatus sets the "quality_status" field.
|
|
func (_u *InventoryBatchUpdateOne) SetQualityStatus(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetQualityStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQualityStatus sets the "quality_status" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableQualityStatus(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetQualityStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *InventoryBatchUpdateOne) SetZoneCode(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableZoneCode(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *InventoryBatchUpdateOne) ClearZoneCode() *InventoryBatchUpdateOne {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *InventoryBatchUpdateOne) SetRemark(v string) *InventoryBatchUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableRemark(v *string) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *InventoryBatchUpdateOne) ClearRemark() *InventoryBatchUpdateOne {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *InventoryBatchUpdateOne) SetCreatedAt(v int64) *InventoryBatchUpdateOne {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableCreatedAt(v *int64) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *InventoryBatchUpdateOne) AddCreatedAt(v int64) *InventoryBatchUpdateOne {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *InventoryBatchUpdateOne) SetUpdatedAt(v int64) *InventoryBatchUpdateOne {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *InventoryBatchUpdateOne) SetNillableUpdatedAt(v *int64) *InventoryBatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *InventoryBatchUpdateOne) AddUpdatedAt(v int64) *InventoryBatchUpdateOne {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the InventoryBatchMutation object of the builder.
|
|
func (_u *InventoryBatchUpdateOne) Mutation() *InventoryBatchMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the InventoryBatchUpdate builder.
|
|
func (_u *InventoryBatchUpdateOne) Where(ps ...predicate.InventoryBatch) *InventoryBatchUpdateOne {
|
|
_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 *InventoryBatchUpdateOne) Select(field string, fields ...string) *InventoryBatchUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated InventoryBatch entity.
|
|
func (_u *InventoryBatchUpdateOne) Save(ctx context.Context) (*InventoryBatch, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *InventoryBatchUpdateOne) SaveX(ctx context.Context) *InventoryBatch {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *InventoryBatchUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *InventoryBatchUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *InventoryBatchUpdateOne) sqlSave(ctx context.Context) (_node *InventoryBatch, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(inventorybatch.Table, inventorybatch.Columns, sqlgraph.NewFieldSpec(inventorybatch.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "InventoryBatch.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, inventorybatch.FieldID)
|
|
for _, f := range fields {
|
|
if !inventorybatch.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != inventorybatch.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.BatchNo(); ok {
|
|
_spec.SetField(inventorybatch.FieldBatchNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(inventorybatch.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(inventorybatch.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialNameCleared() {
|
|
_spec.ClearField(inventorybatch.FieldMaterialName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(inventorybatch.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(inventorybatch.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.LockedQty(); ok {
|
|
_spec.SetField(inventorybatch.FieldLockedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLockedQty(); ok {
|
|
_spec.AddField(inventorybatch.FieldLockedQty, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ProductionDate(); ok {
|
|
_spec.SetField(inventorybatch.FieldProductionDate, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ProductionDateCleared() {
|
|
_spec.ClearField(inventorybatch.FieldProductionDate, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Supplier(); ok {
|
|
_spec.SetField(inventorybatch.FieldSupplier, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SupplierCleared() {
|
|
_spec.ClearField(inventorybatch.FieldSupplier, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.QualityStatus(); ok {
|
|
_spec.SetField(inventorybatch.FieldQualityStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(inventorybatch.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(inventorybatch.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(inventorybatch.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(inventorybatch.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(inventorybatch.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(inventorybatch.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(inventorybatch.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(inventorybatch.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
_node = &InventoryBatch{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{inventorybatch.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|