初始化2
This commit is contained in:
@@ -0,0 +1,718 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_mes/ent/predicate"
|
||||
"bj_power_mes/ent/workpieceprocess"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// WorkpieceProcessUpdate is the builder for updating WorkpieceProcess entities.
|
||||
type WorkpieceProcessUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *WorkpieceProcessMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WorkpieceProcessUpdate builder.
|
||||
func (_u *WorkpieceProcessUpdate) Where(ps ...predicate.WorkpieceProcess) *WorkpieceProcessUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSn sets the "sn" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetSn(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetSn(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSn sets the "sn" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableSn(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetSn(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetProcessCode sets the "processCode" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetProcessCode(v int) *WorkpieceProcessUpdate {
|
||||
_u.mutation.ResetProcessCode()
|
||||
_u.mutation.SetProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableProcessCode(v *int) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetProcessCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddProcessCode adds value to the "processCode" field.
|
||||
func (_u *WorkpieceProcessUpdate) AddProcessCode(v int) *WorkpieceProcessUpdate {
|
||||
_u.mutation.AddProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStationNo sets the "stationNo" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetStationNo(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableStationNo(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetStationNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOrderNo sets the "orderNo" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetOrderNo(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetOrderNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableOrderNo(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetOrderNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetProcessName sets the "processName" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetProcessName(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetProcessName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessName sets the "processName" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableProcessName(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetProcessName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetStatus(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableStatus(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOperator sets the "operator" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetOperator(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetOperator(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableOperator(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetOperator(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResult sets the "result" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetResult(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetResult(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResult sets the "result" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableResult(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetResult(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStartedAt sets the "startedAt" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetStartedAt(v time.Time) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetStartedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableStartedAt(v *time.Time) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetStartedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearStartedAt clears the value of the "startedAt" field.
|
||||
func (_u *WorkpieceProcessUpdate) ClearStartedAt() *WorkpieceProcessUpdate {
|
||||
_u.mutation.ClearStartedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEndedAt sets the "endedAt" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetEndedAt(v time.Time) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetEndedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEndedAt sets the "endedAt" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableEndedAt(v *time.Time) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetEndedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEndedAt clears the value of the "endedAt" field.
|
||||
func (_u *WorkpieceProcessUpdate) ClearEndedAt() *WorkpieceProcessUpdate {
|
||||
_u.mutation.ClearEndedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *WorkpieceProcessUpdate) SetRemark(v string) *WorkpieceProcessUpdate {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdate) SetNillableRemark(v *string) *WorkpieceProcessUpdate {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the WorkpieceProcessMutation object of the builder.
|
||||
func (_u *WorkpieceProcessUpdate) Mutation() *WorkpieceProcessMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *WorkpieceProcessUpdate) 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 *WorkpieceProcessUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *WorkpieceProcessUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *WorkpieceProcessUpdate) 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 *WorkpieceProcessUpdate) check() error {
|
||||
if v, ok := _u.mutation.Sn(); ok {
|
||||
if err := workpieceprocess.SnValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.sn": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.StationNo(); ok {
|
||||
if err := workpieceprocess.StationNoValidator(v); err != nil {
|
||||
return &ValidationError{Name: "stationNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.stationNo": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.OrderNo(); ok {
|
||||
if err := workpieceprocess.OrderNoValidator(v); err != nil {
|
||||
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.orderNo": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.ProcessName(); ok {
|
||||
if err := workpieceprocess.ProcessNameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "processName", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.processName": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Status(); ok {
|
||||
if err := workpieceprocess.StatusValidator(v); err != nil {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Operator(); ok {
|
||||
if err := workpieceprocess.OperatorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.operator": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Result(); ok {
|
||||
if err := workpieceprocess.ResultValidator(v); err != nil {
|
||||
return &ValidationError{Name: "result", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.result": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := workpieceprocess.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *WorkpieceProcessUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceProcessUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *WorkpieceProcessUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(workpieceprocess.Table, workpieceprocess.Columns, sqlgraph.NewFieldSpec(workpieceprocess.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.Sn(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldSn, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ProcessCode(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedProcessCode(); ok {
|
||||
_spec.AddField(workpieceprocess.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.StationNo(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStationNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.OrderNo(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldOrderNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ProcessName(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldProcessName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Operator(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldOperator, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Result(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldResult, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.StartedAt(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStartedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.StartedAtCleared() {
|
||||
_spec.ClearField(workpieceprocess.FieldStartedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.EndedAt(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldEndedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.EndedAtCleared() {
|
||||
_spec.ClearField(workpieceprocess.FieldEndedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(workpieceprocess.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{workpieceprocess.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// WorkpieceProcessUpdateOne is the builder for updating a single WorkpieceProcess entity.
|
||||
type WorkpieceProcessUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *WorkpieceProcessMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetSn sets the "sn" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetSn(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetSn(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSn sets the "sn" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableSn(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSn(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetProcessCode sets the "processCode" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetProcessCode(v int) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.ResetProcessCode()
|
||||
_u.mutation.SetProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableProcessCode(v *int) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetProcessCode(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddProcessCode adds value to the "processCode" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) AddProcessCode(v int) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.AddProcessCode(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStationNo sets the "stationNo" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetStationNo(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableStationNo(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStationNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOrderNo sets the "orderNo" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetOrderNo(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetOrderNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableOrderNo(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetOrderNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetProcessName sets the "processName" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetProcessName(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetProcessName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableProcessName sets the "processName" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableProcessName(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetProcessName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetStatus(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableStatus(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOperator sets the "operator" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetOperator(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetOperator(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableOperator(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetOperator(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResult sets the "result" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetResult(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetResult(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResult sets the "result" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableResult(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetResult(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStartedAt sets the "startedAt" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetStartedAt(v time.Time) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetStartedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStartedAt sets the "startedAt" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableStartedAt(v *time.Time) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStartedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearStartedAt clears the value of the "startedAt" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) ClearStartedAt() *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.ClearStartedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEndedAt sets the "endedAt" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetEndedAt(v time.Time) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetEndedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEndedAt sets the "endedAt" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableEndedAt(v *time.Time) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEndedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEndedAt clears the value of the "endedAt" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) ClearEndedAt() *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.ClearEndedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetRemark(v string) *WorkpieceProcessUpdateOne {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *WorkpieceProcessUpdateOne) SetNillableRemark(v *string) *WorkpieceProcessUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the WorkpieceProcessMutation object of the builder.
|
||||
func (_u *WorkpieceProcessUpdateOne) Mutation() *WorkpieceProcessMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WorkpieceProcessUpdate builder.
|
||||
func (_u *WorkpieceProcessUpdateOne) Where(ps ...predicate.WorkpieceProcess) *WorkpieceProcessUpdateOne {
|
||||
_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 *WorkpieceProcessUpdateOne) Select(field string, fields ...string) *WorkpieceProcessUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated WorkpieceProcess entity.
|
||||
func (_u *WorkpieceProcessUpdateOne) Save(ctx context.Context) (*WorkpieceProcess, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *WorkpieceProcessUpdateOne) SaveX(ctx context.Context) *WorkpieceProcess {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *WorkpieceProcessUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *WorkpieceProcessUpdateOne) 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 *WorkpieceProcessUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Sn(); ok {
|
||||
if err := workpieceprocess.SnValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.sn": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.StationNo(); ok {
|
||||
if err := workpieceprocess.StationNoValidator(v); err != nil {
|
||||
return &ValidationError{Name: "stationNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.stationNo": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.OrderNo(); ok {
|
||||
if err := workpieceprocess.OrderNoValidator(v); err != nil {
|
||||
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.orderNo": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.ProcessName(); ok {
|
||||
if err := workpieceprocess.ProcessNameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "processName", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.processName": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Status(); ok {
|
||||
if err := workpieceprocess.StatusValidator(v); err != nil {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Operator(); ok {
|
||||
if err := workpieceprocess.OperatorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.operator": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Result(); ok {
|
||||
if err := workpieceprocess.ResultValidator(v); err != nil {
|
||||
return &ValidationError{Name: "result", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.result": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := workpieceprocess.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "WorkpieceProcess.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *WorkpieceProcessUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceProcessUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *WorkpieceProcessUpdateOne) sqlSave(ctx context.Context) (_node *WorkpieceProcess, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(workpieceprocess.Table, workpieceprocess.Columns, sqlgraph.NewFieldSpec(workpieceprocess.FieldID, field.TypeInt))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "WorkpieceProcess.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, workpieceprocess.FieldID)
|
||||
for _, f := range fields {
|
||||
if !workpieceprocess.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != workpieceprocess.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.Sn(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldSn, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ProcessCode(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedProcessCode(); ok {
|
||||
_spec.AddField(workpieceprocess.FieldProcessCode, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.StationNo(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStationNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.OrderNo(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldOrderNo, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.ProcessName(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldProcessName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Operator(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldOperator, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Result(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldResult, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.StartedAt(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldStartedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.StartedAtCleared() {
|
||||
_spec.ClearField(workpieceprocess.FieldStartedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.EndedAt(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldEndedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.EndedAtCleared() {
|
||||
_spec.ClearField(workpieceprocess.FieldEndedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(workpieceprocess.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &WorkpieceProcess{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{workpieceprocess.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