700 lines
21 KiB
Go
700 lines
21 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/inboundorder"
|
|
"bj_power_wms/ent/predicate"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// InboundOrderUpdate is the builder for updating InboundOrder entities.
|
|
type InboundOrderUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *InboundOrderMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the InboundOrderUpdate builder.
|
|
func (_u *InboundOrderUpdate) Where(ps ...predicate.InboundOrder) *InboundOrderUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetInboundNo sets the "inbound_no" field.
|
|
func (_u *InboundOrderUpdate) SetInboundNo(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetInboundNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInboundNo sets the "inbound_no" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableInboundNo(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetInboundNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetInboundType sets the "inbound_type" field.
|
|
func (_u *InboundOrderUpdate) SetInboundType(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetInboundType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInboundType sets the "inbound_type" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableInboundType(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetInboundType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *InboundOrderUpdate) SetMaterialCode(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableMaterialCode(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "material_name" field.
|
|
func (_u *InboundOrderUpdate) SetMaterialName(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "material_name" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableMaterialName(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialName clears the value of the "material_name" field.
|
|
func (_u *InboundOrderUpdate) ClearMaterialName() *InboundOrderUpdate {
|
|
_u.mutation.ClearMaterialName()
|
|
return _u
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (_u *InboundOrderUpdate) SetManageMode(v int) *InboundOrderUpdate {
|
|
_u.mutation.ResetManageMode()
|
|
_u.mutation.SetManageMode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManageMode sets the "manage_mode" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableManageMode(v *int) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetManageMode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddManageMode adds value to the "manage_mode" field.
|
|
func (_u *InboundOrderUpdate) AddManageMode(v int) *InboundOrderUpdate {
|
|
_u.mutation.AddManageMode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetBatchNo sets the "batch_no" field.
|
|
func (_u *InboundOrderUpdate) SetBatchNo(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetBatchNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableBatchNo(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetBatchNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearBatchNo clears the value of the "batch_no" field.
|
|
func (_u *InboundOrderUpdate) ClearBatchNo() *InboundOrderUpdate {
|
|
_u.mutation.ClearBatchNo()
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *InboundOrderUpdate) SetZoneCode(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableZoneCode(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *InboundOrderUpdate) ClearZoneCode() *InboundOrderUpdate {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *InboundOrderUpdate) SetQuantity(v int) *InboundOrderUpdate {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableQuantity(v *int) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *InboundOrderUpdate) AddQuantity(v int) *InboundOrderUpdate {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *InboundOrderUpdate) SetOperator(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableOperator(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOperator clears the value of the "operator" field.
|
|
func (_u *InboundOrderUpdate) ClearOperator() *InboundOrderUpdate {
|
|
_u.mutation.ClearOperator()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *InboundOrderUpdate) SetRemark(v string) *InboundOrderUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableRemark(v *string) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *InboundOrderUpdate) ClearRemark() *InboundOrderUpdate {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *InboundOrderUpdate) SetCreatedAt(v int64) *InboundOrderUpdate {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdate) SetNillableCreatedAt(v *int64) *InboundOrderUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *InboundOrderUpdate) AddCreatedAt(v int64) *InboundOrderUpdate {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the InboundOrderMutation object of the builder.
|
|
func (_u *InboundOrderUpdate) Mutation() *InboundOrderMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *InboundOrderUpdate) 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 *InboundOrderUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *InboundOrderUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *InboundOrderUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *InboundOrderUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(inboundorder.Table, inboundorder.Columns, sqlgraph.NewFieldSpec(inboundorder.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.InboundNo(); ok {
|
|
_spec.SetField(inboundorder.FieldInboundNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.InboundType(); ok {
|
|
_spec.SetField(inboundorder.FieldInboundType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(inboundorder.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(inboundorder.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialNameCleared() {
|
|
_spec.ClearField(inboundorder.FieldMaterialName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ManageMode(); ok {
|
|
_spec.SetField(inboundorder.FieldManageMode, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedManageMode(); ok {
|
|
_spec.AddField(inboundorder.FieldManageMode, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.BatchNo(); ok {
|
|
_spec.SetField(inboundorder.FieldBatchNo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.BatchNoCleared() {
|
|
_spec.ClearField(inboundorder.FieldBatchNo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(inboundorder.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(inboundorder.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(inboundorder.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(inboundorder.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(inboundorder.FieldOperator, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OperatorCleared() {
|
|
_spec.ClearField(inboundorder.FieldOperator, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(inboundorder.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(inboundorder.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(inboundorder.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(inboundorder.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{inboundorder.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// InboundOrderUpdateOne is the builder for updating a single InboundOrder entity.
|
|
type InboundOrderUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *InboundOrderMutation
|
|
}
|
|
|
|
// SetInboundNo sets the "inbound_no" field.
|
|
func (_u *InboundOrderUpdateOne) SetInboundNo(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetInboundNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInboundNo sets the "inbound_no" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableInboundNo(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetInboundNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetInboundType sets the "inbound_type" field.
|
|
func (_u *InboundOrderUpdateOne) SetInboundType(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetInboundType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInboundType sets the "inbound_type" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableInboundType(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetInboundType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "material_code" field.
|
|
func (_u *InboundOrderUpdateOne) SetMaterialCode(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableMaterialCode(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "material_name" field.
|
|
func (_u *InboundOrderUpdateOne) SetMaterialName(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "material_name" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableMaterialName(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMaterialName clears the value of the "material_name" field.
|
|
func (_u *InboundOrderUpdateOne) ClearMaterialName() *InboundOrderUpdateOne {
|
|
_u.mutation.ClearMaterialName()
|
|
return _u
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (_u *InboundOrderUpdateOne) SetManageMode(v int) *InboundOrderUpdateOne {
|
|
_u.mutation.ResetManageMode()
|
|
_u.mutation.SetManageMode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManageMode sets the "manage_mode" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableManageMode(v *int) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetManageMode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddManageMode adds value to the "manage_mode" field.
|
|
func (_u *InboundOrderUpdateOne) AddManageMode(v int) *InboundOrderUpdateOne {
|
|
_u.mutation.AddManageMode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetBatchNo sets the "batch_no" field.
|
|
func (_u *InboundOrderUpdateOne) SetBatchNo(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetBatchNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableBatchNo(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetBatchNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearBatchNo clears the value of the "batch_no" field.
|
|
func (_u *InboundOrderUpdateOne) ClearBatchNo() *InboundOrderUpdateOne {
|
|
_u.mutation.ClearBatchNo()
|
|
return _u
|
|
}
|
|
|
|
// SetZoneCode sets the "zone_code" field.
|
|
func (_u *InboundOrderUpdateOne) SetZoneCode(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetZoneCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableZoneCode(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetZoneCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearZoneCode clears the value of the "zone_code" field.
|
|
func (_u *InboundOrderUpdateOne) ClearZoneCode() *InboundOrderUpdateOne {
|
|
_u.mutation.ClearZoneCode()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *InboundOrderUpdateOne) SetQuantity(v int) *InboundOrderUpdateOne {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableQuantity(v *int) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *InboundOrderUpdateOne) AddQuantity(v int) *InboundOrderUpdateOne {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *InboundOrderUpdateOne) SetOperator(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableOperator(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOperator clears the value of the "operator" field.
|
|
func (_u *InboundOrderUpdateOne) ClearOperator() *InboundOrderUpdateOne {
|
|
_u.mutation.ClearOperator()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *InboundOrderUpdateOne) SetRemark(v string) *InboundOrderUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableRemark(v *string) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *InboundOrderUpdateOne) ClearRemark() *InboundOrderUpdateOne {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *InboundOrderUpdateOne) SetCreatedAt(v int64) *InboundOrderUpdateOne {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *InboundOrderUpdateOne) SetNillableCreatedAt(v *int64) *InboundOrderUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *InboundOrderUpdateOne) AddCreatedAt(v int64) *InboundOrderUpdateOne {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the InboundOrderMutation object of the builder.
|
|
func (_u *InboundOrderUpdateOne) Mutation() *InboundOrderMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the InboundOrderUpdate builder.
|
|
func (_u *InboundOrderUpdateOne) Where(ps ...predicate.InboundOrder) *InboundOrderUpdateOne {
|
|
_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 *InboundOrderUpdateOne) Select(field string, fields ...string) *InboundOrderUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated InboundOrder entity.
|
|
func (_u *InboundOrderUpdateOne) Save(ctx context.Context) (*InboundOrder, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *InboundOrderUpdateOne) SaveX(ctx context.Context) *InboundOrder {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *InboundOrderUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *InboundOrderUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (_u *InboundOrderUpdateOne) sqlSave(ctx context.Context) (_node *InboundOrder, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(inboundorder.Table, inboundorder.Columns, sqlgraph.NewFieldSpec(inboundorder.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "InboundOrder.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, inboundorder.FieldID)
|
|
for _, f := range fields {
|
|
if !inboundorder.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != inboundorder.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.InboundNo(); ok {
|
|
_spec.SetField(inboundorder.FieldInboundNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.InboundType(); ok {
|
|
_spec.SetField(inboundorder.FieldInboundType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(inboundorder.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(inboundorder.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MaterialNameCleared() {
|
|
_spec.ClearField(inboundorder.FieldMaterialName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ManageMode(); ok {
|
|
_spec.SetField(inboundorder.FieldManageMode, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedManageMode(); ok {
|
|
_spec.AddField(inboundorder.FieldManageMode, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.BatchNo(); ok {
|
|
_spec.SetField(inboundorder.FieldBatchNo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.BatchNoCleared() {
|
|
_spec.ClearField(inboundorder.FieldBatchNo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ZoneCode(); ok {
|
|
_spec.SetField(inboundorder.FieldZoneCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ZoneCodeCleared() {
|
|
_spec.ClearField(inboundorder.FieldZoneCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(inboundorder.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(inboundorder.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(inboundorder.FieldOperator, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OperatorCleared() {
|
|
_spec.ClearField(inboundorder.FieldOperator, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(inboundorder.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(inboundorder.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(inboundorder.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(inboundorder.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
_node = &InboundOrder{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{inboundorder.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|