Files
bj_power/bj_power_mes/ent/processflow_update.go
T
SunYF 0ab21b1234 feat&refactor: 完成多模块功能迭代与配置优化
本次提交覆盖多个业务模块的功能完善与体验优化:
1.  **鉴权与配置调整**:
    - 统一JWT滑动续签逻辑,简化Token存储,移除RefreshToken相关冗余代码
    - 调整多项目配置文件中JWT过期时间为3600秒,统一会话闲置窗口
    - 工位配置放开1~12限制,改为仅校验大于0
2.  **术语统一替换**:全链路将"精密件"替换为"电气件",修正物料管理描述
3.  **功能新增**:
    - 新增工位类型、工艺路线与产线点位台账模块
    - 添加工艺PDF预览面板、工位终端代理转发接口
    - 新增操作日志按操作人列表筛选、工位登出日志记录
    - 新增PLC移料指令与产线点位状态管理
4.  **业务流程优化**:
    - 调整BOM物料删除校验逻辑,优化工单备料计算
    - 补充物料图号、检测单号等追溯字段
    - 完善工艺流程图与工位绑定关系说明
    - 优化前端页面文案与交互细节
5.  **代码规范与维护**:
    - 新增通用工具函数与前端静态资源
    - 整理路由权限与中间件逻辑
    - 修复部分接口与配置的不兼容问题
2026-09-10 16:59:15 +08:00

