本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
998 lines
27 KiB
Go
998 lines
27 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/dock"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// DockCreate is the builder for creating a Dock entity.
|
|
type DockCreate struct {
|
|
config
|
|
mutation *DockMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDockCode sets the "dock_code" field.
|
|
func (_c *DockCreate) SetDockCode(v string) *DockCreate {
|
|
_c.mutation.SetDockCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *DockCreate) SetName(v string) *DockCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableName(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetName(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDockType sets the "dock_type" field.
|
|
func (_c *DockCreate) SetDockType(v string) *DockCreate {
|
|
_c.mutation.SetDockType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDockType sets the "dock_type" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableDockType(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetDockType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStationNo sets the "station_no" field.
|
|
func (_c *DockCreate) SetStationNo(v int) *DockCreate {
|
|
_c.mutation.SetStationNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStationNo sets the "station_no" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableStationNo(v *int) *DockCreate {
|
|
if v != nil {
|
|
_c.SetStationNo(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (_c *DockCreate) SetHasPallet(v bool) *DockCreate {
|
|
_c.mutation.SetHasPallet(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableHasPallet sets the "has_pallet" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableHasPallet(v *bool) *DockCreate {
|
|
if v != nil {
|
|
_c.SetHasPallet(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPalletRef sets the "pallet_ref" field.
|
|
func (_c *DockCreate) SetPalletRef(v string) *DockCreate {
|
|
_c.mutation.SetPalletRef(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePalletRef sets the "pallet_ref" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillablePalletRef(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetPalletRef(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *DockCreate) SetStatus(v string) *DockCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableStatus(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *DockCreate) SetCreatedAt(v int64) *DockCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableCreatedAt(v *int64) *DockCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the DockMutation object of the builder.
|
|
func (_c *DockCreate) Mutation() *DockMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the Dock in the database.
|
|
func (_c *DockCreate) Save(ctx context.Context) (*Dock, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *DockCreate) SaveX(ctx context.Context) *Dock {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *DockCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *DockCreate) 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 *DockCreate) defaults() {
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
v := dock.DefaultName
|
|
_c.mutation.SetName(v)
|
|
}
|
|
if _, ok := _c.mutation.DockType(); !ok {
|
|
v := dock.DefaultDockType
|
|
_c.mutation.SetDockType(v)
|
|
}
|
|
if _, ok := _c.mutation.StationNo(); !ok {
|
|
v := dock.DefaultStationNo
|
|
_c.mutation.SetStationNo(v)
|
|
}
|
|
if _, ok := _c.mutation.HasPallet(); !ok {
|
|
v := dock.DefaultHasPallet
|
|
_c.mutation.SetHasPallet(v)
|
|
}
|
|
if _, ok := _c.mutation.PalletRef(); !ok {
|
|
v := dock.DefaultPalletRef
|
|
_c.mutation.SetPalletRef(v)
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := dock.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := dock.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *DockCreate) check() error {
|
|
if _, ok := _c.mutation.DockCode(); !ok {
|
|
return &ValidationError{Name: "dock_code", err: errors.New(`ent: missing required field "Dock.dock_code"`)}
|
|
}
|
|
if v, ok := _c.mutation.DockCode(); ok {
|
|
if err := dock.DockCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "dock_code", err: fmt.Errorf(`ent: validator failed for field "Dock.dock_code": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Dock.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := dock.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Dock.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.DockType(); !ok {
|
|
return &ValidationError{Name: "dock_type", err: errors.New(`ent: missing required field "Dock.dock_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.DockType(); ok {
|
|
if err := dock.DockTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "dock_type", err: fmt.Errorf(`ent: validator failed for field "Dock.dock_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.StationNo(); !ok {
|
|
return &ValidationError{Name: "station_no", err: errors.New(`ent: missing required field "Dock.station_no"`)}
|
|
}
|
|
if _, ok := _c.mutation.HasPallet(); !ok {
|
|
return &ValidationError{Name: "has_pallet", err: errors.New(`ent: missing required field "Dock.has_pallet"`)}
|
|
}
|
|
if v, ok := _c.mutation.PalletRef(); ok {
|
|
if err := dock.PalletRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "pallet_ref", err: fmt.Errorf(`ent: validator failed for field "Dock.pallet_ref": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Dock.status"`)}
|
|
}
|
|
if v, ok := _c.mutation.Status(); ok {
|
|
if err := dock.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Dock.status": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Dock.created_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *DockCreate) sqlSave(ctx context.Context) (*Dock, 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
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *DockCreate) createSpec() (*Dock, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Dock{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(dock.Table, sqlgraph.NewFieldSpec(dock.FieldID, field.TypeInt))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.DockCode(); ok {
|
|
_spec.SetField(dock.FieldDockCode, field.TypeString, value)
|
|
_node.DockCode = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(dock.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.DockType(); ok {
|
|
_spec.SetField(dock.FieldDockType, field.TypeString, value)
|
|
_node.DockType = value
|
|
}
|
|
if value, ok := _c.mutation.StationNo(); ok {
|
|
_spec.SetField(dock.FieldStationNo, field.TypeInt, value)
|
|
_node.StationNo = value
|
|
}
|
|
if value, ok := _c.mutation.HasPallet(); ok {
|
|
_spec.SetField(dock.FieldHasPallet, field.TypeBool, value)
|
|
_node.HasPallet = value
|
|
}
|
|
if value, ok := _c.mutation.PalletRef(); ok {
|
|
_spec.SetField(dock.FieldPalletRef, field.TypeString, value)
|
|
_node.PalletRef = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(dock.FieldStatus, field.TypeString, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(dock.FieldCreatedAt, field.TypeInt64, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Dock.Create().
|
|
// SetDockCode(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.DockUpsert) {
|
|
// SetDockCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *DockCreate) OnConflict(opts ...sql.ConflictOption) *DockUpsertOne {
|
|
_c.conflict = opts
|
|
return &DockUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *DockCreate) OnConflictColumns(columns ...string) *DockUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &DockUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// DockUpsertOne is the builder for "upsert"-ing
|
|
// one Dock node.
|
|
DockUpsertOne struct {
|
|
create *DockCreate
|
|
}
|
|
|
|
// DockUpsert is the "OnConflict" setter.
|
|
DockUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDockCode sets the "dock_code" field.
|
|
func (u *DockUpsert) SetDockCode(v string) *DockUpsert {
|
|
u.Set(dock.FieldDockCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDockCode sets the "dock_code" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateDockCode() *DockUpsert {
|
|
u.SetExcluded(dock.FieldDockCode)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *DockUpsert) SetName(v string) *DockUpsert {
|
|
u.Set(dock.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateName() *DockUpsert {
|
|
u.SetExcluded(dock.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetDockType sets the "dock_type" field.
|
|
func (u *DockUpsert) SetDockType(v string) *DockUpsert {
|
|
u.Set(dock.FieldDockType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDockType sets the "dock_type" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateDockType() *DockUpsert {
|
|
u.SetExcluded(dock.FieldDockType)
|
|
return u
|
|
}
|
|
|
|
// SetStationNo sets the "station_no" field.
|
|
func (u *DockUpsert) SetStationNo(v int) *DockUpsert {
|
|
u.Set(dock.FieldStationNo, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStationNo sets the "station_no" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateStationNo() *DockUpsert {
|
|
u.SetExcluded(dock.FieldStationNo)
|
|
return u
|
|
}
|
|
|
|
// AddStationNo adds v to the "station_no" field.
|
|
func (u *DockUpsert) AddStationNo(v int) *DockUpsert {
|
|
u.Add(dock.FieldStationNo, v)
|
|
return u
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (u *DockUpsert) SetHasPallet(v bool) *DockUpsert {
|
|
u.Set(dock.FieldHasPallet, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateHasPallet sets the "has_pallet" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateHasPallet() *DockUpsert {
|
|
u.SetExcluded(dock.FieldHasPallet)
|
|
return u
|
|
}
|
|
|
|
// SetPalletRef sets the "pallet_ref" field.
|
|
func (u *DockUpsert) SetPalletRef(v string) *DockUpsert {
|
|
u.Set(dock.FieldPalletRef, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePalletRef sets the "pallet_ref" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdatePalletRef() *DockUpsert {
|
|
u.SetExcluded(dock.FieldPalletRef)
|
|
return u
|
|
}
|
|
|
|
// ClearPalletRef clears the value of the "pallet_ref" field.
|
|
func (u *DockUpsert) ClearPalletRef() *DockUpsert {
|
|
u.SetNull(dock.FieldPalletRef)
|
|
return u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *DockUpsert) SetStatus(v string) *DockUpsert {
|
|
u.Set(dock.FieldStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateStatus() *DockUpsert {
|
|
u.SetExcluded(dock.FieldStatus)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *DockUpsert) SetCreatedAt(v int64) *DockUpsert {
|
|
u.Set(dock.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *DockUpsert) UpdateCreatedAt() *DockUpsert {
|
|
u.SetExcluded(dock.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *DockUpsert) AddCreatedAt(v int64) *DockUpsert {
|
|
u.Add(dock.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *DockUpsertOne) UpdateNewValues() *DockUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *DockUpsertOne) Ignore() *DockUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *DockUpsertOne) DoNothing() *DockUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the DockCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *DockUpsertOne) Update(set func(*DockUpsert)) *DockUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&DockUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDockCode sets the "dock_code" field.
|
|
func (u *DockUpsertOne) SetDockCode(v string) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetDockCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDockCode sets the "dock_code" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateDockCode() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateDockCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *DockUpsertOne) SetName(v string) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateName() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDockType sets the "dock_type" field.
|
|
func (u *DockUpsertOne) SetDockType(v string) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetDockType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDockType sets the "dock_type" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateDockType() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateDockType()
|
|
})
|
|
}
|
|
|
|
// SetStationNo sets the "station_no" field.
|
|
func (u *DockUpsertOne) SetStationNo(v int) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetStationNo(v)
|
|
})
|
|
}
|
|
|
|
// AddStationNo adds v to the "station_no" field.
|
|
func (u *DockUpsertOne) AddStationNo(v int) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.AddStationNo(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStationNo sets the "station_no" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateStationNo() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateStationNo()
|
|
})
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (u *DockUpsertOne) SetHasPallet(v bool) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetHasPallet(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHasPallet sets the "has_pallet" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateHasPallet() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateHasPallet()
|
|
})
|
|
}
|
|
|
|
// SetPalletRef sets the "pallet_ref" field.
|
|
func (u *DockUpsertOne) SetPalletRef(v string) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetPalletRef(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePalletRef sets the "pallet_ref" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdatePalletRef() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdatePalletRef()
|
|
})
|
|
}
|
|
|
|
// ClearPalletRef clears the value of the "pallet_ref" field.
|
|
func (u *DockUpsertOne) ClearPalletRef() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.ClearPalletRef()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *DockUpsertOne) SetStatus(v string) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateStatus() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *DockUpsertOne) SetCreatedAt(v int64) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *DockUpsertOne) AddCreatedAt(v int64) *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *DockUpsertOne) UpdateCreatedAt() *DockUpsertOne {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *DockUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for DockCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *DockUpsertOne) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
func (u *DockUpsertOne) ID(ctx context.Context) (id int, err error) {
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *DockUpsertOne) IDX(ctx context.Context) int {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// DockCreateBulk is the builder for creating many Dock entities in bulk.
|
|
type DockCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*DockCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the Dock entities in the database.
|
|
func (_c *DockCreateBulk) Save(ctx context.Context) ([]*Dock, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*Dock, 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.(*DockMutation)
|
|
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}
|
|
spec.OnConflict = _c.conflict
|
|
// 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 {
|
|
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 *DockCreateBulk) SaveX(ctx context.Context) []*Dock {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *DockCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *DockCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Dock.CreateBulk(builders...).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.DockUpsert) {
|
|
// SetDockCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *DockCreateBulk) OnConflict(opts ...sql.ConflictOption) *DockUpsertBulk {
|
|
_c.conflict = opts
|
|
return &DockUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *DockCreateBulk) OnConflictColumns(columns ...string) *DockUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &DockUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// DockUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of Dock nodes.
|
|
type DockUpsertBulk struct {
|
|
create *DockCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *DockUpsertBulk) UpdateNewValues() *DockUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Dock.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *DockUpsertBulk) Ignore() *DockUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *DockUpsertBulk) DoNothing() *DockUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the DockCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *DockUpsertBulk) Update(set func(*DockUpsert)) *DockUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&DockUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDockCode sets the "dock_code" field.
|
|
func (u *DockUpsertBulk) SetDockCode(v string) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetDockCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDockCode sets the "dock_code" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateDockCode() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateDockCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *DockUpsertBulk) SetName(v string) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateName() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetDockType sets the "dock_type" field.
|
|
func (u *DockUpsertBulk) SetDockType(v string) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetDockType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDockType sets the "dock_type" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateDockType() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateDockType()
|
|
})
|
|
}
|
|
|
|
// SetStationNo sets the "station_no" field.
|
|
func (u *DockUpsertBulk) SetStationNo(v int) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetStationNo(v)
|
|
})
|
|
}
|
|
|
|
// AddStationNo adds v to the "station_no" field.
|
|
func (u *DockUpsertBulk) AddStationNo(v int) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.AddStationNo(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStationNo sets the "station_no" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateStationNo() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateStationNo()
|
|
})
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (u *DockUpsertBulk) SetHasPallet(v bool) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetHasPallet(v)
|
|
})
|
|
}
|
|
|
|
// UpdateHasPallet sets the "has_pallet" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateHasPallet() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateHasPallet()
|
|
})
|
|
}
|
|
|
|
// SetPalletRef sets the "pallet_ref" field.
|
|
func (u *DockUpsertBulk) SetPalletRef(v string) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetPalletRef(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePalletRef sets the "pallet_ref" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdatePalletRef() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdatePalletRef()
|
|
})
|
|
}
|
|
|
|
// ClearPalletRef clears the value of the "pallet_ref" field.
|
|
func (u *DockUpsertBulk) ClearPalletRef() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.ClearPalletRef()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *DockUpsertBulk) SetStatus(v string) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateStatus() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *DockUpsertBulk) SetCreatedAt(v int64) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *DockUpsertBulk) AddCreatedAt(v int64) *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *DockUpsertBulk) UpdateCreatedAt() *DockUpsertBulk {
|
|
return u.Update(func(s *DockUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *DockUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the DockCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for DockCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *DockUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|