742 lines
22 KiB
Go
742 lines
22 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/plcsendlog"
|
|
"bj_power_mes/ent/predicate"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/dialect/sql/sqljson"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// PlcSendLogUpdate is the builder for updating PlcSendLog entities.
|
|
type PlcSendLogUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *PlcSendLogMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the PlcSendLogUpdate builder.
|
|
func (_u *PlcSendLogUpdate) Where(ps ...predicate.PlcSendLog) *PlcSendLogUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetOrderNo sets the "orderNo" field.
|
|
func (_u *PlcSendLogUpdate) SetOrderNo(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetOrderNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableOrderNo(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetOrderNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSn sets the "sn" field.
|
|
func (_u *PlcSendLogUpdate) SetSn(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetSn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSn sets the "sn" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableSn(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetSn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStationNo sets the "stationNo" field.
|
|
func (_u *PlcSendLogUpdate) SetStationNo(v int) *PlcSendLogUpdate {
|
|
_u.mutation.ResetStationNo()
|
|
_u.mutation.SetStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableStationNo(v *int) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStationNo adds value to the "stationNo" field.
|
|
func (_u *PlcSendLogUpdate) AddStationNo(v int) *PlcSendLogUpdate {
|
|
_u.mutation.AddStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearStationNo clears the value of the "stationNo" field.
|
|
func (_u *PlcSendLogUpdate) ClearStationNo() *PlcSendLogUpdate {
|
|
_u.mutation.ClearStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetProcessCombination sets the "processCombination" field.
|
|
func (_u *PlcSendLogUpdate) SetProcessCombination(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetProcessCombination(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProcessCombination sets the "processCombination" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableProcessCombination(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetProcessCombination(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProcessCodes sets the "processCodes" field.
|
|
func (_u *PlcSendLogUpdate) SetProcessCodes(v []int) *PlcSendLogUpdate {
|
|
_u.mutation.SetProcessCodes(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendProcessCodes appends value to the "processCodes" field.
|
|
func (_u *PlcSendLogUpdate) AppendProcessCodes(v []int) *PlcSendLogUpdate {
|
|
_u.mutation.AppendProcessCodes(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearProcessCodes clears the value of the "processCodes" field.
|
|
func (_u *PlcSendLogUpdate) ClearProcessCodes() *PlcSendLogUpdate {
|
|
_u.mutation.ClearProcessCodes()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *PlcSendLogUpdate) SetStatus(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableStatus(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSendTime sets the "sendTime" field.
|
|
func (_u *PlcSendLogUpdate) SetSendTime(v time.Time) *PlcSendLogUpdate {
|
|
_u.mutation.SetSendTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSendTime sets the "sendTime" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableSendTime(v *time.Time) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetSendTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSendTime clears the value of the "sendTime" field.
|
|
func (_u *PlcSendLogUpdate) ClearSendTime() *PlcSendLogUpdate {
|
|
_u.mutation.ClearSendTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDoneTime sets the "doneTime" field.
|
|
func (_u *PlcSendLogUpdate) SetDoneTime(v time.Time) *PlcSendLogUpdate {
|
|
_u.mutation.SetDoneTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDoneTime sets the "doneTime" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableDoneTime(v *time.Time) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetDoneTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDoneTime clears the value of the "doneTime" field.
|
|
func (_u *PlcSendLogUpdate) ClearDoneTime() *PlcSendLogUpdate {
|
|
_u.mutation.ClearDoneTime()
|
|
return _u
|
|
}
|
|
|
|
// SetAck sets the "ack" field.
|
|
func (_u *PlcSendLogUpdate) SetAck(v bool) *PlcSendLogUpdate {
|
|
_u.mutation.SetAck(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAck sets the "ack" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableAck(v *bool) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetAck(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *PlcSendLogUpdate) SetRemark(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableRemark(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *PlcSendLogUpdate) SetOperator(v string) *PlcSendLogUpdate {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdate) SetNillableOperator(v *string) *PlcSendLogUpdate {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the PlcSendLogMutation object of the builder.
|
|
func (_u *PlcSendLogUpdate) Mutation() *PlcSendLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *PlcSendLogUpdate) 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 *PlcSendLogUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *PlcSendLogUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PlcSendLogUpdate) 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 *PlcSendLogUpdate) check() error {
|
|
if v, ok := _u.mutation.OrderNo(); ok {
|
|
if err := plcsendlog.OrderNoValidator(v); err != nil {
|
|
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.orderNo": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Sn(); ok {
|
|
if err := plcsendlog.SnValidator(v); err != nil {
|
|
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.sn": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProcessCombination(); ok {
|
|
if err := plcsendlog.ProcessCombinationValidator(v); err != nil {
|
|
return &ValidationError{Name: "processCombination", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.processCombination": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := plcsendlog.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := plcsendlog.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.remark": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Operator(); ok {
|
|
if err := plcsendlog.OperatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.operator": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *PlcSendLogUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlcSendLogUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *PlcSendLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(plcsendlog.Table, plcsendlog.Columns, sqlgraph.NewFieldSpec(plcsendlog.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.OrderNo(); ok {
|
|
_spec.SetField(plcsendlog.FieldOrderNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Sn(); ok {
|
|
_spec.SetField(plcsendlog.FieldSn, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.StationNo(); ok {
|
|
_spec.SetField(plcsendlog.FieldStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStationNo(); ok {
|
|
_spec.AddField(plcsendlog.FieldStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.StationNoCleared() {
|
|
_spec.ClearField(plcsendlog.FieldStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.ProcessCombination(); ok {
|
|
_spec.SetField(plcsendlog.FieldProcessCombination, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProcessCodes(); ok {
|
|
_spec.SetField(plcsendlog.FieldProcessCodes, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedProcessCodes(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, plcsendlog.FieldProcessCodes, value)
|
|
})
|
|
}
|
|
if _u.mutation.ProcessCodesCleared() {
|
|
_spec.ClearField(plcsendlog.FieldProcessCodes, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(plcsendlog.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SendTime(); ok {
|
|
_spec.SetField(plcsendlog.FieldSendTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SendTimeCleared() {
|
|
_spec.ClearField(plcsendlog.FieldSendTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.DoneTime(); ok {
|
|
_spec.SetField(plcsendlog.FieldDoneTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DoneTimeCleared() {
|
|
_spec.ClearField(plcsendlog.FieldDoneTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Ack(); ok {
|
|
_spec.SetField(plcsendlog.FieldAck, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(plcsendlog.FieldRemark, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(plcsendlog.FieldOperator, 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{plcsendlog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// PlcSendLogUpdateOne is the builder for updating a single PlcSendLog entity.
|
|
type PlcSendLogUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *PlcSendLogMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetOrderNo sets the "orderNo" field.
|
|
func (_u *PlcSendLogUpdateOne) SetOrderNo(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetOrderNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableOrderNo(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetOrderNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSn sets the "sn" field.
|
|
func (_u *PlcSendLogUpdateOne) SetSn(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetSn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSn sets the "sn" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableSn(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetSn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStationNo sets the "stationNo" field.
|
|
func (_u *PlcSendLogUpdateOne) SetStationNo(v int) *PlcSendLogUpdateOne {
|
|
_u.mutation.ResetStationNo()
|
|
_u.mutation.SetStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableStationNo(v *int) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStationNo adds value to the "stationNo" field.
|
|
func (_u *PlcSendLogUpdateOne) AddStationNo(v int) *PlcSendLogUpdateOne {
|
|
_u.mutation.AddStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearStationNo clears the value of the "stationNo" field.
|
|
func (_u *PlcSendLogUpdateOne) ClearStationNo() *PlcSendLogUpdateOne {
|
|
_u.mutation.ClearStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetProcessCombination sets the "processCombination" field.
|
|
func (_u *PlcSendLogUpdateOne) SetProcessCombination(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetProcessCombination(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProcessCombination sets the "processCombination" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableProcessCombination(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetProcessCombination(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProcessCodes sets the "processCodes" field.
|
|
func (_u *PlcSendLogUpdateOne) SetProcessCodes(v []int) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetProcessCodes(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendProcessCodes appends value to the "processCodes" field.
|
|
func (_u *PlcSendLogUpdateOne) AppendProcessCodes(v []int) *PlcSendLogUpdateOne {
|
|
_u.mutation.AppendProcessCodes(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearProcessCodes clears the value of the "processCodes" field.
|
|
func (_u *PlcSendLogUpdateOne) ClearProcessCodes() *PlcSendLogUpdateOne {
|
|
_u.mutation.ClearProcessCodes()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *PlcSendLogUpdateOne) SetStatus(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableStatus(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSendTime sets the "sendTime" field.
|
|
func (_u *PlcSendLogUpdateOne) SetSendTime(v time.Time) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetSendTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSendTime sets the "sendTime" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableSendTime(v *time.Time) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetSendTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSendTime clears the value of the "sendTime" field.
|
|
func (_u *PlcSendLogUpdateOne) ClearSendTime() *PlcSendLogUpdateOne {
|
|
_u.mutation.ClearSendTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDoneTime sets the "doneTime" field.
|
|
func (_u *PlcSendLogUpdateOne) SetDoneTime(v time.Time) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetDoneTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDoneTime sets the "doneTime" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableDoneTime(v *time.Time) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetDoneTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDoneTime clears the value of the "doneTime" field.
|
|
func (_u *PlcSendLogUpdateOne) ClearDoneTime() *PlcSendLogUpdateOne {
|
|
_u.mutation.ClearDoneTime()
|
|
return _u
|
|
}
|
|
|
|
// SetAck sets the "ack" field.
|
|
func (_u *PlcSendLogUpdateOne) SetAck(v bool) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetAck(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAck sets the "ack" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableAck(v *bool) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetAck(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *PlcSendLogUpdateOne) SetRemark(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableRemark(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOperator sets the "operator" field.
|
|
func (_u *PlcSendLogUpdateOne) SetOperator(v string) *PlcSendLogUpdateOne {
|
|
_u.mutation.SetOperator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
|
func (_u *PlcSendLogUpdateOne) SetNillableOperator(v *string) *PlcSendLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetOperator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the PlcSendLogMutation object of the builder.
|
|
func (_u *PlcSendLogUpdateOne) Mutation() *PlcSendLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the PlcSendLogUpdate builder.
|
|
func (_u *PlcSendLogUpdateOne) Where(ps ...predicate.PlcSendLog) *PlcSendLogUpdateOne {
|
|
_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 *PlcSendLogUpdateOne) Select(field string, fields ...string) *PlcSendLogUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated PlcSendLog entity.
|
|
func (_u *PlcSendLogUpdateOne) Save(ctx context.Context) (*PlcSendLog, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *PlcSendLogUpdateOne) SaveX(ctx context.Context) *PlcSendLog {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *PlcSendLogUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PlcSendLogUpdateOne) 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 *PlcSendLogUpdateOne) check() error {
|
|
if v, ok := _u.mutation.OrderNo(); ok {
|
|
if err := plcsendlog.OrderNoValidator(v); err != nil {
|
|
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.orderNo": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Sn(); ok {
|
|
if err := plcsendlog.SnValidator(v); err != nil {
|
|
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.sn": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProcessCombination(); ok {
|
|
if err := plcsendlog.ProcessCombinationValidator(v); err != nil {
|
|
return &ValidationError{Name: "processCombination", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.processCombination": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := plcsendlog.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := plcsendlog.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.remark": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Operator(); ok {
|
|
if err := plcsendlog.OperatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.operator": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *PlcSendLogUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlcSendLogUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *PlcSendLogUpdateOne) sqlSave(ctx context.Context) (_node *PlcSendLog, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(plcsendlog.Table, plcsendlog.Columns, sqlgraph.NewFieldSpec(plcsendlog.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PlcSendLog.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, plcsendlog.FieldID)
|
|
for _, f := range fields {
|
|
if !plcsendlog.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != plcsendlog.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.OrderNo(); ok {
|
|
_spec.SetField(plcsendlog.FieldOrderNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Sn(); ok {
|
|
_spec.SetField(plcsendlog.FieldSn, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.StationNo(); ok {
|
|
_spec.SetField(plcsendlog.FieldStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStationNo(); ok {
|
|
_spec.AddField(plcsendlog.FieldStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.StationNoCleared() {
|
|
_spec.ClearField(plcsendlog.FieldStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.ProcessCombination(); ok {
|
|
_spec.SetField(plcsendlog.FieldProcessCombination, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProcessCodes(); ok {
|
|
_spec.SetField(plcsendlog.FieldProcessCodes, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedProcessCodes(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, plcsendlog.FieldProcessCodes, value)
|
|
})
|
|
}
|
|
if _u.mutation.ProcessCodesCleared() {
|
|
_spec.ClearField(plcsendlog.FieldProcessCodes, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(plcsendlog.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SendTime(); ok {
|
|
_spec.SetField(plcsendlog.FieldSendTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SendTimeCleared() {
|
|
_spec.ClearField(plcsendlog.FieldSendTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.DoneTime(); ok {
|
|
_spec.SetField(plcsendlog.FieldDoneTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DoneTimeCleared() {
|
|
_spec.ClearField(plcsendlog.FieldDoneTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Ack(); ok {
|
|
_spec.SetField(plcsendlog.FieldAck, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(plcsendlog.FieldRemark, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Operator(); ok {
|
|
_spec.SetField(plcsendlog.FieldOperator, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &PlcSendLog{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{plcsendlog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|