439 lines
13 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/predicate"
"bj_power_mes/ent/processflow"
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ProcessFlowUpdate is the builder for updating ProcessFlow entities.
type ProcessFlowUpdate struct {
config
hooks []Hook
mutation *ProcessFlowMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the ProcessFlowUpdate builder.
func (_u *ProcessFlowUpdate) Where(ps ...predicate.ProcessFlow) *ProcessFlowUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetName sets the "name" field.
func (_u *ProcessFlowUpdate) SetName(v string) *ProcessFlowUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ProcessFlowUpdate) SetNillableName(v *string) *ProcessFlowUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetPdfFile sets the "pdfFile" field.
func (_u *ProcessFlowUpdate) SetPdfFile(v string) *ProcessFlowUpdate {
_u.mutation.SetPdfFile(v)
return _u
}
// SetNillablePdfFile sets the "pdfFile" field if the given value is not nil.
func (_u *ProcessFlowUpdate) SetNillablePdfFile(v *string) *ProcessFlowUpdate {
if v != nil {
_u.SetPdfFile(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *ProcessFlowUpdate) SetStatus(v string) *ProcessFlowUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *ProcessFlowUpdate) SetNillableStatus(v *string) *ProcessFlowUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetRemark sets the "remark" field.
func (_u *ProcessFlowUpdate) SetRemark(v string) *ProcessFlowUpdate {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *ProcessFlowUpdate) SetNillableRemark(v *string) *ProcessFlowUpdate {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// SetUpdatedAt sets the "updatedAt" field.
func (_u *ProcessFlowUpdate) SetUpdatedAt(v time.Time) *ProcessFlowUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// ClearUpdatedAt clears the value of the "updatedAt" field.
func (_u *ProcessFlowUpdate) ClearUpdatedAt() *ProcessFlowUpdate {
_u.mutation.ClearUpdatedAt()
return _u
}
// Mutation returns the ProcessFlowMutation object of the builder.
func (_u *ProcessFlowUpdate) Mutation() *ProcessFlowMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *ProcessFlowUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *ProcessFlowUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *ProcessFlowUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *ProcessFlowUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *ProcessFlowUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
v := processflow.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *ProcessFlowUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := processflow.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.name": %w`, err)}
}
}
if v, ok := _u.mutation.PdfFile(); ok {
if err := processflow.PdfFileValidator(v); err != nil {
return &ValidationError{Name: "pdfFile", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.pdfFile": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := processflow.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.status": %w`, err)}
}
}
if v, ok := _u.mutation.Remark(); ok {
if err := processflow.RemarkValidator(v); err != nil {
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.remark": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *ProcessFlowUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessFlowUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *ProcessFlowUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(processflow.Table, processflow.Columns, sqlgraph.NewFieldSpec(processflow.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.Name(); ok {
_spec.SetField(processflow.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.PdfFile(); ok {
_spec.SetField(processflow.FieldPdfFile, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(processflow.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(processflow.FieldRemark, field.TypeString, value)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(processflow.FieldUpdatedAt, field.TypeTime, value)
}
if _u.mutation.UpdatedAtCleared() {
_spec.ClearField(processflow.FieldUpdatedAt, field.TypeTime)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{processflow.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// ProcessFlowUpdateOne is the builder for updating a single ProcessFlow entity.
type ProcessFlowUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ProcessFlowMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetName sets the "name" field.
func (_u *ProcessFlowUpdateOne) SetName(v string) *ProcessFlowUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ProcessFlowUpdateOne) SetNillableName(v *string) *ProcessFlowUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetPdfFile sets the "pdfFile" field.
func (_u *ProcessFlowUpdateOne) SetPdfFile(v string) *ProcessFlowUpdateOne {
_u.mutation.SetPdfFile(v)
return _u
}
// SetNillablePdfFile sets the "pdfFile" field if the given value is not nil.
func (_u *ProcessFlowUpdateOne) SetNillablePdfFile(v *string) *ProcessFlowUpdateOne {
if v != nil {
_u.SetPdfFile(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *ProcessFlowUpdateOne) SetStatus(v string) *ProcessFlowUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *ProcessFlowUpdateOne) SetNillableStatus(v *string) *ProcessFlowUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetRemark sets the "remark" field.
func (_u *ProcessFlowUpdateOne) SetRemark(v string) *ProcessFlowUpdateOne {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *ProcessFlowUpdateOne) SetNillableRemark(v *string) *ProcessFlowUpdateOne {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// SetUpdatedAt sets the "updatedAt" field.
func (_u *ProcessFlowUpdateOne) SetUpdatedAt(v time.Time) *ProcessFlowUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// ClearUpdatedAt clears the value of the "updatedAt" field.
func (_u *ProcessFlowUpdateOne) ClearUpdatedAt() *ProcessFlowUpdateOne {
_u.mutation.ClearUpdatedAt()
return _u
}
// Mutation returns the ProcessFlowMutation object of the builder.
func (_u *ProcessFlowUpdateOne) Mutation() *ProcessFlowMutation {
return _u.mutation
}
// Where appends a list predicates to the ProcessFlowUpdate builder.
func (_u *ProcessFlowUpdateOne) Where(ps ...predicate.ProcessFlow) *ProcessFlowUpdateOne {
_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 *ProcessFlowUpdateOne) Select(field string, fields ...string) *ProcessFlowUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated ProcessFlow entity.
func (_u *ProcessFlowUpdateOne) Save(ctx context.Context) (*ProcessFlow, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *ProcessFlowUpdateOne) SaveX(ctx context.Context) *ProcessFlow {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *ProcessFlowUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *ProcessFlowUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *ProcessFlowUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
v := processflow.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *ProcessFlowUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := processflow.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.name": %w`, err)}
}
}
if v, ok := _u.mutation.PdfFile(); ok {
if err := processflow.PdfFileValidator(v); err != nil {
return &ValidationError{Name: "pdfFile", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.pdfFile": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := processflow.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.status": %w`, err)}
}
}
if v, ok := _u.mutation.Remark(); ok {
if err := processflow.RemarkValidator(v); err != nil {
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessFlow.remark": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *ProcessFlowUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessFlowUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *ProcessFlowUpdateOne) sqlSave(ctx context.Context) (_node *ProcessFlow, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(processflow.Table, processflow.Columns, sqlgraph.NewFieldSpec(processflow.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProcessFlow.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, processflow.FieldID)
for _, f := range fields {
if !processflow.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != processflow.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.Name(); ok {
_spec.SetField(processflow.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.PdfFile(); ok {
_spec.SetField(processflow.FieldPdfFile, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(processflow.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(processflow.FieldRemark, field.TypeString, value)
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(processflow.FieldUpdatedAt, field.TypeTime, value)
}
if _u.mutation.UpdatedAtCleared() {
_spec.ClearField(processflow.FieldUpdatedAt, field.TypeTime)
}
_spec.AddModifiers(_u.modifiers...)
_node = &ProcessFlow{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{processflow.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}