Files
bj_power/bj_power_mes/ent/associationtrace_update.go
T
SunYF 5c3b747a20 feat: 新增预警与附件模块,优化工位派工功能
1. 新增预警规则、预警消息、业务附件数据库表与CRUD逻辑
2. 为拧紧记录添加审核人、审核时间字段及审核留痕功能
3. 优化产线点位类型与编号描述,更新工位组合下发菜单名称为工艺路线派工
4. 新增上传文件获取原文件名与大小的工具方法
5. 在系统管理菜单新增预警中心与附件中心入口
2026-09-14 16:31:08 +08:00

485 lines
16 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/associationtrace"
"bj_power_mes/ent/predicate"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
)
// AssociationTraceUpdate is the builder for updating AssociationTrace entities.
type AssociationTraceUpdate struct {
config
hooks []Hook
mutation *AssociationTraceMutation
}
// Where appends a list predicates to the AssociationTraceUpdate builder.
func (_u *AssociationTraceUpdate) Where(ps ...predicate.AssociationTrace) *AssociationTraceUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetFinishedSn sets the "finishedSn" field.
func (_u *AssociationTraceUpdate) SetFinishedSn(v string) *AssociationTraceUpdate {
_u.mutation.SetFinishedSn(v)
return _u
}
// SetNillableFinishedSn sets the "finishedSn" field if the given value is not nil.
func (_u *AssociationTraceUpdate) SetNillableFinishedSn(v *string) *AssociationTraceUpdate {
if v != nil {
_u.SetFinishedSn(*v)
}
return _u
}
// SetOrderNo sets the "orderNo" field.
func (_u *AssociationTraceUpdate) SetOrderNo(v string) *AssociationTraceUpdate {
_u.mutation.SetOrderNo(v)
return _u
}
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
func (_u *AssociationTraceUpdate) SetNillableOrderNo(v *string) *AssociationTraceUpdate {
if v != nil {
_u.SetOrderNo(*v)
}
return _u
}
// SetProcessCode sets the "processCode" field.
func (_u *AssociationTraceUpdate) SetProcessCode(v string) *AssociationTraceUpdate {
_u.mutation.SetProcessCode(v)
return _u
}
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
func (_u *AssociationTraceUpdate) SetNillableProcessCode(v *string) *AssociationTraceUpdate {
if v != nil {
_u.SetProcessCode(*v)
}
return _u
}
// SetBatchItems sets the "batchItems" field.
func (_u *AssociationTraceUpdate) SetBatchItems(v []string) *AssociationTraceUpdate {
_u.mutation.SetBatchItems(v)
return _u
}
// AppendBatchItems appends value to the "batchItems" field.
func (_u *AssociationTraceUpdate) AppendBatchItems(v []string) *AssociationTraceUpdate {
_u.mutation.AppendBatchItems(v)
return _u
}
// ClearBatchItems clears the value of the "batchItems" field.
func (_u *AssociationTraceUpdate) ClearBatchItems() *AssociationTraceUpdate {
_u.mutation.ClearBatchItems()
return _u
}
// SetSerialItems sets the "serialItems" field.
func (_u *AssociationTraceUpdate) SetSerialItems(v []string) *AssociationTraceUpdate {
_u.mutation.SetSerialItems(v)
return _u
}
// AppendSerialItems appends value to the "serialItems" field.
func (_u *AssociationTraceUpdate) AppendSerialItems(v []string) *AssociationTraceUpdate {
_u.mutation.AppendSerialItems(v)
return _u
}
// ClearSerialItems clears the value of the "serialItems" field.
func (_u *AssociationTraceUpdate) ClearSerialItems() *AssociationTraceUpdate {
_u.mutation.ClearSerialItems()
return _u
}
// SetOperator sets the "operator" field.
func (_u *AssociationTraceUpdate) SetOperator(v string) *AssociationTraceUpdate {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *AssociationTraceUpdate) SetNillableOperator(v *string) *AssociationTraceUpdate {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// Mutation returns the AssociationTraceMutation object of the builder.
func (_u *AssociationTraceUpdate) Mutation() *AssociationTraceMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AssociationTraceUpdate) 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 *AssociationTraceUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AssociationTraceUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AssociationTraceUpdate) 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 *AssociationTraceUpdate) check() error {
if v, ok := _u.mutation.FinishedSn(); ok {
if err := associationtrace.FinishedSnValidator(v); err != nil {
return &ValidationError{Name: "finishedSn", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.finishedSn": %w`, err)}
}
}
if v, ok := _u.mutation.OrderNo(); ok {
if err := associationtrace.OrderNoValidator(v); err != nil {
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.orderNo": %w`, err)}
}
}
if v, ok := _u.mutation.ProcessCode(); ok {
if err := associationtrace.ProcessCodeValidator(v); err != nil {
return &ValidationError{Name: "processCode", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.processCode": %w`, err)}
}
}
if v, ok := _u.mutation.Operator(); ok {
if err := associationtrace.OperatorValidator(v); err != nil {
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.operator": %w`, err)}
}
}
return nil
}
func (_u *AssociationTraceUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(associationtrace.Table, associationtrace.Columns, sqlgraph.NewFieldSpec(associationtrace.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.FinishedSn(); ok {
_spec.SetField(associationtrace.FieldFinishedSn, field.TypeString, value)
}
if value, ok := _u.mutation.OrderNo(); ok {
_spec.SetField(associationtrace.FieldOrderNo, field.TypeString, value)
}
if value, ok := _u.mutation.ProcessCode(); ok {
_spec.SetField(associationtrace.FieldProcessCode, field.TypeString, value)
}
if value, ok := _u.mutation.BatchItems(); ok {
_spec.SetField(associationtrace.FieldBatchItems, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedBatchItems(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, associationtrace.FieldBatchItems, value)
})
}
if _u.mutation.BatchItemsCleared() {
_spec.ClearField(associationtrace.FieldBatchItems, field.TypeJSON)
}
if value, ok := _u.mutation.SerialItems(); ok {
_spec.SetField(associationtrace.FieldSerialItems, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedSerialItems(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, associationtrace.FieldSerialItems, value)
})
}
if _u.mutation.SerialItemsCleared() {
_spec.ClearField(associationtrace.FieldSerialItems, field.TypeJSON)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(associationtrace.FieldOperator, field.TypeString, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{associationtrace.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AssociationTraceUpdateOne is the builder for updating a single AssociationTrace entity.
type AssociationTraceUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AssociationTraceMutation
}
// SetFinishedSn sets the "finishedSn" field.
func (_u *AssociationTraceUpdateOne) SetFinishedSn(v string) *AssociationTraceUpdateOne {
_u.mutation.SetFinishedSn(v)
return _u
}
// SetNillableFinishedSn sets the "finishedSn" field if the given value is not nil.
func (_u *AssociationTraceUpdateOne) SetNillableFinishedSn(v *string) *AssociationTraceUpdateOne {
if v != nil {
_u.SetFinishedSn(*v)
}
return _u
}
// SetOrderNo sets the "orderNo" field.
func (_u *AssociationTraceUpdateOne) SetOrderNo(v string) *AssociationTraceUpdateOne {
_u.mutation.SetOrderNo(v)
return _u
}
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
func (_u *AssociationTraceUpdateOne) SetNillableOrderNo(v *string) *AssociationTraceUpdateOne {
if v != nil {
_u.SetOrderNo(*v)
}
return _u
}
// SetProcessCode sets the "processCode" field.
func (_u *AssociationTraceUpdateOne) SetProcessCode(v string) *AssociationTraceUpdateOne {
_u.mutation.SetProcessCode(v)
return _u
}
// SetNillableProcessCode sets the "processCode" field if the given value is not nil.
func (_u *AssociationTraceUpdateOne) SetNillableProcessCode(v *string) *AssociationTraceUpdateOne {
if v != nil {
_u.SetProcessCode(*v)
}
return _u
}
// SetBatchItems sets the "batchItems" field.
func (_u *AssociationTraceUpdateOne) SetBatchItems(v []string) *AssociationTraceUpdateOne {
_u.mutation.SetBatchItems(v)
return _u
}
// AppendBatchItems appends value to the "batchItems" field.
func (_u *AssociationTraceUpdateOne) AppendBatchItems(v []string) *AssociationTraceUpdateOne {
_u.mutation.AppendBatchItems(v)
return _u
}
// ClearBatchItems clears the value of the "batchItems" field.
func (_u *AssociationTraceUpdateOne) ClearBatchItems() *AssociationTraceUpdateOne {
_u.mutation.ClearBatchItems()
return _u
}
// SetSerialItems sets the "serialItems" field.
func (_u *AssociationTraceUpdateOne) SetSerialItems(v []string) *AssociationTraceUpdateOne {
_u.mutation.SetSerialItems(v)
return _u
}
// AppendSerialItems appends value to the "serialItems" field.
func (_u *AssociationTraceUpdateOne) AppendSerialItems(v []string) *AssociationTraceUpdateOne {
_u.mutation.AppendSerialItems(v)
return _u
}
// ClearSerialItems clears the value of the "serialItems" field.
func (_u *AssociationTraceUpdateOne) ClearSerialItems() *AssociationTraceUpdateOne {
_u.mutation.ClearSerialItems()
return _u
}
// SetOperator sets the "operator" field.
func (_u *AssociationTraceUpdateOne) SetOperator(v string) *AssociationTraceUpdateOne {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *AssociationTraceUpdateOne) SetNillableOperator(v *string) *AssociationTraceUpdateOne {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// Mutation returns the AssociationTraceMutation object of the builder.
func (_u *AssociationTraceUpdateOne) Mutation() *AssociationTraceMutation {
return _u.mutation
}
// Where appends a list predicates to the AssociationTraceUpdate builder.
func (_u *AssociationTraceUpdateOne) Where(ps ...predicate.AssociationTrace) *AssociationTraceUpdateOne {
_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 *AssociationTraceUpdateOne) Select(field string, fields ...string) *AssociationTraceUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AssociationTrace entity.
func (_u *AssociationTraceUpdateOne) Save(ctx context.Context) (*AssociationTrace, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AssociationTraceUpdateOne) SaveX(ctx context.Context) *AssociationTrace {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AssociationTraceUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AssociationTraceUpdateOne) 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 *AssociationTraceUpdateOne) check() error {
if v, ok := _u.mutation.FinishedSn(); ok {
if err := associationtrace.FinishedSnValidator(v); err != nil {
return &ValidationError{Name: "finishedSn", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.finishedSn": %w`, err)}
}
}
if v, ok := _u.mutation.OrderNo(); ok {
if err := associationtrace.OrderNoValidator(v); err != nil {
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.orderNo": %w`, err)}
}
}
if v, ok := _u.mutation.ProcessCode(); ok {
if err := associationtrace.ProcessCodeValidator(v); err != nil {
return &ValidationError{Name: "processCode", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.processCode": %w`, err)}
}
}
if v, ok := _u.mutation.Operator(); ok {
if err := associationtrace.OperatorValidator(v); err != nil {
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "AssociationTrace.operator": %w`, err)}
}
}
return nil
}
func (_u *AssociationTraceUpdateOne) sqlSave(ctx context.Context) (_node *AssociationTrace, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(associationtrace.Table, associationtrace.Columns, sqlgraph.NewFieldSpec(associationtrace.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AssociationTrace.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, associationtrace.FieldID)
for _, f := range fields {
if !associationtrace.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != associationtrace.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.FinishedSn(); ok {
_spec.SetField(associationtrace.FieldFinishedSn, field.TypeString, value)
}
if value, ok := _u.mutation.OrderNo(); ok {
_spec.SetField(associationtrace.FieldOrderNo, field.TypeString, value)
}
if value, ok := _u.mutation.ProcessCode(); ok {
_spec.SetField(associationtrace.FieldProcessCode, field.TypeString, value)
}
if value, ok := _u.mutation.BatchItems(); ok {
_spec.SetField(associationtrace.FieldBatchItems, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedBatchItems(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, associationtrace.FieldBatchItems, value)
})
}
if _u.mutation.BatchItemsCleared() {
_spec.ClearField(associationtrace.FieldBatchItems, field.TypeJSON)
}
if value, ok := _u.mutation.SerialItems(); ok {
_spec.SetField(associationtrace.FieldSerialItems, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedSerialItems(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, associationtrace.FieldSerialItems, value)
})
}
if _u.mutation.SerialItemsCleared() {
_spec.ClearField(associationtrace.FieldSerialItems, field.TypeJSON)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(associationtrace.FieldOperator, field.TypeString, value)
}
_node = &AssociationTrace{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{associationtrace.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}