- MES 新增实体:混产模板、产品BOM、产品工艺物料、试制记录(schema + ent 生成码 + logic/handler/前端页) - WMS 实体增强:检验记录、库存、半成品重构;新增序列号库存与短缺代报 - AGV 与产能:AGV 手动点位与链路、物料守卫、短缺预测、原因字典 - 前端通用能力:新增下一步引导组件 NextStepBar,统一帮助文档/布局/请求拦截与操作列 - 工位终端:界面与各 handler 调整(api/store/绑定/PLC/拧紧/上报等) - 配置与文档:更新 mes-api.yaml、WMS README 及案例/产线API/问题记录/项目说明/流程说明
580 lines
18 KiB
Go
580 lines
18 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/predicate"
|
|
"bj_power_mes/ent/productbom"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// ProductBOMUpdate is the builder for updating ProductBOM entities.
|
|
type ProductBOMUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ProductBOMMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the ProductBOMUpdate builder.
|
|
func (_u *ProductBOMUpdate) Where(ps ...predicate.ProductBOM) *ProductBOMUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetProductCode sets the "productCode" field.
|
|
func (_u *ProductBOMUpdate) SetProductCode(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetProductCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductCode sets the "productCode" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableProductCode(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetProductCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "materialCode" field.
|
|
func (_u *ProductBOMUpdate) SetMaterialCode(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "materialCode" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableMaterialCode(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "materialName" field.
|
|
func (_u *ProductBOMUpdate) SetMaterialName(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "materialName" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableMaterialName(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (_u *ProductBOMUpdate) SetSpec(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetSpec(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSpec sets the "spec" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableSpec(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetSpec(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (_u *ProductBOMUpdate) SetUnit(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetUnit(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUnit sets the "unit" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableUnit(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetUnit(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUnitQty sets the "unitQty" field.
|
|
func (_u *ProductBOMUpdate) SetUnitQty(v float64) *ProductBOMUpdate {
|
|
_u.mutation.ResetUnitQty()
|
|
_u.mutation.SetUnitQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUnitQty sets the "unitQty" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableUnitQty(v *float64) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetUnitQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUnitQty adds value to the "unitQty" field.
|
|
func (_u *ProductBOMUpdate) AddUnitQty(v float64) *ProductBOMUpdate {
|
|
_u.mutation.AddUnitQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLossRate sets the "lossRate" field.
|
|
func (_u *ProductBOMUpdate) SetLossRate(v float64) *ProductBOMUpdate {
|
|
_u.mutation.ResetLossRate()
|
|
_u.mutation.SetLossRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLossRate sets the "lossRate" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableLossRate(v *float64) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetLossRate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLossRate adds value to the "lossRate" field.
|
|
func (_u *ProductBOMUpdate) AddLossRate(v float64) *ProductBOMUpdate {
|
|
_u.mutation.AddLossRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *ProductBOMUpdate) SetRemark(v string) *ProductBOMUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdate) SetNillableRemark(v *string) *ProductBOMUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the ProductBOMMutation object of the builder.
|
|
func (_u *ProductBOMUpdate) Mutation() *ProductBOMMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *ProductBOMUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ProductBOMUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ProductBOMUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProductBOMUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProductBOMUpdate) check() error {
|
|
if v, ok := _u.mutation.ProductCode(); ok {
|
|
if err := productbom.ProductCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.productCode": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MaterialCode(); ok {
|
|
if err := productbom.MaterialCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.materialCode": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MaterialName(); ok {
|
|
if err := productbom.MaterialNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.materialName": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Spec(); ok {
|
|
if err := productbom.SpecValidator(v); err != nil {
|
|
return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.spec": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Unit(); ok {
|
|
if err := productbom.UnitValidator(v); err != nil {
|
|
return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.unit": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := productbom.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProductBOMUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductBOMUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProductBOMUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(productbom.Table, productbom.Columns, sqlgraph.NewFieldSpec(productbom.FieldID, field.TypeInt))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.ProductCode(); ok {
|
|
_spec.SetField(productbom.FieldProductCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(productbom.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(productbom.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Spec(); ok {
|
|
_spec.SetField(productbom.FieldSpec, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Unit(); ok {
|
|
_spec.SetField(productbom.FieldUnit, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UnitQty(); ok {
|
|
_spec.SetField(productbom.FieldUnitQty, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUnitQty(); ok {
|
|
_spec.AddField(productbom.FieldUnitQty, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.LossRate(); ok {
|
|
_spec.SetField(productbom.FieldLossRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLossRate(); ok {
|
|
_spec.AddField(productbom.FieldLossRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(productbom.FieldRemark, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{productbom.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ProductBOMUpdateOne is the builder for updating a single ProductBOM entity.
|
|
type ProductBOMUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ProductBOMMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetProductCode sets the "productCode" field.
|
|
func (_u *ProductBOMUpdateOne) SetProductCode(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetProductCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductCode sets the "productCode" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableProductCode(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetProductCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialCode sets the "materialCode" field.
|
|
func (_u *ProductBOMUpdateOne) SetMaterialCode(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetMaterialCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialCode sets the "materialCode" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableMaterialCode(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMaterialName sets the "materialName" field.
|
|
func (_u *ProductBOMUpdateOne) SetMaterialName(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetMaterialName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "materialName" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableMaterialName(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaterialName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSpec sets the "spec" field.
|
|
func (_u *ProductBOMUpdateOne) SetSpec(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetSpec(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSpec sets the "spec" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableSpec(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetSpec(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (_u *ProductBOMUpdateOne) SetUnit(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetUnit(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUnit sets the "unit" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableUnit(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetUnit(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUnitQty sets the "unitQty" field.
|
|
func (_u *ProductBOMUpdateOne) SetUnitQty(v float64) *ProductBOMUpdateOne {
|
|
_u.mutation.ResetUnitQty()
|
|
_u.mutation.SetUnitQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUnitQty sets the "unitQty" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableUnitQty(v *float64) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetUnitQty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUnitQty adds value to the "unitQty" field.
|
|
func (_u *ProductBOMUpdateOne) AddUnitQty(v float64) *ProductBOMUpdateOne {
|
|
_u.mutation.AddUnitQty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLossRate sets the "lossRate" field.
|
|
func (_u *ProductBOMUpdateOne) SetLossRate(v float64) *ProductBOMUpdateOne {
|
|
_u.mutation.ResetLossRate()
|
|
_u.mutation.SetLossRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLossRate sets the "lossRate" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableLossRate(v *float64) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetLossRate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLossRate adds value to the "lossRate" field.
|
|
func (_u *ProductBOMUpdateOne) AddLossRate(v float64) *ProductBOMUpdateOne {
|
|
_u.mutation.AddLossRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *ProductBOMUpdateOne) SetRemark(v string) *ProductBOMUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *ProductBOMUpdateOne) SetNillableRemark(v *string) *ProductBOMUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the ProductBOMMutation object of the builder.
|
|
func (_u *ProductBOMUpdateOne) Mutation() *ProductBOMMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the ProductBOMUpdate builder.
|
|
func (_u *ProductBOMUpdateOne) Where(ps ...predicate.ProductBOM) *ProductBOMUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *ProductBOMUpdateOne) Select(field string, fields ...string) *ProductBOMUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated ProductBOM entity.
|
|
func (_u *ProductBOMUpdateOne) Save(ctx context.Context) (*ProductBOM, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ProductBOMUpdateOne) SaveX(ctx context.Context) *ProductBOM {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ProductBOMUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProductBOMUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProductBOMUpdateOne) check() error {
|
|
if v, ok := _u.mutation.ProductCode(); ok {
|
|
if err := productbom.ProductCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.productCode": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MaterialCode(); ok {
|
|
if err := productbom.MaterialCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.materialCode": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.MaterialName(); ok {
|
|
if err := productbom.MaterialNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.materialName": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Spec(); ok {
|
|
if err := productbom.SpecValidator(v); err != nil {
|
|
return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.spec": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Unit(); ok {
|
|
if err := productbom.UnitValidator(v); err != nil {
|
|
return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.unit": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := productbom.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductBOM.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProductBOMUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductBOMUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProductBOMUpdateOne) sqlSave(ctx context.Context) (_node *ProductBOM, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(productbom.Table, productbom.Columns, sqlgraph.NewFieldSpec(productbom.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProductBOM.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, productbom.FieldID)
|
|
for _, f := range fields {
|
|
if !productbom.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != productbom.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.ProductCode(); ok {
|
|
_spec.SetField(productbom.FieldProductCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialCode(); ok {
|
|
_spec.SetField(productbom.FieldMaterialCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MaterialName(); ok {
|
|
_spec.SetField(productbom.FieldMaterialName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Spec(); ok {
|
|
_spec.SetField(productbom.FieldSpec, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Unit(); ok {
|
|
_spec.SetField(productbom.FieldUnit, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UnitQty(); ok {
|
|
_spec.SetField(productbom.FieldUnitQty, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUnitQty(); ok {
|
|
_spec.AddField(productbom.FieldUnitQty, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.LossRate(); ok {
|
|
_spec.SetField(productbom.FieldLossRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLossRate(); ok {
|
|
_spec.AddField(productbom.FieldLossRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(productbom.FieldRemark, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &ProductBOM{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{productbom.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|