feat: 重构BOM架构,新增基础设置与虚拟工位管理功能
本次重构删除原有BOM物料清单表,改用工单工艺组合×工艺物料清单作为唯一用料来源;新增系统基础设置表支持WMS地址、日志保留天数等配置,新增虚拟工位作业管理后台接口与前端页签控制功能,同时优化工位号校验逻辑、事件日志自动清理与工单用料查询能力。
This commit is contained in:
@@ -0,0 +1,357 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_mes/ent/predicate"
|
||||
"bj_power_mes/ent/sysconfig"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SysConfigUpdate is the builder for updating SysConfig entities.
|
||||
type SysConfigUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SysConfigMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SysConfigUpdate builder.
|
||||
func (_u *SysConfigUpdate) Where(ps ...predicate.SysConfig) *SysConfigUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (_u *SysConfigUpdate) SetKey(v string) *SysConfigUpdate {
|
||||
_u.mutation.SetKey(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdate) SetNillableKey(v *string) *SysConfigUpdate {
|
||||
if v != nil {
|
||||
_u.SetKey(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (_u *SysConfigUpdate) SetValue(v string) *SysConfigUpdate {
|
||||
_u.mutation.SetValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdate) SetNillableValue(v *string) *SysConfigUpdate {
|
||||
if v != nil {
|
||||
_u.SetValue(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *SysConfigUpdate) SetRemark(v string) *SysConfigUpdate {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdate) SetNillableRemark(v *string) *SysConfigUpdate {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (_u *SysConfigUpdate) ClearRemark() *SysConfigUpdate {
|
||||
_u.mutation.ClearRemark()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the SysConfigMutation object of the builder.
|
||||
func (_u *SysConfigUpdate) Mutation() *SysConfigMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *SysConfigUpdate) 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 *SysConfigUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *SysConfigUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *SysConfigUpdate) 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 *SysConfigUpdate) check() error {
|
||||
if v, ok := _u.mutation.Key(); ok {
|
||||
if err := sysconfig.KeyValidator(v); err != nil {
|
||||
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "SysConfig.key": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Value(); ok {
|
||||
if err := sysconfig.ValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "SysConfig.value": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := sysconfig.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "SysConfig.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *SysConfigUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SysConfigUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *SysConfigUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(sysconfig.Table, sysconfig.Columns, sqlgraph.NewFieldSpec(sysconfig.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.Key(); ok {
|
||||
_spec.SetField(sysconfig.FieldKey, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Value(); ok {
|
||||
_spec.SetField(sysconfig.FieldValue, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(sysconfig.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RemarkCleared() {
|
||||
_spec.ClearField(sysconfig.FieldRemark, field.TypeString)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{sysconfig.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// SysConfigUpdateOne is the builder for updating a single SysConfig entity.
|
||||
type SysConfigUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *SysConfigMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (_u *SysConfigUpdateOne) SetKey(v string) *SysConfigUpdateOne {
|
||||
_u.mutation.SetKey(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdateOne) SetNillableKey(v *string) *SysConfigUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetKey(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (_u *SysConfigUpdateOne) SetValue(v string) *SysConfigUpdateOne {
|
||||
_u.mutation.SetValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdateOne) SetNillableValue(v *string) *SysConfigUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetValue(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (_u *SysConfigUpdateOne) SetRemark(v string) *SysConfigUpdateOne {
|
||||
_u.mutation.SetRemark(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (_u *SysConfigUpdateOne) SetNillableRemark(v *string) *SysConfigUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRemark(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (_u *SysConfigUpdateOne) ClearRemark() *SysConfigUpdateOne {
|
||||
_u.mutation.ClearRemark()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the SysConfigMutation object of the builder.
|
||||
func (_u *SysConfigUpdateOne) Mutation() *SysConfigMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SysConfigUpdate builder.
|
||||
func (_u *SysConfigUpdateOne) Where(ps ...predicate.SysConfig) *SysConfigUpdateOne {
|
||||
_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 *SysConfigUpdateOne) Select(field string, fields ...string) *SysConfigUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated SysConfig entity.
|
||||
func (_u *SysConfigUpdateOne) Save(ctx context.Context) (*SysConfig, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *SysConfigUpdateOne) SaveX(ctx context.Context) *SysConfig {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *SysConfigUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *SysConfigUpdateOne) 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 *SysConfigUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Key(); ok {
|
||||
if err := sysconfig.KeyValidator(v); err != nil {
|
||||
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "SysConfig.key": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Value(); ok {
|
||||
if err := sysconfig.ValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "SysConfig.value": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Remark(); ok {
|
||||
if err := sysconfig.RemarkValidator(v); err != nil {
|
||||
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "SysConfig.remark": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *SysConfigUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SysConfigUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *SysConfigUpdateOne) sqlSave(ctx context.Context) (_node *SysConfig, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(sysconfig.Table, sysconfig.Columns, sqlgraph.NewFieldSpec(sysconfig.FieldID, field.TypeInt))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SysConfig.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, sysconfig.FieldID)
|
||||
for _, f := range fields {
|
||||
if !sysconfig.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != sysconfig.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.Key(); ok {
|
||||
_spec.SetField(sysconfig.FieldKey, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Value(); ok {
|
||||
_spec.SetField(sysconfig.FieldValue, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Remark(); ok {
|
||||
_spec.SetField(sysconfig.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RemarkCleared() {
|
||||
_spec.ClearField(sysconfig.FieldRemark, field.TypeString)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &SysConfig{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{sysconfig.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
Reference in New Issue
Block a user