初始化
This commit is contained in:
@@ -1,631 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_wms/ent/inventorylock"
|
||||
"bj_power_wms/ent/predicate"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// InventoryLockUpdate is the builder for updating InventoryLock entities.
|
||||
type InventoryLockUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *InventoryLockMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the InventoryLockUpdate builder.
|
||||
func (_u *InventoryLockUpdate) Where(ps ...predicate.InventoryLock) *InventoryLockUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTargetType sets the "target_type" field.
|
||||
func (_u *InventoryLockUpdate) SetTargetType(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetTargetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetType sets the "target_type" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableTargetType(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetTargetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTargetID sets the "target_id" field.
|
||||
func (_u *InventoryLockUpdate) SetTargetID(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetTargetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableTargetID(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetTargetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMaterialCode sets the "material_code" field.
|
||||
func (_u *InventoryLockUpdate) SetMaterialCode(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetMaterialCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableMaterialCode(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetMaterialCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLockedQty sets the "locked_qty" field.
|
||||
func (_u *InventoryLockUpdate) SetLockedQty(v int) *InventoryLockUpdate {
|
||||
_u.mutation.ResetLockedQty()
|
||||
_u.mutation.SetLockedQty(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLockedQty sets the "locked_qty" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableLockedQty(v *int) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetLockedQty(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddLockedQty adds value to the "locked_qty" field.
|
||||
func (_u *InventoryLockUpdate) AddLockedQty(v int) *InventoryLockUpdate {
|
||||
_u.mutation.AddLockedQty(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOrderNo sets the "order_no" field.
|
||||
func (_u *InventoryLockUpdate) SetOrderNo(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetOrderNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderNo sets the "order_no" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableOrderNo(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetOrderNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *InventoryLockUpdate) SetStatus(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableStatus(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiredAt sets the "expired_at" field.
|
||||
func (_u *InventoryLockUpdate) SetExpiredAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.ResetExpiredAt()
|
||||
_u.mutation.SetExpiredAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiredAt sets the "expired_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableExpiredAt(v *int64) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetExpiredAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddExpiredAt adds value to the "expired_at" field.
|
||||
func (_u *InventoryLockUpdate) AddExpiredAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.AddExpiredAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearExpiredAt clears the value of the "expired_at" field.
|
||||
func (_u *InventoryLockUpdate) ClearExpiredAt() *InventoryLockUpdate {
|
||||
_u.mutation.ClearExpiredAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *InventoryLockUpdate) SetRemark(v string) *InventoryLockUpdate {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableRemark(v *string) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (_u *InventoryLockUpdate) ClearRemark() *InventoryLockUpdate {
|
||||
_u.mutation.ClearRemark()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *InventoryLockUpdate) SetCreatedAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.ResetCreatedAt()
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableCreatedAt(v *int64) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddCreatedAt adds value to the "created_at" field.
|
||||
func (_u *InventoryLockUpdate) AddCreatedAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.AddCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *InventoryLockUpdate) SetUpdatedAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.ResetUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdate) SetNillableUpdatedAt(v *int64) *InventoryLockUpdate {
|
||||
if v != nil {
|
||||
_u.SetUpdatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddUpdatedAt adds value to the "updated_at" field.
|
||||
func (_u *InventoryLockUpdate) AddUpdatedAt(v int64) *InventoryLockUpdate {
|
||||
_u.mutation.AddUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the InventoryLockMutation object of the builder.
|
||||
func (_u *InventoryLockUpdate) Mutation() *InventoryLockMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *InventoryLockUpdate) 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 *InventoryLockUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *InventoryLockUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *InventoryLockUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (_u *InventoryLockUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(inventorylock.Table, inventorylock.Columns, sqlgraph.NewFieldSpec(inventorylock.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.TargetType(); ok {
|
||||
_spec.SetField(inventorylock.FieldTargetType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TargetID(); ok {
|
||||
_spec.SetField(inventorylock.FieldTargetID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.MaterialCode(); ok {
|
||||
_spec.SetField(inventorylock.FieldMaterialCode, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LockedQty(); ok {
|
||||
_spec.SetField(inventorylock.FieldLockedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedLockedQty(); ok {
|
||||
_spec.AddField(inventorylock.FieldLockedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.OrderNo(); ok {
|
||||
_spec.SetField(inventorylock.FieldOrderNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(inventorylock.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ExpiredAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldExpiredAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedExpiredAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldExpiredAt, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.ExpiredAtCleared() {
|
||||
_spec.ClearField(inventorylock.FieldExpiredAt, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(inventorylock.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RemarkCleared() {
|
||||
_spec.ClearField(inventorylock.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldCreatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldCreatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldUpdatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldUpdatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{inventorylock.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// InventoryLockUpdateOne is the builder for updating a single InventoryLock entity.
|
||||
type InventoryLockUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *InventoryLockMutation
|
||||
}
|
||||
|
||||
// SetTargetType sets the "target_type" field.
|
||||
func (_u *InventoryLockUpdateOne) SetTargetType(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetTargetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetType sets the "target_type" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableTargetType(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTargetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTargetID sets the "target_id" field.
|
||||
func (_u *InventoryLockUpdateOne) SetTargetID(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetTargetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableTargetID(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTargetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMaterialCode sets the "material_code" field.
|
||||
func (_u *InventoryLockUpdateOne) SetMaterialCode(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetMaterialCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableMaterialCode(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetMaterialCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLockedQty sets the "locked_qty" field.
|
||||
func (_u *InventoryLockUpdateOne) SetLockedQty(v int) *InventoryLockUpdateOne {
|
||||
_u.mutation.ResetLockedQty()
|
||||
_u.mutation.SetLockedQty(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLockedQty sets the "locked_qty" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableLockedQty(v *int) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetLockedQty(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddLockedQty adds value to the "locked_qty" field.
|
||||
func (_u *InventoryLockUpdateOne) AddLockedQty(v int) *InventoryLockUpdateOne {
|
||||
_u.mutation.AddLockedQty(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOrderNo sets the "order_no" field.
|
||||
func (_u *InventoryLockUpdateOne) SetOrderNo(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetOrderNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderNo sets the "order_no" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableOrderNo(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetOrderNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *InventoryLockUpdateOne) SetStatus(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableStatus(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiredAt sets the "expired_at" field.
|
||||
func (_u *InventoryLockUpdateOne) SetExpiredAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.ResetExpiredAt()
|
||||
_u.mutation.SetExpiredAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiredAt sets the "expired_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableExpiredAt(v *int64) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetExpiredAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddExpiredAt adds value to the "expired_at" field.
|
||||
func (_u *InventoryLockUpdateOne) AddExpiredAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.AddExpiredAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearExpiredAt clears the value of the "expired_at" field.
|
||||
func (_u *InventoryLockUpdateOne) ClearExpiredAt() *InventoryLockUpdateOne {
|
||||
_u.mutation.ClearExpiredAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *InventoryLockUpdateOne) SetRemark(v string) *InventoryLockUpdateOne {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableRemark(v *string) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (_u *InventoryLockUpdateOne) ClearRemark() *InventoryLockUpdateOne {
|
||||
_u.mutation.ClearRemark()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *InventoryLockUpdateOne) SetCreatedAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.ResetCreatedAt()
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableCreatedAt(v *int64) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddCreatedAt adds value to the "created_at" field.
|
||||
func (_u *InventoryLockUpdateOne) AddCreatedAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.AddCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *InventoryLockUpdateOne) SetUpdatedAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.ResetUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_u *InventoryLockUpdateOne) SetNillableUpdatedAt(v *int64) *InventoryLockUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUpdatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddUpdatedAt adds value to the "updated_at" field.
|
||||
func (_u *InventoryLockUpdateOne) AddUpdatedAt(v int64) *InventoryLockUpdateOne {
|
||||
_u.mutation.AddUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the InventoryLockMutation object of the builder.
|
||||
func (_u *InventoryLockUpdateOne) Mutation() *InventoryLockMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the InventoryLockUpdate builder.
|
||||
func (_u *InventoryLockUpdateOne) Where(ps ...predicate.InventoryLock) *InventoryLockUpdateOne {
|
||||
_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 *InventoryLockUpdateOne) Select(field string, fields ...string) *InventoryLockUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated InventoryLock entity.
|
||||
func (_u *InventoryLockUpdateOne) Save(ctx context.Context) (*InventoryLock, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *InventoryLockUpdateOne) SaveX(ctx context.Context) *InventoryLock {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *InventoryLockUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *InventoryLockUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (_u *InventoryLockUpdateOne) sqlSave(ctx context.Context) (_node *InventoryLock, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(inventorylock.Table, inventorylock.Columns, sqlgraph.NewFieldSpec(inventorylock.FieldID, field.TypeInt))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "InventoryLock.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, inventorylock.FieldID)
|
||||
for _, f := range fields {
|
||||
if !inventorylock.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != inventorylock.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.TargetType(); ok {
|
||||
_spec.SetField(inventorylock.FieldTargetType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TargetID(); ok {
|
||||
_spec.SetField(inventorylock.FieldTargetID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.MaterialCode(); ok {
|
||||
_spec.SetField(inventorylock.FieldMaterialCode, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LockedQty(); ok {
|
||||
_spec.SetField(inventorylock.FieldLockedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedLockedQty(); ok {
|
||||
_spec.AddField(inventorylock.FieldLockedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.OrderNo(); ok {
|
||||
_spec.SetField(inventorylock.FieldOrderNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(inventorylock.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ExpiredAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldExpiredAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedExpiredAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldExpiredAt, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.ExpiredAtCleared() {
|
||||
_spec.ClearField(inventorylock.FieldExpiredAt, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(inventorylock.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RemarkCleared() {
|
||||
_spec.ClearField(inventorylock.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldCreatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldCreatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(inventorylock.FieldUpdatedAt, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
||||
_spec.AddField(inventorylock.FieldUpdatedAt, field.TypeInt64, value)
|
||||
}
|
||||
_node = &InventoryLock{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{inventorylock.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
Reference in New Issue
Block a user