1. 废弃半成品库存表并统一库存主表 2. 修复列表排序与搜索大小写不敏感问题 3. 新增用户最近登录时间、工单BOM名称字段 4. 完善角色管理、工位选择器功能 5. 增加拧紧数据补录、成品自动回流WMS能力 6. 统一导出时间范围校验规则 7. 丰富物料/备料单筛选条件 8. 调整菜单与权限命名适配产品型号业务
1439 lines
41 KiB
Go
1439 lines
41 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/material"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// MaterialCreate is the builder for creating a Material entity.
|
|
type MaterialCreate struct {
|
|
config
|
|
mutation *MaterialMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (_c *MaterialCreate) SetCode(v string) *MaterialCreate {
|
|
_c.mutation.SetCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *MaterialCreate) SetName(v string) *MaterialCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetShortName sets the "short_name" field.
|
|
func (_c *MaterialCreate) SetShortName(v string) *MaterialCreate {
|
|
_c.mutation.SetShortName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableShortName sets the "short_name" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableShortName(v *string) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetShortName(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (_c *MaterialCreate) SetSpec(v string) *MaterialCreate {
|
|
_c.mutation.SetSpec(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSpec sets the "spec" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableSpec(v *string) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetSpec(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (_c *MaterialCreate) SetUnit(v string) *MaterialCreate {
|
|
_c.mutation.SetUnit(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUnit sets the "unit" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableUnit(v *string) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetUnit(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_c *MaterialCreate) SetDescription(v string) *MaterialCreate {
|
|
_c.mutation.SetDescription(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableDescription(v *string) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetDescription(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetItemType sets the "item_type" field.
|
|
func (_c *MaterialCreate) SetItemType(v int) *MaterialCreate {
|
|
_c.mutation.SetItemType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableItemType sets the "item_type" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableItemType(v *int) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetItemType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (_c *MaterialCreate) SetManageMode(v int) *MaterialCreate {
|
|
_c.mutation.SetManageMode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableManageMode sets the "manage_mode" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableManageMode(v *int) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetManageMode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsBatchManaged sets the "is_batch_managed" field.
|
|
func (_c *MaterialCreate) SetIsBatchManaged(v bool) *MaterialCreate {
|
|
_c.mutation.SetIsBatchManaged(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsBatchManaged sets the "is_batch_managed" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableIsBatchManaged(v *bool) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetIsBatchManaged(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsSerialManaged sets the "is_serial_managed" field.
|
|
func (_c *MaterialCreate) SetIsSerialManaged(v bool) *MaterialCreate {
|
|
_c.mutation.SetIsSerialManaged(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsSerialManaged sets the "is_serial_managed" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableIsSerialManaged(v *bool) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetIsSerialManaged(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTemplateCode sets the "template_code" field.
|
|
func (_c *MaterialCreate) SetTemplateCode(v string) *MaterialCreate {
|
|
_c.mutation.SetTemplateCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableTemplateCode(v *string) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetTemplateCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (_c *MaterialCreate) SetIsActive(v bool) *MaterialCreate {
|
|
_c.mutation.SetIsActive(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableIsActive(v *bool) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetIsActive(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *MaterialCreate) SetCreatedAt(v int64) *MaterialCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableCreatedAt(v *int64) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *MaterialCreate) SetUpdatedAt(v int64) *MaterialCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *MaterialCreate) SetNillableUpdatedAt(v *int64) *MaterialCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the MaterialMutation object of the builder.
|
|
func (_c *MaterialCreate) Mutation() *MaterialMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the Material in the database.
|
|
func (_c *MaterialCreate) Save(ctx context.Context) (*Material, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *MaterialCreate) SaveX(ctx context.Context) *Material {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MaterialCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MaterialCreate) 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 *MaterialCreate) defaults() {
|
|
if _, ok := _c.mutation.ItemType(); !ok {
|
|
v := material.DefaultItemType
|
|
_c.mutation.SetItemType(v)
|
|
}
|
|
if _, ok := _c.mutation.ManageMode(); !ok {
|
|
v := material.DefaultManageMode
|
|
_c.mutation.SetManageMode(v)
|
|
}
|
|
if _, ok := _c.mutation.IsBatchManaged(); !ok {
|
|
v := material.DefaultIsBatchManaged
|
|
_c.mutation.SetIsBatchManaged(v)
|
|
}
|
|
if _, ok := _c.mutation.IsSerialManaged(); !ok {
|
|
v := material.DefaultIsSerialManaged
|
|
_c.mutation.SetIsSerialManaged(v)
|
|
}
|
|
if _, ok := _c.mutation.IsActive(); !ok {
|
|
v := material.DefaultIsActive
|
|
_c.mutation.SetIsActive(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := material.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := material.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *MaterialCreate) check() error {
|
|
if _, ok := _c.mutation.Code(); !ok {
|
|
return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "Material.code"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Material.name"`)}
|
|
}
|
|
if _, ok := _c.mutation.ItemType(); !ok {
|
|
return &ValidationError{Name: "item_type", err: errors.New(`ent: missing required field "Material.item_type"`)}
|
|
}
|
|
if _, ok := _c.mutation.ManageMode(); !ok {
|
|
return &ValidationError{Name: "manage_mode", err: errors.New(`ent: missing required field "Material.manage_mode"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsBatchManaged(); !ok {
|
|
return &ValidationError{Name: "is_batch_managed", err: errors.New(`ent: missing required field "Material.is_batch_managed"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsSerialManaged(); !ok {
|
|
return &ValidationError{Name: "is_serial_managed", err: errors.New(`ent: missing required field "Material.is_serial_managed"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsActive(); !ok {
|
|
return &ValidationError{Name: "is_active", err: errors.New(`ent: missing required field "Material.is_active"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Material.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Material.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *MaterialCreate) sqlSave(ctx context.Context) (*Material, 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 *MaterialCreate) createSpec() (*Material, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Material{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(material.Table, sqlgraph.NewFieldSpec(material.FieldID, field.TypeInt))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.Code(); ok {
|
|
_spec.SetField(material.FieldCode, field.TypeString, value)
|
|
_node.Code = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(material.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.ShortName(); ok {
|
|
_spec.SetField(material.FieldShortName, field.TypeString, value)
|
|
_node.ShortName = value
|
|
}
|
|
if value, ok := _c.mutation.Spec(); ok {
|
|
_spec.SetField(material.FieldSpec, field.TypeString, value)
|
|
_node.Spec = value
|
|
}
|
|
if value, ok := _c.mutation.Unit(); ok {
|
|
_spec.SetField(material.FieldUnit, field.TypeString, value)
|
|
_node.Unit = value
|
|
}
|
|
if value, ok := _c.mutation.Description(); ok {
|
|
_spec.SetField(material.FieldDescription, field.TypeString, value)
|
|
_node.Description = value
|
|
}
|
|
if value, ok := _c.mutation.ItemType(); ok {
|
|
_spec.SetField(material.FieldItemType, field.TypeInt, value)
|
|
_node.ItemType = value
|
|
}
|
|
if value, ok := _c.mutation.ManageMode(); ok {
|
|
_spec.SetField(material.FieldManageMode, field.TypeInt, value)
|
|
_node.ManageMode = value
|
|
}
|
|
if value, ok := _c.mutation.IsBatchManaged(); ok {
|
|
_spec.SetField(material.FieldIsBatchManaged, field.TypeBool, value)
|
|
_node.IsBatchManaged = value
|
|
}
|
|
if value, ok := _c.mutation.IsSerialManaged(); ok {
|
|
_spec.SetField(material.FieldIsSerialManaged, field.TypeBool, value)
|
|
_node.IsSerialManaged = value
|
|
}
|
|
if value, ok := _c.mutation.TemplateCode(); ok {
|
|
_spec.SetField(material.FieldTemplateCode, field.TypeString, value)
|
|
_node.TemplateCode = value
|
|
}
|
|
if value, ok := _c.mutation.IsActive(); ok {
|
|
_spec.SetField(material.FieldIsActive, field.TypeBool, value)
|
|
_node.IsActive = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(material.FieldCreatedAt, field.TypeInt64, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(material.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.Material.Create().
|
|
// SetCode(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.MaterialUpsert) {
|
|
// SetCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *MaterialCreate) OnConflict(opts ...sql.ConflictOption) *MaterialUpsertOne {
|
|
_c.conflict = opts
|
|
return &MaterialUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Material.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *MaterialCreate) OnConflictColumns(columns ...string) *MaterialUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &MaterialUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// MaterialUpsertOne is the builder for "upsert"-ing
|
|
// one Material node.
|
|
MaterialUpsertOne struct {
|
|
create *MaterialCreate
|
|
}
|
|
|
|
// MaterialUpsert is the "OnConflict" setter.
|
|
MaterialUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *MaterialUpsert) SetCode(v string) *MaterialUpsert {
|
|
u.Set(material.FieldCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateCode() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldCode)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MaterialUpsert) SetName(v string) *MaterialUpsert {
|
|
u.Set(material.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateName() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetShortName sets the "short_name" field.
|
|
func (u *MaterialUpsert) SetShortName(v string) *MaterialUpsert {
|
|
u.Set(material.FieldShortName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateShortName sets the "short_name" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateShortName() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldShortName)
|
|
return u
|
|
}
|
|
|
|
// ClearShortName clears the value of the "short_name" field.
|
|
func (u *MaterialUpsert) ClearShortName() *MaterialUpsert {
|
|
u.SetNull(material.FieldShortName)
|
|
return u
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (u *MaterialUpsert) SetSpec(v string) *MaterialUpsert {
|
|
u.Set(material.FieldSpec, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSpec sets the "spec" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateSpec() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldSpec)
|
|
return u
|
|
}
|
|
|
|
// ClearSpec clears the value of the "spec" field.
|
|
func (u *MaterialUpsert) ClearSpec() *MaterialUpsert {
|
|
u.SetNull(material.FieldSpec)
|
|
return u
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (u *MaterialUpsert) SetUnit(v string) *MaterialUpsert {
|
|
u.Set(material.FieldUnit, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUnit sets the "unit" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateUnit() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldUnit)
|
|
return u
|
|
}
|
|
|
|
// ClearUnit clears the value of the "unit" field.
|
|
func (u *MaterialUpsert) ClearUnit() *MaterialUpsert {
|
|
u.SetNull(material.FieldUnit)
|
|
return u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MaterialUpsert) SetDescription(v string) *MaterialUpsert {
|
|
u.Set(material.FieldDescription, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateDescription() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MaterialUpsert) ClearDescription() *MaterialUpsert {
|
|
u.SetNull(material.FieldDescription)
|
|
return u
|
|
}
|
|
|
|
// SetItemType sets the "item_type" field.
|
|
func (u *MaterialUpsert) SetItemType(v int) *MaterialUpsert {
|
|
u.Set(material.FieldItemType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateItemType sets the "item_type" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateItemType() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldItemType)
|
|
return u
|
|
}
|
|
|
|
// AddItemType adds v to the "item_type" field.
|
|
func (u *MaterialUpsert) AddItemType(v int) *MaterialUpsert {
|
|
u.Add(material.FieldItemType, v)
|
|
return u
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (u *MaterialUpsert) SetManageMode(v int) *MaterialUpsert {
|
|
u.Set(material.FieldManageMode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateManageMode() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldManageMode)
|
|
return u
|
|
}
|
|
|
|
// AddManageMode adds v to the "manage_mode" field.
|
|
func (u *MaterialUpsert) AddManageMode(v int) *MaterialUpsert {
|
|
u.Add(material.FieldManageMode, v)
|
|
return u
|
|
}
|
|
|
|
// SetIsBatchManaged sets the "is_batch_managed" field.
|
|
func (u *MaterialUpsert) SetIsBatchManaged(v bool) *MaterialUpsert {
|
|
u.Set(material.FieldIsBatchManaged, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsBatchManaged sets the "is_batch_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateIsBatchManaged() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldIsBatchManaged)
|
|
return u
|
|
}
|
|
|
|
// SetIsSerialManaged sets the "is_serial_managed" field.
|
|
func (u *MaterialUpsert) SetIsSerialManaged(v bool) *MaterialUpsert {
|
|
u.Set(material.FieldIsSerialManaged, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsSerialManaged sets the "is_serial_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateIsSerialManaged() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldIsSerialManaged)
|
|
return u
|
|
}
|
|
|
|
// SetTemplateCode sets the "template_code" field.
|
|
func (u *MaterialUpsert) SetTemplateCode(v string) *MaterialUpsert {
|
|
u.Set(material.FieldTemplateCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateTemplateCode() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldTemplateCode)
|
|
return u
|
|
}
|
|
|
|
// ClearTemplateCode clears the value of the "template_code" field.
|
|
func (u *MaterialUpsert) ClearTemplateCode() *MaterialUpsert {
|
|
u.SetNull(material.FieldTemplateCode)
|
|
return u
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (u *MaterialUpsert) SetIsActive(v bool) *MaterialUpsert {
|
|
u.Set(material.FieldIsActive, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsActive sets the "is_active" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateIsActive() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldIsActive)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MaterialUpsert) SetCreatedAt(v int64) *MaterialUpsert {
|
|
u.Set(material.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateCreatedAt() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *MaterialUpsert) AddCreatedAt(v int64) *MaterialUpsert {
|
|
u.Add(material.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MaterialUpsert) SetUpdatedAt(v int64) *MaterialUpsert {
|
|
u.Set(material.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsert) UpdateUpdatedAt() *MaterialUpsert {
|
|
u.SetExcluded(material.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *MaterialUpsert) AddUpdatedAt(v int64) *MaterialUpsert {
|
|
u.Add(material.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.Material.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MaterialUpsertOne) UpdateNewValues() *MaterialUpsertOne {
|
|
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.Material.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MaterialUpsertOne) Ignore() *MaterialUpsertOne {
|
|
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 *MaterialUpsertOne) DoNothing() *MaterialUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MaterialCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *MaterialUpsertOne) Update(set func(*MaterialUpsert)) *MaterialUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MaterialUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *MaterialUpsertOne) SetCode(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateCode() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MaterialUpsertOne) SetName(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateName() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetShortName sets the "short_name" field.
|
|
func (u *MaterialUpsertOne) SetShortName(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetShortName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateShortName sets the "short_name" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateShortName() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateShortName()
|
|
})
|
|
}
|
|
|
|
// ClearShortName clears the value of the "short_name" field.
|
|
func (u *MaterialUpsertOne) ClearShortName() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearShortName()
|
|
})
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (u *MaterialUpsertOne) SetSpec(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetSpec(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSpec sets the "spec" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateSpec() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateSpec()
|
|
})
|
|
}
|
|
|
|
// ClearSpec clears the value of the "spec" field.
|
|
func (u *MaterialUpsertOne) ClearSpec() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearSpec()
|
|
})
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (u *MaterialUpsertOne) SetUnit(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetUnit(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUnit sets the "unit" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateUnit() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateUnit()
|
|
})
|
|
}
|
|
|
|
// ClearUnit clears the value of the "unit" field.
|
|
func (u *MaterialUpsertOne) ClearUnit() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearUnit()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MaterialUpsertOne) SetDescription(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateDescription() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MaterialUpsertOne) ClearDescription() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetItemType sets the "item_type" field.
|
|
func (u *MaterialUpsertOne) SetItemType(v int) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetItemType(v)
|
|
})
|
|
}
|
|
|
|
// AddItemType adds v to the "item_type" field.
|
|
func (u *MaterialUpsertOne) AddItemType(v int) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddItemType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateItemType sets the "item_type" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateItemType() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateItemType()
|
|
})
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (u *MaterialUpsertOne) SetManageMode(v int) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetManageMode(v)
|
|
})
|
|
}
|
|
|
|
// AddManageMode adds v to the "manage_mode" field.
|
|
func (u *MaterialUpsertOne) AddManageMode(v int) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddManageMode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateManageMode() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateManageMode()
|
|
})
|
|
}
|
|
|
|
// SetIsBatchManaged sets the "is_batch_managed" field.
|
|
func (u *MaterialUpsertOne) SetIsBatchManaged(v bool) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsBatchManaged(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsBatchManaged sets the "is_batch_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateIsBatchManaged() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsBatchManaged()
|
|
})
|
|
}
|
|
|
|
// SetIsSerialManaged sets the "is_serial_managed" field.
|
|
func (u *MaterialUpsertOne) SetIsSerialManaged(v bool) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsSerialManaged(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsSerialManaged sets the "is_serial_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateIsSerialManaged() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsSerialManaged()
|
|
})
|
|
}
|
|
|
|
// SetTemplateCode sets the "template_code" field.
|
|
func (u *MaterialUpsertOne) SetTemplateCode(v string) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetTemplateCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateTemplateCode() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateTemplateCode()
|
|
})
|
|
}
|
|
|
|
// ClearTemplateCode clears the value of the "template_code" field.
|
|
func (u *MaterialUpsertOne) ClearTemplateCode() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearTemplateCode()
|
|
})
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (u *MaterialUpsertOne) SetIsActive(v bool) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsActive(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsActive sets the "is_active" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateIsActive() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsActive()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MaterialUpsertOne) SetCreatedAt(v int64) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *MaterialUpsertOne) AddCreatedAt(v int64) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateCreatedAt() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MaterialUpsertOne) SetUpdatedAt(v int64) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *MaterialUpsertOne) AddUpdatedAt(v int64) *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsertOne) UpdateUpdatedAt() *MaterialUpsertOne {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MaterialUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for MaterialCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MaterialUpsertOne) 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 *MaterialUpsertOne) 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 *MaterialUpsertOne) IDX(ctx context.Context) int {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// MaterialCreateBulk is the builder for creating many Material entities in bulk.
|
|
type MaterialCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*MaterialCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the Material entities in the database.
|
|
func (_c *MaterialCreateBulk) Save(ctx context.Context) ([]*Material, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*Material, 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.(*MaterialMutation)
|
|
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 *MaterialCreateBulk) SaveX(ctx context.Context) []*Material {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *MaterialCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *MaterialCreateBulk) 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.Material.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.MaterialUpsert) {
|
|
// SetCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *MaterialCreateBulk) OnConflict(opts ...sql.ConflictOption) *MaterialUpsertBulk {
|
|
_c.conflict = opts
|
|
return &MaterialUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Material.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *MaterialCreateBulk) OnConflictColumns(columns ...string) *MaterialUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &MaterialUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// MaterialUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of Material nodes.
|
|
type MaterialUpsertBulk struct {
|
|
create *MaterialCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.Material.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MaterialUpsertBulk) UpdateNewValues() *MaterialUpsertBulk {
|
|
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.Material.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MaterialUpsertBulk) Ignore() *MaterialUpsertBulk {
|
|
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 *MaterialUpsertBulk) DoNothing() *MaterialUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MaterialCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *MaterialUpsertBulk) Update(set func(*MaterialUpsert)) *MaterialUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MaterialUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *MaterialUpsertBulk) SetCode(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateCode() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *MaterialUpsertBulk) SetName(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateName() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetShortName sets the "short_name" field.
|
|
func (u *MaterialUpsertBulk) SetShortName(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetShortName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateShortName sets the "short_name" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateShortName() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateShortName()
|
|
})
|
|
}
|
|
|
|
// ClearShortName clears the value of the "short_name" field.
|
|
func (u *MaterialUpsertBulk) ClearShortName() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearShortName()
|
|
})
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (u *MaterialUpsertBulk) SetSpec(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetSpec(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSpec sets the "spec" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateSpec() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateSpec()
|
|
})
|
|
}
|
|
|
|
// ClearSpec clears the value of the "spec" field.
|
|
func (u *MaterialUpsertBulk) ClearSpec() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearSpec()
|
|
})
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (u *MaterialUpsertBulk) SetUnit(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetUnit(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUnit sets the "unit" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateUnit() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateUnit()
|
|
})
|
|
}
|
|
|
|
// ClearUnit clears the value of the "unit" field.
|
|
func (u *MaterialUpsertBulk) ClearUnit() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearUnit()
|
|
})
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (u *MaterialUpsertBulk) SetDescription(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetDescription(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDescription sets the "description" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateDescription() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateDescription()
|
|
})
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (u *MaterialUpsertBulk) ClearDescription() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearDescription()
|
|
})
|
|
}
|
|
|
|
// SetItemType sets the "item_type" field.
|
|
func (u *MaterialUpsertBulk) SetItemType(v int) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetItemType(v)
|
|
})
|
|
}
|
|
|
|
// AddItemType adds v to the "item_type" field.
|
|
func (u *MaterialUpsertBulk) AddItemType(v int) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddItemType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateItemType sets the "item_type" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateItemType() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateItemType()
|
|
})
|
|
}
|
|
|
|
// SetManageMode sets the "manage_mode" field.
|
|
func (u *MaterialUpsertBulk) SetManageMode(v int) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetManageMode(v)
|
|
})
|
|
}
|
|
|
|
// AddManageMode adds v to the "manage_mode" field.
|
|
func (u *MaterialUpsertBulk) AddManageMode(v int) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddManageMode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateManageMode sets the "manage_mode" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateManageMode() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateManageMode()
|
|
})
|
|
}
|
|
|
|
// SetIsBatchManaged sets the "is_batch_managed" field.
|
|
func (u *MaterialUpsertBulk) SetIsBatchManaged(v bool) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsBatchManaged(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsBatchManaged sets the "is_batch_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateIsBatchManaged() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsBatchManaged()
|
|
})
|
|
}
|
|
|
|
// SetIsSerialManaged sets the "is_serial_managed" field.
|
|
func (u *MaterialUpsertBulk) SetIsSerialManaged(v bool) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsSerialManaged(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsSerialManaged sets the "is_serial_managed" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateIsSerialManaged() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsSerialManaged()
|
|
})
|
|
}
|
|
|
|
// SetTemplateCode sets the "template_code" field.
|
|
func (u *MaterialUpsertBulk) SetTemplateCode(v string) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetTemplateCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateTemplateCode() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateTemplateCode()
|
|
})
|
|
}
|
|
|
|
// ClearTemplateCode clears the value of the "template_code" field.
|
|
func (u *MaterialUpsertBulk) ClearTemplateCode() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.ClearTemplateCode()
|
|
})
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (u *MaterialUpsertBulk) SetIsActive(v bool) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetIsActive(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsActive sets the "is_active" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateIsActive() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateIsActive()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *MaterialUpsertBulk) SetCreatedAt(v int64) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *MaterialUpsertBulk) AddCreatedAt(v int64) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateCreatedAt() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MaterialUpsertBulk) SetUpdatedAt(v int64) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *MaterialUpsertBulk) AddUpdatedAt(v int64) *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MaterialUpsertBulk) UpdateUpdatedAt() *MaterialUpsertBulk {
|
|
return u.Update(func(s *MaterialUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MaterialUpsertBulk) 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 MaterialCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for MaterialCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MaterialUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|