// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_mes/ent/agvpoint" "bj_power_mes/ent/predicate" "context" "errors" "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // AgvPointUpdate is the builder for updating AgvPoint entities. type AgvPointUpdate struct { config hooks []Hook mutation *AgvPointMutation modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the AgvPointUpdate builder. func (_u *AgvPointUpdate) Where(ps ...predicate.AgvPoint) *AgvPointUpdate { _u.mutation.Where(ps...) return _u } // SetPositionCode sets the "position_code" field. func (_u *AgvPointUpdate) SetPositionCode(v string) *AgvPointUpdate { _u.mutation.SetPositionCode(v) return _u } // SetNillablePositionCode sets the "position_code" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillablePositionCode(v *string) *AgvPointUpdate { if v != nil { _u.SetPositionCode(*v) } return _u } // SetName sets the "name" field. func (_u *AgvPointUpdate) SetName(v string) *AgvPointUpdate { _u.mutation.SetName(v) return _u } // SetNillableName sets the "name" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableName(v *string) *AgvPointUpdate { if v != nil { _u.SetName(*v) } return _u } // SetIsDock sets the "is_dock" field. func (_u *AgvPointUpdate) SetIsDock(v bool) *AgvPointUpdate { _u.mutation.SetIsDock(v) return _u } // SetNillableIsDock sets the "is_dock" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableIsDock(v *bool) *AgvPointUpdate { if v != nil { _u.SetIsDock(*v) } return _u } // SetDockID sets the "dock_id" field. func (_u *AgvPointUpdate) SetDockID(v int) *AgvPointUpdate { _u.mutation.ResetDockID() _u.mutation.SetDockID(v) return _u } // SetNillableDockID sets the "dock_id" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableDockID(v *int) *AgvPointUpdate { if v != nil { _u.SetDockID(*v) } return _u } // AddDockID adds value to the "dock_id" field. func (_u *AgvPointUpdate) AddDockID(v int) *AgvPointUpdate { _u.mutation.AddDockID(v) return _u } // ClearDockID clears the value of the "dock_id" field. func (_u *AgvPointUpdate) ClearDockID() *AgvPointUpdate { _u.mutation.ClearDockID() return _u } // SetEnabled sets the "enabled" field. func (_u *AgvPointUpdate) SetEnabled(v bool) *AgvPointUpdate { _u.mutation.SetEnabled(v) return _u } // SetNillableEnabled sets the "enabled" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableEnabled(v *bool) *AgvPointUpdate { if v != nil { _u.SetEnabled(*v) } return _u } // SetLocked sets the "locked" field. func (_u *AgvPointUpdate) SetLocked(v bool) *AgvPointUpdate { _u.mutation.SetLocked(v) return _u } // SetNillableLocked sets the "locked" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableLocked(v *bool) *AgvPointUpdate { if v != nil { _u.SetLocked(*v) } return _u } // SetLockedBy sets the "locked_by" field. func (_u *AgvPointUpdate) SetLockedBy(v string) *AgvPointUpdate { _u.mutation.SetLockedBy(v) return _u } // SetNillableLockedBy sets the "locked_by" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableLockedBy(v *string) *AgvPointUpdate { if v != nil { _u.SetLockedBy(*v) } return _u } // SetLockedReason sets the "locked_reason" field. func (_u *AgvPointUpdate) SetLockedReason(v string) *AgvPointUpdate { _u.mutation.SetLockedReason(v) return _u } // SetNillableLockedReason sets the "locked_reason" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableLockedReason(v *string) *AgvPointUpdate { if v != nil { _u.SetLockedReason(*v) } return _u } // SetLockedAt sets the "locked_at" field. func (_u *AgvPointUpdate) SetLockedAt(v int64) *AgvPointUpdate { _u.mutation.ResetLockedAt() _u.mutation.SetLockedAt(v) return _u } // SetNillableLockedAt sets the "locked_at" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableLockedAt(v *int64) *AgvPointUpdate { if v != nil { _u.SetLockedAt(*v) } return _u } // AddLockedAt adds value to the "locked_at" field. func (_u *AgvPointUpdate) AddLockedAt(v int64) *AgvPointUpdate { _u.mutation.AddLockedAt(v) return _u } // SetForcePick sets the "force_pick" field. func (_u *AgvPointUpdate) SetForcePick(v bool) *AgvPointUpdate { _u.mutation.SetForcePick(v) return _u } // SetNillableForcePick sets the "force_pick" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableForcePick(v *bool) *AgvPointUpdate { if v != nil { _u.SetForcePick(*v) } return _u } // SetForcePickAt sets the "force_pick_at" field. func (_u *AgvPointUpdate) SetForcePickAt(v int64) *AgvPointUpdate { _u.mutation.ResetForcePickAt() _u.mutation.SetForcePickAt(v) return _u } // SetNillableForcePickAt sets the "force_pick_at" field if the given value is not nil. func (_u *AgvPointUpdate) SetNillableForcePickAt(v *int64) *AgvPointUpdate { if v != nil { _u.SetForcePickAt(*v) } return _u } // AddForcePickAt adds value to the "force_pick_at" field. func (_u *AgvPointUpdate) AddForcePickAt(v int64) *AgvPointUpdate { _u.mutation.AddForcePickAt(v) return _u } // Mutation returns the AgvPointMutation object of the builder. func (_u *AgvPointUpdate) Mutation() *AgvPointMutation { return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *AgvPointUpdate) 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 *AgvPointUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *AgvPointUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AgvPointUpdate) 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 *AgvPointUpdate) check() error { if v, ok := _u.mutation.PositionCode(); ok { if err := agvpoint.PositionCodeValidator(v); err != nil { return &ValidationError{Name: "position_code", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.position_code": %w`, err)} } } if v, ok := _u.mutation.Name(); ok { if err := agvpoint.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.name": %w`, err)} } } if v, ok := _u.mutation.LockedBy(); ok { if err := agvpoint.LockedByValidator(v); err != nil { return &ValidationError{Name: "locked_by", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.locked_by": %w`, err)} } } if v, ok := _u.mutation.LockedReason(); ok { if err := agvpoint.LockedReasonValidator(v); err != nil { return &ValidationError{Name: "locked_reason", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.locked_reason": %w`, err)} } } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *AgvPointUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvPointUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *AgvPointUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(agvpoint.Table, agvpoint.Columns, sqlgraph.NewFieldSpec(agvpoint.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.PositionCode(); ok { _spec.SetField(agvpoint.FieldPositionCode, field.TypeString, value) } if value, ok := _u.mutation.Name(); ok { _spec.SetField(agvpoint.FieldName, field.TypeString, value) } if value, ok := _u.mutation.IsDock(); ok { _spec.SetField(agvpoint.FieldIsDock, field.TypeBool, value) } if value, ok := _u.mutation.DockID(); ok { _spec.SetField(agvpoint.FieldDockID, field.TypeInt, value) } if value, ok := _u.mutation.AddedDockID(); ok { _spec.AddField(agvpoint.FieldDockID, field.TypeInt, value) } if _u.mutation.DockIDCleared() { _spec.ClearField(agvpoint.FieldDockID, field.TypeInt) } if value, ok := _u.mutation.Enabled(); ok { _spec.SetField(agvpoint.FieldEnabled, field.TypeBool, value) } if value, ok := _u.mutation.Locked(); ok { _spec.SetField(agvpoint.FieldLocked, field.TypeBool, value) } if value, ok := _u.mutation.LockedBy(); ok { _spec.SetField(agvpoint.FieldLockedBy, field.TypeString, value) } if value, ok := _u.mutation.LockedReason(); ok { _spec.SetField(agvpoint.FieldLockedReason, field.TypeString, value) } if value, ok := _u.mutation.LockedAt(); ok { _spec.SetField(agvpoint.FieldLockedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedLockedAt(); ok { _spec.AddField(agvpoint.FieldLockedAt, field.TypeInt64, value) } if value, ok := _u.mutation.ForcePick(); ok { _spec.SetField(agvpoint.FieldForcePick, field.TypeBool, value) } if value, ok := _u.mutation.ForcePickAt(); ok { _spec.SetField(agvpoint.FieldForcePickAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedForcePickAt(); ok { _spec.AddField(agvpoint.FieldForcePickAt, field.TypeInt64, value) } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{agvpoint.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // AgvPointUpdateOne is the builder for updating a single AgvPoint entity. type AgvPointUpdateOne struct { config fields []string hooks []Hook mutation *AgvPointMutation modifiers []func(*sql.UpdateBuilder) } // SetPositionCode sets the "position_code" field. func (_u *AgvPointUpdateOne) SetPositionCode(v string) *AgvPointUpdateOne { _u.mutation.SetPositionCode(v) return _u } // SetNillablePositionCode sets the "position_code" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillablePositionCode(v *string) *AgvPointUpdateOne { if v != nil { _u.SetPositionCode(*v) } return _u } // SetName sets the "name" field. func (_u *AgvPointUpdateOne) SetName(v string) *AgvPointUpdateOne { _u.mutation.SetName(v) return _u } // SetNillableName sets the "name" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableName(v *string) *AgvPointUpdateOne { if v != nil { _u.SetName(*v) } return _u } // SetIsDock sets the "is_dock" field. func (_u *AgvPointUpdateOne) SetIsDock(v bool) *AgvPointUpdateOne { _u.mutation.SetIsDock(v) return _u } // SetNillableIsDock sets the "is_dock" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableIsDock(v *bool) *AgvPointUpdateOne { if v != nil { _u.SetIsDock(*v) } return _u } // SetDockID sets the "dock_id" field. func (_u *AgvPointUpdateOne) SetDockID(v int) *AgvPointUpdateOne { _u.mutation.ResetDockID() _u.mutation.SetDockID(v) return _u } // SetNillableDockID sets the "dock_id" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableDockID(v *int) *AgvPointUpdateOne { if v != nil { _u.SetDockID(*v) } return _u } // AddDockID adds value to the "dock_id" field. func (_u *AgvPointUpdateOne) AddDockID(v int) *AgvPointUpdateOne { _u.mutation.AddDockID(v) return _u } // ClearDockID clears the value of the "dock_id" field. func (_u *AgvPointUpdateOne) ClearDockID() *AgvPointUpdateOne { _u.mutation.ClearDockID() return _u } // SetEnabled sets the "enabled" field. func (_u *AgvPointUpdateOne) SetEnabled(v bool) *AgvPointUpdateOne { _u.mutation.SetEnabled(v) return _u } // SetNillableEnabled sets the "enabled" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableEnabled(v *bool) *AgvPointUpdateOne { if v != nil { _u.SetEnabled(*v) } return _u } // SetLocked sets the "locked" field. func (_u *AgvPointUpdateOne) SetLocked(v bool) *AgvPointUpdateOne { _u.mutation.SetLocked(v) return _u } // SetNillableLocked sets the "locked" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableLocked(v *bool) *AgvPointUpdateOne { if v != nil { _u.SetLocked(*v) } return _u } // SetLockedBy sets the "locked_by" field. func (_u *AgvPointUpdateOne) SetLockedBy(v string) *AgvPointUpdateOne { _u.mutation.SetLockedBy(v) return _u } // SetNillableLockedBy sets the "locked_by" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableLockedBy(v *string) *AgvPointUpdateOne { if v != nil { _u.SetLockedBy(*v) } return _u } // SetLockedReason sets the "locked_reason" field. func (_u *AgvPointUpdateOne) SetLockedReason(v string) *AgvPointUpdateOne { _u.mutation.SetLockedReason(v) return _u } // SetNillableLockedReason sets the "locked_reason" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableLockedReason(v *string) *AgvPointUpdateOne { if v != nil { _u.SetLockedReason(*v) } return _u } // SetLockedAt sets the "locked_at" field. func (_u *AgvPointUpdateOne) SetLockedAt(v int64) *AgvPointUpdateOne { _u.mutation.ResetLockedAt() _u.mutation.SetLockedAt(v) return _u } // SetNillableLockedAt sets the "locked_at" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableLockedAt(v *int64) *AgvPointUpdateOne { if v != nil { _u.SetLockedAt(*v) } return _u } // AddLockedAt adds value to the "locked_at" field. func (_u *AgvPointUpdateOne) AddLockedAt(v int64) *AgvPointUpdateOne { _u.mutation.AddLockedAt(v) return _u } // SetForcePick sets the "force_pick" field. func (_u *AgvPointUpdateOne) SetForcePick(v bool) *AgvPointUpdateOne { _u.mutation.SetForcePick(v) return _u } // SetNillableForcePick sets the "force_pick" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableForcePick(v *bool) *AgvPointUpdateOne { if v != nil { _u.SetForcePick(*v) } return _u } // SetForcePickAt sets the "force_pick_at" field. func (_u *AgvPointUpdateOne) SetForcePickAt(v int64) *AgvPointUpdateOne { _u.mutation.ResetForcePickAt() _u.mutation.SetForcePickAt(v) return _u } // SetNillableForcePickAt sets the "force_pick_at" field if the given value is not nil. func (_u *AgvPointUpdateOne) SetNillableForcePickAt(v *int64) *AgvPointUpdateOne { if v != nil { _u.SetForcePickAt(*v) } return _u } // AddForcePickAt adds value to the "force_pick_at" field. func (_u *AgvPointUpdateOne) AddForcePickAt(v int64) *AgvPointUpdateOne { _u.mutation.AddForcePickAt(v) return _u } // Mutation returns the AgvPointMutation object of the builder. func (_u *AgvPointUpdateOne) Mutation() *AgvPointMutation { return _u.mutation } // Where appends a list predicates to the AgvPointUpdate builder. func (_u *AgvPointUpdateOne) Where(ps ...predicate.AgvPoint) *AgvPointUpdateOne { _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 *AgvPointUpdateOne) Select(field string, fields ...string) *AgvPointUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated AgvPoint entity. func (_u *AgvPointUpdateOne) Save(ctx context.Context) (*AgvPoint, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *AgvPointUpdateOne) SaveX(ctx context.Context) *AgvPoint { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *AgvPointUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *AgvPointUpdateOne) 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 *AgvPointUpdateOne) check() error { if v, ok := _u.mutation.PositionCode(); ok { if err := agvpoint.PositionCodeValidator(v); err != nil { return &ValidationError{Name: "position_code", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.position_code": %w`, err)} } } if v, ok := _u.mutation.Name(); ok { if err := agvpoint.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.name": %w`, err)} } } if v, ok := _u.mutation.LockedBy(); ok { if err := agvpoint.LockedByValidator(v); err != nil { return &ValidationError{Name: "locked_by", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.locked_by": %w`, err)} } } if v, ok := _u.mutation.LockedReason(); ok { if err := agvpoint.LockedReasonValidator(v); err != nil { return &ValidationError{Name: "locked_reason", err: fmt.Errorf(`ent: validator failed for field "AgvPoint.locked_reason": %w`, err)} } } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *AgvPointUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvPointUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *AgvPointUpdateOne) sqlSave(ctx context.Context) (_node *AgvPoint, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(agvpoint.Table, agvpoint.Columns, sqlgraph.NewFieldSpec(agvpoint.FieldID, field.TypeInt)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AgvPoint.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, agvpoint.FieldID) for _, f := range fields { if !agvpoint.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != agvpoint.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.PositionCode(); ok { _spec.SetField(agvpoint.FieldPositionCode, field.TypeString, value) } if value, ok := _u.mutation.Name(); ok { _spec.SetField(agvpoint.FieldName, field.TypeString, value) } if value, ok := _u.mutation.IsDock(); ok { _spec.SetField(agvpoint.FieldIsDock, field.TypeBool, value) } if value, ok := _u.mutation.DockID(); ok { _spec.SetField(agvpoint.FieldDockID, field.TypeInt, value) } if value, ok := _u.mutation.AddedDockID(); ok { _spec.AddField(agvpoint.FieldDockID, field.TypeInt, value) } if _u.mutation.DockIDCleared() { _spec.ClearField(agvpoint.FieldDockID, field.TypeInt) } if value, ok := _u.mutation.Enabled(); ok { _spec.SetField(agvpoint.FieldEnabled, field.TypeBool, value) } if value, ok := _u.mutation.Locked(); ok { _spec.SetField(agvpoint.FieldLocked, field.TypeBool, value) } if value, ok := _u.mutation.LockedBy(); ok { _spec.SetField(agvpoint.FieldLockedBy, field.TypeString, value) } if value, ok := _u.mutation.LockedReason(); ok { _spec.SetField(agvpoint.FieldLockedReason, field.TypeString, value) } if value, ok := _u.mutation.LockedAt(); ok { _spec.SetField(agvpoint.FieldLockedAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedLockedAt(); ok { _spec.AddField(agvpoint.FieldLockedAt, field.TypeInt64, value) } if value, ok := _u.mutation.ForcePick(); ok { _spec.SetField(agvpoint.FieldForcePick, field.TypeBool, value) } if value, ok := _u.mutation.ForcePickAt(); ok { _spec.SetField(agvpoint.FieldForcePickAt, field.TypeInt64, value) } if value, ok := _u.mutation.AddedForcePickAt(); ok { _spec.AddField(agvpoint.FieldForcePickAt, field.TypeInt64, value) } _spec.AddModifiers(_u.modifiers...) _node = &AgvPoint{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{agvpoint.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }