489 lines
14 KiB
Go
489 lines
14 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|||
|
|
|
||
|
|
package ent
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bj_power_mes/ent/plcsendlog"
|
||
|
|
"context"
|
||
|
|
"errors"
|
||
|
|
"fmt"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||
|
|
"entgo.io/ent/schema/field"
|
||
|
|
)
|
||
|
|
|
||
|
|
// PlcSendLogCreate is the builder for creating a PlcSendLog entity.
|
||
|
|
type PlcSendLogCreate struct {
|
||
|
|
config
|
||
|
|
mutation *PlcSendLogMutation
|
||
|
|
hooks []Hook
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetOrderNo sets the "orderNo" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetOrderNo(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetOrderNo(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableOrderNo(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetOrderNo(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetSn sets the "sn" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetSn(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetSn(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableSn sets the "sn" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableSn(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetSn(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetStationNo sets the "stationNo" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetStationNo(v int) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetStationNo(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableStationNo(v *int) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetStationNo(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetProcessCombination sets the "processCombination" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetProcessCombination(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetProcessCombination(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableProcessCombination sets the "processCombination" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableProcessCombination(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetProcessCombination(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetProcessCodes sets the "processCodes" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetProcessCodes(v []int) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetProcessCodes(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetStatus sets the "status" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetStatus(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetStatus(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableStatus(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetStatus(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetSendTime sets the "sendTime" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetSendTime(v time.Time) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetSendTime(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableSendTime sets the "sendTime" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableSendTime(v *time.Time) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetSendTime(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetDoneTime sets the "doneTime" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetDoneTime(v time.Time) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetDoneTime(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableDoneTime sets the "doneTime" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableDoneTime(v *time.Time) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetDoneTime(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetAck sets the "ack" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetAck(v bool) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetAck(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableAck sets the "ack" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableAck(v *bool) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetAck(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetRemark sets the "remark" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetRemark(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetRemark(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableRemark(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetRemark(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetOperator sets the "operator" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetOperator(v string) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetOperator(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableOperator(v *string) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetOperator(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetCreatedAt sets the "createdAt" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetCreatedAt(v time.Time) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetCreatedAt(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
|
||
|
|
func (_c *PlcSendLogCreate) SetNillableCreatedAt(v *time.Time) *PlcSendLogCreate {
|
||
|
|
if v != nil {
|
||
|
|
_c.SetCreatedAt(*v)
|
||
|
|
}
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetID sets the "id" field.
|
||
|
|
func (_c *PlcSendLogCreate) SetID(v int) *PlcSendLogCreate {
|
||
|
|
_c.mutation.SetID(v)
|
||
|
|
return _c
|
||
|
|
}
|
||
|
|
|
||
|
|
// Mutation returns the PlcSendLogMutation object of the builder.
|
||
|
|
func (_c *PlcSendLogCreate) Mutation() *PlcSendLogMutation {
|
||
|
|
return _c.mutation
|
||
|
|
}
|
||
|
|
|
||
|
|
// Save creates the PlcSendLog in the database.
|
||
|
|
func (_c *PlcSendLogCreate) Save(ctx context.Context) (*PlcSendLog, error) {
|
||
|
|
_c.defaults()
|
||
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SaveX calls Save and panics if Save returns an error.
|
||
|
|
func (_c *PlcSendLogCreate) SaveX(ctx context.Context) *PlcSendLog {
|
||
|
|
v, err := _c.Save(ctx)
|
||
|
|
if err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
return v
|
||
|
|
}
|
||
|
|
|
||
|
|
// Exec executes the query.
|
||
|
|
func (_c *PlcSendLogCreate) Exec(ctx context.Context) error {
|
||
|
|
_, err := _c.Save(ctx)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
|
func (_c *PlcSendLogCreate) ExecX(ctx context.Context) {
|
||
|
|
if err := _c.Exec(ctx); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// defaults sets the default values of the builder before save.
|
||
|
|
func (_c *PlcSendLogCreate) defaults() {
|
||
|
|
if _, ok := _c.mutation.OrderNo(); !ok {
|
||
|
|
v := plcsendlog.DefaultOrderNo
|
||
|
|
_c.mutation.SetOrderNo(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Sn(); !ok {
|
||
|
|
v := plcsendlog.DefaultSn
|
||
|
|
_c.mutation.SetSn(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.ProcessCombination(); !ok {
|
||
|
|
v := plcsendlog.DefaultProcessCombination
|
||
|
|
_c.mutation.SetProcessCombination(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Status(); !ok {
|
||
|
|
v := plcsendlog.DefaultStatus
|
||
|
|
_c.mutation.SetStatus(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Ack(); !ok {
|
||
|
|
v := plcsendlog.DefaultAck
|
||
|
|
_c.mutation.SetAck(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Remark(); !ok {
|
||
|
|
v := plcsendlog.DefaultRemark
|
||
|
|
_c.mutation.SetRemark(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Operator(); !ok {
|
||
|
|
v := plcsendlog.DefaultOperator
|
||
|
|
_c.mutation.SetOperator(v)
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||
|
|
v := plcsendlog.DefaultCreatedAt()
|
||
|
|
_c.mutation.SetCreatedAt(v)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// check runs all checks and user-defined validators on the builder.
|
||
|
|
func (_c *PlcSendLogCreate) check() error {
|
||
|
|
if _, ok := _c.mutation.OrderNo(); !ok {
|
||
|
|
return &ValidationError{Name: "orderNo", err: errors.New(`ent: missing required field "PlcSendLog.orderNo"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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 _, ok := _c.mutation.Sn(); !ok {
|
||
|
|
return &ValidationError{Name: "sn", err: errors.New(`ent: missing required field "PlcSendLog.sn"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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 _, ok := _c.mutation.ProcessCombination(); !ok {
|
||
|
|
return &ValidationError{Name: "processCombination", err: errors.New(`ent: missing required field "PlcSendLog.processCombination"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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 _, ok := _c.mutation.Status(); !ok {
|
||
|
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "PlcSendLog.status"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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 _, ok := _c.mutation.Ack(); !ok {
|
||
|
|
return &ValidationError{Name: "ack", err: errors.New(`ent: missing required field "PlcSendLog.ack"`)}
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.Remark(); !ok {
|
||
|
|
return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "PlcSendLog.remark"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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 _, ok := _c.mutation.Operator(); !ok {
|
||
|
|
return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "PlcSendLog.operator"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.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)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||
|
|
return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "PlcSendLog.createdAt"`)}
|
||
|
|
}
|
||
|
|
if v, ok := _c.mutation.ID(); ok {
|
||
|
|
if err := plcsendlog.IDValidator(v); err != nil {
|
||
|
|
return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "PlcSendLog.id": %w`, err)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (_c *PlcSendLogCreate) sqlSave(ctx context.Context) (*PlcSendLog, error) {
|
||
|
|
if err := _c.check(); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
_node, _spec := _c.createSpec()
|
||
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||
|
|
if sqlgraph.IsConstraintError(err) {
|
||
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
|
}
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
if _spec.ID.Value != _node.ID {
|
||
|
|
id := _spec.ID.Value.(int64)
|
||
|
|
_node.ID = int(id)
|
||
|
|
}
|
||
|
|
_c.mutation.id = &_node.ID
|
||
|
|
_c.mutation.done = true
|
||
|
|
return _node, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (_c *PlcSendLogCreate) createSpec() (*PlcSendLog, *sqlgraph.CreateSpec) {
|
||
|
|
var (
|
||
|
|
_node = &PlcSendLog{config: _c.config}
|
||
|
|
_spec = sqlgraph.NewCreateSpec(plcsendlog.Table, sqlgraph.NewFieldSpec(plcsendlog.FieldID, field.TypeInt))
|
||
|
|
)
|
||
|
|
if id, ok := _c.mutation.ID(); ok {
|
||
|
|
_node.ID = id
|
||
|
|
_spec.ID.Value = id
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.OrderNo(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldOrderNo, field.TypeString, value)
|
||
|
|
_node.OrderNo = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.Sn(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldSn, field.TypeString, value)
|
||
|
|
_node.Sn = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.StationNo(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldStationNo, field.TypeInt, value)
|
||
|
|
_node.StationNo = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.ProcessCombination(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldProcessCombination, field.TypeString, value)
|
||
|
|
_node.ProcessCombination = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.ProcessCodes(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldProcessCodes, field.TypeJSON, value)
|
||
|
|
_node.ProcessCodes = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.Status(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldStatus, field.TypeString, value)
|
||
|
|
_node.Status = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.SendTime(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldSendTime, field.TypeTime, value)
|
||
|
|
_node.SendTime = &value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.DoneTime(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldDoneTime, field.TypeTime, value)
|
||
|
|
_node.DoneTime = &value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.Ack(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldAck, field.TypeBool, value)
|
||
|
|
_node.Ack = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.Remark(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldRemark, field.TypeString, value)
|
||
|
|
_node.Remark = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.Operator(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldOperator, field.TypeString, value)
|
||
|
|
_node.Operator = value
|
||
|
|
}
|
||
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
||
|
|
_spec.SetField(plcsendlog.FieldCreatedAt, field.TypeTime, value)
|
||
|
|
_node.CreatedAt = value
|
||
|
|
}
|
||
|
|
return _node, _spec
|
||
|
|
}
|
||
|
|
|
||
|
|
// PlcSendLogCreateBulk is the builder for creating many PlcSendLog entities in bulk.
|
||
|
|
type PlcSendLogCreateBulk struct {
|
||
|
|
config
|
||
|
|
err error
|
||
|
|
builders []*PlcSendLogCreate
|
||
|
|
}
|
||
|
|
|
||
|
|
// Save creates the PlcSendLog entities in the database.
|
||
|
|
func (_c *PlcSendLogCreateBulk) Save(ctx context.Context) ([]*PlcSendLog, error) {
|
||
|
|
if _c.err != nil {
|
||
|
|
return nil, _c.err
|
||
|
|
}
|
||
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||
|
|
nodes := make([]*PlcSendLog, len(_c.builders))
|
||
|
|
mutators := make([]Mutator, len(_c.builders))
|
||
|
|
for i := range _c.builders {
|
||
|
|
func(i int, root context.Context) {
|
||
|
|
builder := _c.builders[i]
|
||
|
|
builder.defaults()
|
||
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||
|
|
mutation, ok := m.(*PlcSendLogMutation)
|
||
|
|
if !ok {
|
||
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||
|
|
}
|
||
|
|
if err := builder.check(); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
builder.mutation = mutation
|
||
|
|
var err error
|
||
|
|
nodes[i], specs[i] = builder.createSpec()
|
||
|
|
if i < len(mutators)-1 {
|
||
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||
|
|
} else {
|
||
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
||
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||
|
|
if sqlgraph.IsConstraintError(err) {
|
||
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
mutation.id = &nodes[i].ID
|
||
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
||
|
|
id := specs[i].ID.Value.(int64)
|
||
|
|
nodes[i].ID = int(id)
|
||
|
|
}
|
||
|
|
mutation.done = true
|
||
|
|
return nodes[i], nil
|
||
|
|
})
|
||
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||
|
|
mut = builder.hooks[i](mut)
|
||
|
|
}
|
||
|
|
mutators[i] = mut
|
||
|
|
}(i, ctx)
|
||
|
|
}
|
||
|
|
if len(mutators) > 0 {
|
||
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nodes, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// SaveX is like Save, but panics if an error occurs.
|
||
|
|
func (_c *PlcSendLogCreateBulk) SaveX(ctx context.Context) []*PlcSendLog {
|
||
|
|
v, err := _c.Save(ctx)
|
||
|
|
if err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
return v
|
||
|
|
}
|
||
|
|
|
||
|
|
// Exec executes the query.
|
||
|
|
func (_c *PlcSendLogCreateBulk) Exec(ctx context.Context) error {
|
||
|
|
_, err := _c.Save(ctx)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
|
func (_c *PlcSendLogCreateBulk) ExecX(ctx context.Context) {
|
||
|
|
if err := _c.Exec(ctx); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|