初始化2
This commit is contained in:
@@ -0,0 +1,481 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_mes/ent/predicate"
|
||||
"bj_power_mes/ent/processstep"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ProcessStepUpdate is the builder for updating ProcessStep entities.
|
||||
type ProcessStepUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ProcessStepMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ProcessStepUpdate builder.
|
||||
func (_u *ProcessStepUpdate) Where(ps ...predicate.ProcessStep) *ProcessStepUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetProcessCode sets the "processCode" field.
|
||||
func (_u *ProcessStepUpdate) SetProcessCode(v int) *ProcessStepUpdate {
|
||||
_u.mutation.ResetProcessCode()
|
||||
_u.mutation.SetProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableProcessCode(v *int) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetProcessCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddProcessCode adds value to the "processCode" field.
|
||||
func (_u *ProcessStepUpdate) AddProcessCode(v int) *ProcessStepUpdate {
|
||||
_u.mutation.AddProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSeq sets the "seq" field.
|
||||
func (_u *ProcessStepUpdate) SetSeq(v int) *ProcessStepUpdate {
|
||||
_u.mutation.ResetSeq()
|
||||
_u.mutation.SetSeq(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSeq sets the "seq" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableSeq(v *int) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetSeq(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSeq adds value to the "seq" field.
|
||||
func (_u *ProcessStepUpdate) AddSeq(v int) *ProcessStepUpdate {
|
||||
_u.mutation.AddSeq(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *ProcessStepUpdate) SetName(v string) *ProcessStepUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableName(v *string) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCollectType sets the "collectType" field.
|
||||
func (_u *ProcessStepUpdate) SetCollectType(v string) *ProcessStepUpdate {
|
||||
_u.mutation.SetCollectType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCollectType sets the "collectType" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableCollectType(v *string) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetCollectType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsTorque sets the "isTorque" field.
|
||||
func (_u *ProcessStepUpdate) SetIsTorque(v bool) *ProcessStepUpdate {
|
||||
_u.mutation.SetIsTorque(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsTorque sets the "isTorque" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableIsTorque(v *bool) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetIsTorque(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *ProcessStepUpdate) SetRemark(v string) *ProcessStepUpdate {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdate) SetNillableRemark(v *string) *ProcessStepUpdate {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the ProcessStepMutation object of the builder.
|
||||
func (_u *ProcessStepUpdate) Mutation() *ProcessStepMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *ProcessStepUpdate) 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 *ProcessStepUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *ProcessStepUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *ProcessStepUpdate) 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 *ProcessStepUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := processstep.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.CollectType(); ok {
|
||||
if err := processstep.CollectTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "collectType", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.collectType": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := processstep.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *ProcessStepUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessStepUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *ProcessStepUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(processstep.Table, processstep.Columns, sqlgraph.NewFieldSpec(processstep.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.ProcessCode(); ok {
|
||||
_spec.SetField(processstep.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedProcessCode(); ok {
|
||||
_spec.AddField(processstep.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Seq(); ok {
|
||||
_spec.SetField(processstep.FieldSeq, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedSeq(); ok {
|
||||
_spec.AddField(processstep.FieldSeq, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(processstep.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CollectType(); ok {
|
||||
_spec.SetField(processstep.FieldCollectType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.IsTorque(); ok {
|
||||
_spec.SetField(processstep.FieldIsTorque, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(processstep.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{processstep.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// ProcessStepUpdateOne is the builder for updating a single ProcessStep entity.
|
||||
type ProcessStepUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *ProcessStepMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetProcessCode sets the "processCode" field.
|
||||
func (_u *ProcessStepUpdateOne) SetProcessCode(v int) *ProcessStepUpdateOne {
|
||||
_u.mutation.ResetProcessCode()
|
||||
_u.mutation.SetProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableProcessCode(v *int) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetProcessCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddProcessCode adds value to the "processCode" field.
|
||||
func (_u *ProcessStepUpdateOne) AddProcessCode(v int) *ProcessStepUpdateOne {
|
||||
_u.mutation.AddProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSeq sets the "seq" field.
|
||||
func (_u *ProcessStepUpdateOne) SetSeq(v int) *ProcessStepUpdateOne {
|
||||
_u.mutation.ResetSeq()
|
||||
_u.mutation.SetSeq(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSeq sets the "seq" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableSeq(v *int) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSeq(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSeq adds value to the "seq" field.
|
||||
func (_u *ProcessStepUpdateOne) AddSeq(v int) *ProcessStepUpdateOne {
|
||||
_u.mutation.AddSeq(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *ProcessStepUpdateOne) SetName(v string) *ProcessStepUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableName(v *string) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCollectType sets the "collectType" field.
|
||||
func (_u *ProcessStepUpdateOne) SetCollectType(v string) *ProcessStepUpdateOne {
|
||||
_u.mutation.SetCollectType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCollectType sets the "collectType" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableCollectType(v *string) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCollectType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsTorque sets the "isTorque" field.
|
||||
func (_u *ProcessStepUpdateOne) SetIsTorque(v bool) *ProcessStepUpdateOne {
|
||||
_u.mutation.SetIsTorque(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsTorque sets the "isTorque" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableIsTorque(v *bool) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIsTorque(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *ProcessStepUpdateOne) SetRemark(v string) *ProcessStepUpdateOne {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *ProcessStepUpdateOne) SetNillableRemark(v *string) *ProcessStepUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the ProcessStepMutation object of the builder.
|
||||
func (_u *ProcessStepUpdateOne) Mutation() *ProcessStepMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ProcessStepUpdate builder.
|
||||
func (_u *ProcessStepUpdateOne) Where(ps ...predicate.ProcessStep) *ProcessStepUpdateOne {
|
||||
_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 *ProcessStepUpdateOne) Select(field string, fields ...string) *ProcessStepUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated ProcessStep entity.
|
||||
func (_u *ProcessStepUpdateOne) Save(ctx context.Context) (*ProcessStep, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *ProcessStepUpdateOne) SaveX(ctx context.Context) *ProcessStep {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *ProcessStepUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *ProcessStepUpdateOne) 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 *ProcessStepUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := processstep.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.CollectType(); ok {
|
||||
if err := processstep.CollectTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "collectType", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.collectType": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := processstep.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *ProcessStepUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessStepUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *ProcessStepUpdateOne) sqlSave(ctx context.Context) (_node *ProcessStep, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(processstep.Table, processstep.Columns, sqlgraph.NewFieldSpec(processstep.FieldID, field.TypeInt))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProcessStep.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, processstep.FieldID)
|
||||
for _, f := range fields {
|
||||
if !processstep.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != processstep.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.ProcessCode(); ok {
|
||||
_spec.SetField(processstep.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedProcessCode(); ok {
|
||||
_spec.AddField(processstep.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Seq(); ok {
|
||||
_spec.SetField(processstep.FieldSeq, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedSeq(); ok {
|
||||
_spec.AddField(processstep.FieldSeq, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(processstep.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CollectType(); ok {
|
||||
_spec.SetField(processstep.FieldCollectType, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.IsTorque(); ok {
|
||||
_spec.SetField(processstep.FieldIsTorque, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(processstep.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &ProcessStep{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{processstep.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