Files
bj_power/bj_power_wms/ent/semifinished_create.go
T
SunYF 47573e44b0 feat&fix: 完善半成品/序列号闭环流转逻辑
1. 调整物料编码字段为可空,优化注释说明
2. 修复Vite构建自动清空产物目录冲突问题
3. 优化前端提示文案与表单占位符
4. 为各前端项目添加内联SVG图标
5. 重构MES半成品流转逻辑,不再静默吞掉WMS错误并记录日志
6. 生成并添加空的WMS客户端静态文件
7. 完善Ent ORM模型的空值支持与查询谓词
8. 优化半成品入库接口,支持doneProcessCodes数组格式,新增SN反查物料编码逻辑
9. 更新帮助文档与操作手册
2026-09-01 14:30:26 +08:00

1093 lines
32 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/semifinished"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// SemiFinishedCreate is the builder for creating a SemiFinished entity.
type SemiFinishedCreate struct {
config
mutation *SemiFinishedMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetSn sets the "sn" field.
func (_c *SemiFinishedCreate) SetSn(v string) *SemiFinishedCreate {
_c.mutation.SetSn(v)
return _c
}
// SetMaterialCode sets the "material_code" field.
func (_c *SemiFinishedCreate) SetMaterialCode(v string) *SemiFinishedCreate {
_c.mutation.SetMaterialCode(v)
return _c
}
// SetNillableMaterialCode sets the "material_code" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableMaterialCode(v *string) *SemiFinishedCreate {
if v != nil {
_c.SetMaterialCode(*v)
}
return _c
}
// SetCompletedProcess sets the "completed_process" field.
func (_c *SemiFinishedCreate) SetCompletedProcess(v string) *SemiFinishedCreate {
_c.mutation.SetCompletedProcess(v)
return _c
}
// SetNillableCompletedProcess sets the "completed_process" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableCompletedProcess(v *string) *SemiFinishedCreate {
if v != nil {
_c.SetCompletedProcess(*v)
}
return _c
}
// SetQuantity sets the "quantity" field.
func (_c *SemiFinishedCreate) SetQuantity(v int) *SemiFinishedCreate {
_c.mutation.SetQuantity(v)
return _c
}
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableQuantity(v *int) *SemiFinishedCreate {
if v != nil {
_c.SetQuantity(*v)
}
return _c
}
// SetZoneCode sets the "zone_code" field.
func (_c *SemiFinishedCreate) SetZoneCode(v string) *SemiFinishedCreate {
_c.mutation.SetZoneCode(v)
return _c
}
// SetNillableZoneCode sets the "zone_code" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableZoneCode(v *string) *SemiFinishedCreate {
if v != nil {
_c.SetZoneCode(*v)
}
return _c
}
// SetStatus sets the "status" field.
func (_c *SemiFinishedCreate) SetStatus(v string) *SemiFinishedCreate {
_c.mutation.SetStatus(v)
return _c
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableStatus(v *string) *SemiFinishedCreate {
if v != nil {
_c.SetStatus(*v)
}
return _c
}
// SetOrderNo sets the "order_no" field.
func (_c *SemiFinishedCreate) SetOrderNo(v string) *SemiFinishedCreate {
_c.mutation.SetOrderNo(v)
return _c
}
// SetNillableOrderNo sets the "order_no" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableOrderNo(v *string) *SemiFinishedCreate {
if v != nil {
_c.SetOrderNo(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *SemiFinishedCreate) SetCreatedAt(v int64) *SemiFinishedCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableCreatedAt(v *int64) *SemiFinishedCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *SemiFinishedCreate) SetUpdatedAt(v int64) *SemiFinishedCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *SemiFinishedCreate) SetNillableUpdatedAt(v *int64) *SemiFinishedCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// Mutation returns the SemiFinishedMutation object of the builder.
func (_c *SemiFinishedCreate) Mutation() *SemiFinishedMutation {
return _c.mutation
}
// Save creates the SemiFinished in the database.
func (_c *SemiFinishedCreate) Save(ctx context.Context) (*SemiFinished, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *SemiFinishedCreate) SaveX(ctx context.Context) *SemiFinished {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SemiFinishedCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SemiFinishedCreate) 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 *SemiFinishedCreate) defaults() {
if _, ok := _c.mutation.Quantity(); !ok {
v := semifinished.DefaultQuantity
_c.mutation.SetQuantity(v)
}
if _, ok := _c.mutation.Status(); !ok {
v := semifinished.DefaultStatus
_c.mutation.SetStatus(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := semifinished.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := semifinished.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *SemiFinishedCreate) check() error {
if _, ok := _c.mutation.Sn(); !ok {
return &ValidationError{Name: "sn", err: errors.New(`ent: missing required field "SemiFinished.sn"`)}
}
if _, ok := _c.mutation.Quantity(); !ok {
return &ValidationError{Name: "quantity", err: errors.New(`ent: missing required field "SemiFinished.quantity"`)}
}
if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "SemiFinished.status"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SemiFinished.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SemiFinished.updated_at"`)}
}
return nil
}
func (_c *SemiFinishedCreate) sqlSave(ctx context.Context) (*SemiFinished, 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 *SemiFinishedCreate) createSpec() (*SemiFinished, *sqlgraph.CreateSpec) {
var (
_node = &SemiFinished{config: _c.config}
_spec = sqlgraph.NewCreateSpec(semifinished.Table, sqlgraph.NewFieldSpec(semifinished.FieldID, field.TypeInt))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.Sn(); ok {
_spec.SetField(semifinished.FieldSn, field.TypeString, value)
_node.Sn = value
}
if value, ok := _c.mutation.MaterialCode(); ok {
_spec.SetField(semifinished.FieldMaterialCode, field.TypeString, value)
_node.MaterialCode = value
}
if value, ok := _c.mutation.CompletedProcess(); ok {
_spec.SetField(semifinished.FieldCompletedProcess, field.TypeString, value)
_node.CompletedProcess = value
}
if value, ok := _c.mutation.Quantity(); ok {
_spec.SetField(semifinished.FieldQuantity, field.TypeInt, value)
_node.Quantity = value
}
if value, ok := _c.mutation.ZoneCode(); ok {
_spec.SetField(semifinished.FieldZoneCode, field.TypeString, value)
_node.ZoneCode = value
}
if value, ok := _c.mutation.Status(); ok {
_spec.SetField(semifinished.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.OrderNo(); ok {
_spec.SetField(semifinished.FieldOrderNo, field.TypeString, value)
_node.OrderNo = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(semifinished.FieldCreatedAt, field.TypeInt64, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(semifinished.FieldUpdatedAt, field.TypeInt64, value)
_node.UpdatedAt = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SemiFinished.Create().
// SetSn(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.SemiFinishedUpsert) {
// SetSn(v+v).
// }).
// Exec(ctx)
func (_c *SemiFinishedCreate) OnConflict(opts ...sql.ConflictOption) *SemiFinishedUpsertOne {
_c.conflict = opts
return &SemiFinishedUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SemiFinished.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SemiFinishedCreate) OnConflictColumns(columns ...string) *SemiFinishedUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SemiFinishedUpsertOne{
create: _c,
}
}
type (
// SemiFinishedUpsertOne is the builder for "upsert"-ing
// one SemiFinished node.
SemiFinishedUpsertOne struct {
create *SemiFinishedCreate
}
// SemiFinishedUpsert is the "OnConflict" setter.
SemiFinishedUpsert struct {
*sql.UpdateSet
}
)
// SetSn sets the "sn" field.
func (u *SemiFinishedUpsert) SetSn(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldSn, v)
return u
}
// UpdateSn sets the "sn" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateSn() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldSn)
return u
}
// SetMaterialCode sets the "material_code" field.
func (u *SemiFinishedUpsert) SetMaterialCode(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldMaterialCode, v)
return u
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateMaterialCode() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldMaterialCode)
return u
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *SemiFinishedUpsert) ClearMaterialCode() *SemiFinishedUpsert {
u.SetNull(semifinished.FieldMaterialCode)
return u
}
// SetCompletedProcess sets the "completed_process" field.
func (u *SemiFinishedUpsert) SetCompletedProcess(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldCompletedProcess, v)
return u
}
// UpdateCompletedProcess sets the "completed_process" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateCompletedProcess() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldCompletedProcess)
return u
}
// ClearCompletedProcess clears the value of the "completed_process" field.
func (u *SemiFinishedUpsert) ClearCompletedProcess() *SemiFinishedUpsert {
u.SetNull(semifinished.FieldCompletedProcess)
return u
}
// SetQuantity sets the "quantity" field.
func (u *SemiFinishedUpsert) SetQuantity(v int) *SemiFinishedUpsert {
u.Set(semifinished.FieldQuantity, v)
return u
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateQuantity() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldQuantity)
return u
}
// AddQuantity adds v to the "quantity" field.
func (u *SemiFinishedUpsert) AddQuantity(v int) *SemiFinishedUpsert {
u.Add(semifinished.FieldQuantity, v)
return u
}
// SetZoneCode sets the "zone_code" field.
func (u *SemiFinishedUpsert) SetZoneCode(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldZoneCode, v)
return u
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateZoneCode() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldZoneCode)
return u
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *SemiFinishedUpsert) ClearZoneCode() *SemiFinishedUpsert {
u.SetNull(semifinished.FieldZoneCode)
return u
}
// SetStatus sets the "status" field.
func (u *SemiFinishedUpsert) SetStatus(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateStatus() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldStatus)
return u
}
// SetOrderNo sets the "order_no" field.
func (u *SemiFinishedUpsert) SetOrderNo(v string) *SemiFinishedUpsert {
u.Set(semifinished.FieldOrderNo, v)
return u
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateOrderNo() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldOrderNo)
return u
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *SemiFinishedUpsert) ClearOrderNo() *SemiFinishedUpsert {
u.SetNull(semifinished.FieldOrderNo)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *SemiFinishedUpsert) SetCreatedAt(v int64) *SemiFinishedUpsert {
u.Set(semifinished.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateCreatedAt() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldCreatedAt)
return u
}
// AddCreatedAt adds v to the "created_at" field.
func (u *SemiFinishedUpsert) AddCreatedAt(v int64) *SemiFinishedUpsert {
u.Add(semifinished.FieldCreatedAt, v)
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SemiFinishedUpsert) SetUpdatedAt(v int64) *SemiFinishedUpsert {
u.Set(semifinished.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SemiFinishedUpsert) UpdateUpdatedAt() *SemiFinishedUpsert {
u.SetExcluded(semifinished.FieldUpdatedAt)
return u
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *SemiFinishedUpsert) AddUpdatedAt(v int64) *SemiFinishedUpsert {
u.Add(semifinished.FieldUpdatedAt, 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.SemiFinished.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SemiFinishedUpsertOne) UpdateNewValues() *SemiFinishedUpsertOne {
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.SemiFinished.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SemiFinishedUpsertOne) Ignore() *SemiFinishedUpsertOne {
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 *SemiFinishedUpsertOne) DoNothing() *SemiFinishedUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SemiFinishedCreate.OnConflict
// documentation for more info.
func (u *SemiFinishedUpsertOne) Update(set func(*SemiFinishedUpsert)) *SemiFinishedUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SemiFinishedUpsert{UpdateSet: update})
}))
return u
}
// SetSn sets the "sn" field.
func (u *SemiFinishedUpsertOne) SetSn(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetSn(v)
})
}
// UpdateSn sets the "sn" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateSn() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateSn()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *SemiFinishedUpsertOne) SetMaterialCode(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateMaterialCode() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateMaterialCode()
})
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *SemiFinishedUpsertOne) ClearMaterialCode() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearMaterialCode()
})
}
// SetCompletedProcess sets the "completed_process" field.
func (u *SemiFinishedUpsertOne) SetCompletedProcess(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetCompletedProcess(v)
})
}
// UpdateCompletedProcess sets the "completed_process" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateCompletedProcess() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateCompletedProcess()
})
}
// ClearCompletedProcess clears the value of the "completed_process" field.
func (u *SemiFinishedUpsertOne) ClearCompletedProcess() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearCompletedProcess()
})
}
// SetQuantity sets the "quantity" field.
func (u *SemiFinishedUpsertOne) SetQuantity(v int) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *SemiFinishedUpsertOne) AddQuantity(v int) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateQuantity() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateQuantity()
})
}
// SetZoneCode sets the "zone_code" field.
func (u *SemiFinishedUpsertOne) SetZoneCode(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetZoneCode(v)
})
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateZoneCode() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateZoneCode()
})
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *SemiFinishedUpsertOne) ClearZoneCode() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearZoneCode()
})
}
// SetStatus sets the "status" field.
func (u *SemiFinishedUpsertOne) SetStatus(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateStatus() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateStatus()
})
}
// SetOrderNo sets the "order_no" field.
func (u *SemiFinishedUpsertOne) SetOrderNo(v string) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetOrderNo(v)
})
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateOrderNo() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateOrderNo()
})
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *SemiFinishedUpsertOne) ClearOrderNo() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearOrderNo()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SemiFinishedUpsertOne) SetCreatedAt(v int64) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *SemiFinishedUpsertOne) AddCreatedAt(v int64) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateCreatedAt() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SemiFinishedUpsertOne) SetUpdatedAt(v int64) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetUpdatedAt(v)
})
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *SemiFinishedUpsertOne) AddUpdatedAt(v int64) *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SemiFinishedUpsertOne) UpdateUpdatedAt() *SemiFinishedUpsertOne {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *SemiFinishedUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SemiFinishedCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SemiFinishedUpsertOne) 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 *SemiFinishedUpsertOne) 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 *SemiFinishedUpsertOne) IDX(ctx context.Context) int {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// SemiFinishedCreateBulk is the builder for creating many SemiFinished entities in bulk.
type SemiFinishedCreateBulk struct {
config
err error
builders []*SemiFinishedCreate
conflict []sql.ConflictOption
}
// Save creates the SemiFinished entities in the database.
func (_c *SemiFinishedCreateBulk) Save(ctx context.Context) ([]*SemiFinished, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*SemiFinished, 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.(*SemiFinishedMutation)
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 *SemiFinishedCreateBulk) SaveX(ctx context.Context) []*SemiFinished {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SemiFinishedCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SemiFinishedCreateBulk) 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.SemiFinished.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.SemiFinishedUpsert) {
// SetSn(v+v).
// }).
// Exec(ctx)
func (_c *SemiFinishedCreateBulk) OnConflict(opts ...sql.ConflictOption) *SemiFinishedUpsertBulk {
_c.conflict = opts
return &SemiFinishedUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SemiFinished.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SemiFinishedCreateBulk) OnConflictColumns(columns ...string) *SemiFinishedUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SemiFinishedUpsertBulk{
create: _c,
}
}
// SemiFinishedUpsertBulk is the builder for "upsert"-ing
// a bulk of SemiFinished nodes.
type SemiFinishedUpsertBulk struct {
create *SemiFinishedCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SemiFinished.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SemiFinishedUpsertBulk) UpdateNewValues() *SemiFinishedUpsertBulk {
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.SemiFinished.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SemiFinishedUpsertBulk) Ignore() *SemiFinishedUpsertBulk {
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 *SemiFinishedUpsertBulk) DoNothing() *SemiFinishedUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SemiFinishedCreateBulk.OnConflict
// documentation for more info.
func (u *SemiFinishedUpsertBulk) Update(set func(*SemiFinishedUpsert)) *SemiFinishedUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SemiFinishedUpsert{UpdateSet: update})
}))
return u
}
// SetSn sets the "sn" field.
func (u *SemiFinishedUpsertBulk) SetSn(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetSn(v)
})
}
// UpdateSn sets the "sn" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateSn() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateSn()
})
}
// SetMaterialCode sets the "material_code" field.
func (u *SemiFinishedUpsertBulk) SetMaterialCode(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetMaterialCode(v)
})
}
// UpdateMaterialCode sets the "material_code" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateMaterialCode() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateMaterialCode()
})
}
// ClearMaterialCode clears the value of the "material_code" field.
func (u *SemiFinishedUpsertBulk) ClearMaterialCode() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearMaterialCode()
})
}
// SetCompletedProcess sets the "completed_process" field.
func (u *SemiFinishedUpsertBulk) SetCompletedProcess(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetCompletedProcess(v)
})
}
// UpdateCompletedProcess sets the "completed_process" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateCompletedProcess() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateCompletedProcess()
})
}
// ClearCompletedProcess clears the value of the "completed_process" field.
func (u *SemiFinishedUpsertBulk) ClearCompletedProcess() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearCompletedProcess()
})
}
// SetQuantity sets the "quantity" field.
func (u *SemiFinishedUpsertBulk) SetQuantity(v int) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetQuantity(v)
})
}
// AddQuantity adds v to the "quantity" field.
func (u *SemiFinishedUpsertBulk) AddQuantity(v int) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddQuantity(v)
})
}
// UpdateQuantity sets the "quantity" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateQuantity() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateQuantity()
})
}
// SetZoneCode sets the "zone_code" field.
func (u *SemiFinishedUpsertBulk) SetZoneCode(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetZoneCode(v)
})
}
// UpdateZoneCode sets the "zone_code" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateZoneCode() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateZoneCode()
})
}
// ClearZoneCode clears the value of the "zone_code" field.
func (u *SemiFinishedUpsertBulk) ClearZoneCode() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearZoneCode()
})
}
// SetStatus sets the "status" field.
func (u *SemiFinishedUpsertBulk) SetStatus(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateStatus() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateStatus()
})
}
// SetOrderNo sets the "order_no" field.
func (u *SemiFinishedUpsertBulk) SetOrderNo(v string) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetOrderNo(v)
})
}
// UpdateOrderNo sets the "order_no" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateOrderNo() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateOrderNo()
})
}
// ClearOrderNo clears the value of the "order_no" field.
func (u *SemiFinishedUpsertBulk) ClearOrderNo() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.ClearOrderNo()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SemiFinishedUpsertBulk) SetCreatedAt(v int64) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetCreatedAt(v)
})
}
// AddCreatedAt adds v to the "created_at" field.
func (u *SemiFinishedUpsertBulk) AddCreatedAt(v int64) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateCreatedAt() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateCreatedAt()
})
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SemiFinishedUpsertBulk) SetUpdatedAt(v int64) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.SetUpdatedAt(v)
})
}
// AddUpdatedAt adds v to the "updated_at" field.
func (u *SemiFinishedUpsertBulk) AddUpdatedAt(v int64) *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.AddUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SemiFinishedUpsertBulk) UpdateUpdatedAt() *SemiFinishedUpsertBulk {
return u.Update(func(s *SemiFinishedUpsert) {
s.UpdateUpdatedAt()
})
}
// Exec executes the query.
func (u *SemiFinishedUpsertBulk) 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 SemiFinishedCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SemiFinishedCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SemiFinishedUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}