Files
bj_power/bj_power_mes/ent/attachment_update.go
T
SunYF 4a5e2d7bac feat: 完成多模块迭代更新
- 新增过程巡检按步骤上报、数量不符上报、工位退料功能
- 增加工单工程编号三级归属字段
- 新增物料安全库存与缺货预警
- 新增附件管理、退库单管理模块
- 优化生产看板展示逻辑与前端页面文案
- 清理冗余的工艺路线相关代码与备份文件
2026-09-15 16:37:39 +08:00

482 lines
15 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/attachment"
"bj_power_mes/ent/predicate"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// AttachmentUpdate is the builder for updating Attachment entities.
type AttachmentUpdate struct {
config
hooks []Hook
mutation *AttachmentMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the AttachmentUpdate builder.
func (_u *AttachmentUpdate) Where(ps ...predicate.Attachment) *AttachmentUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetBizType sets the "bizType" field.
func (_u *AttachmentUpdate) SetBizType(v string) *AttachmentUpdate {
_u.mutation.SetBizType(v)
return _u
}
// SetNillableBizType sets the "bizType" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableBizType(v *string) *AttachmentUpdate {
if v != nil {
_u.SetBizType(*v)
}
return _u
}
// SetBizId sets the "bizId" field.
func (_u *AttachmentUpdate) SetBizId(v string) *AttachmentUpdate {
_u.mutation.SetBizId(v)
return _u
}
// SetNillableBizId sets the "bizId" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableBizId(v *string) *AttachmentUpdate {
if v != nil {
_u.SetBizId(*v)
}
return _u
}
// SetFileName sets the "fileName" field.
func (_u *AttachmentUpdate) SetFileName(v string) *AttachmentUpdate {
_u.mutation.SetFileName(v)
return _u
}
// SetNillableFileName sets the "fileName" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableFileName(v *string) *AttachmentUpdate {
if v != nil {
_u.SetFileName(*v)
}
return _u
}
// SetFilePath sets the "filePath" field.
func (_u *AttachmentUpdate) SetFilePath(v string) *AttachmentUpdate {
_u.mutation.SetFilePath(v)
return _u
}
// SetNillableFilePath sets the "filePath" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableFilePath(v *string) *AttachmentUpdate {
if v != nil {
_u.SetFilePath(*v)
}
return _u
}
// SetFileSize sets the "fileSize" field.
func (_u *AttachmentUpdate) SetFileSize(v int) *AttachmentUpdate {
_u.mutation.ResetFileSize()
_u.mutation.SetFileSize(v)
return _u
}
// SetNillableFileSize sets the "fileSize" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableFileSize(v *int) *AttachmentUpdate {
if v != nil {
_u.SetFileSize(*v)
}
return _u
}
// AddFileSize adds value to the "fileSize" field.
func (_u *AttachmentUpdate) AddFileSize(v int) *AttachmentUpdate {
_u.mutation.AddFileSize(v)
return _u
}
// SetUploader sets the "uploader" field.
func (_u *AttachmentUpdate) SetUploader(v string) *AttachmentUpdate {
_u.mutation.SetUploader(v)
return _u
}
// SetNillableUploader sets the "uploader" field if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableUploader(v *string) *AttachmentUpdate {
if v != nil {
_u.SetUploader(*v)
}
return _u
}
// Mutation returns the AttachmentMutation object of the builder.
func (_u *AttachmentUpdate) Mutation() *AttachmentMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AttachmentUpdate) 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 *AttachmentUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AttachmentUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AttachmentUpdate) 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 *AttachmentUpdate) check() error {
if v, ok := _u.mutation.BizType(); ok {
if err := attachment.BizTypeValidator(v); err != nil {
return &ValidationError{Name: "bizType", err: fmt.Errorf(`ent: validator failed for field "Attachment.bizType": %w`, err)}
}
}
if v, ok := _u.mutation.BizId(); ok {
if err := attachment.BizIdValidator(v); err != nil {
return &ValidationError{Name: "bizId", err: fmt.Errorf(`ent: validator failed for field "Attachment.bizId": %w`, err)}
}
}
if v, ok := _u.mutation.FileName(); ok {
if err := attachment.FileNameValidator(v); err != nil {
return &ValidationError{Name: "fileName", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileName": %w`, err)}
}
}
if v, ok := _u.mutation.FilePath(); ok {
if err := attachment.FilePathValidator(v); err != nil {
return &ValidationError{Name: "filePath", err: fmt.Errorf(`ent: validator failed for field "Attachment.filePath": %w`, err)}
}
}
if v, ok := _u.mutation.Uploader(); ok {
if err := attachment.UploaderValidator(v); err != nil {
return &ValidationError{Name: "uploader", err: fmt.Errorf(`ent: validator failed for field "Attachment.uploader": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *AttachmentUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AttachmentUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.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.BizType(); ok {
_spec.SetField(attachment.FieldBizType, field.TypeString, value)
}
if value, ok := _u.mutation.BizId(); ok {
_spec.SetField(attachment.FieldBizId, field.TypeString, value)
}
if value, ok := _u.mutation.FileName(); ok {
_spec.SetField(attachment.FieldFileName, field.TypeString, value)
}
if value, ok := _u.mutation.FilePath(); ok {
_spec.SetField(attachment.FieldFilePath, field.TypeString, value)
}
if value, ok := _u.mutation.FileSize(); ok {
_spec.SetField(attachment.FieldFileSize, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFileSize(); ok {
_spec.AddField(attachment.FieldFileSize, field.TypeInt, value)
}
if value, ok := _u.mutation.Uploader(); ok {
_spec.SetField(attachment.FieldUploader, 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{attachment.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AttachmentUpdateOne is the builder for updating a single Attachment entity.
type AttachmentUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AttachmentMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetBizType sets the "bizType" field.
func (_u *AttachmentUpdateOne) SetBizType(v string) *AttachmentUpdateOne {
_u.mutation.SetBizType(v)
return _u
}
// SetNillableBizType sets the "bizType" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableBizType(v *string) *AttachmentUpdateOne {
if v != nil {
_u.SetBizType(*v)
}
return _u
}
// SetBizId sets the "bizId" field.
func (_u *AttachmentUpdateOne) SetBizId(v string) *AttachmentUpdateOne {
_u.mutation.SetBizId(v)
return _u
}
// SetNillableBizId sets the "bizId" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableBizId(v *string) *AttachmentUpdateOne {
if v != nil {
_u.SetBizId(*v)
}
return _u
}
// SetFileName sets the "fileName" field.
func (_u *AttachmentUpdateOne) SetFileName(v string) *AttachmentUpdateOne {
_u.mutation.SetFileName(v)
return _u
}
// SetNillableFileName sets the "fileName" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableFileName(v *string) *AttachmentUpdateOne {
if v != nil {
_u.SetFileName(*v)
}
return _u
}
// SetFilePath sets the "filePath" field.
func (_u *AttachmentUpdateOne) SetFilePath(v string) *AttachmentUpdateOne {
_u.mutation.SetFilePath(v)
return _u
}
// SetNillableFilePath sets the "filePath" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableFilePath(v *string) *AttachmentUpdateOne {
if v != nil {
_u.SetFilePath(*v)
}
return _u
}
// SetFileSize sets the "fileSize" field.
func (_u *AttachmentUpdateOne) SetFileSize(v int) *AttachmentUpdateOne {
_u.mutation.ResetFileSize()
_u.mutation.SetFileSize(v)
return _u
}
// SetNillableFileSize sets the "fileSize" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableFileSize(v *int) *AttachmentUpdateOne {
if v != nil {
_u.SetFileSize(*v)
}
return _u
}
// AddFileSize adds value to the "fileSize" field.
func (_u *AttachmentUpdateOne) AddFileSize(v int) *AttachmentUpdateOne {
_u.mutation.AddFileSize(v)
return _u
}
// SetUploader sets the "uploader" field.
func (_u *AttachmentUpdateOne) SetUploader(v string) *AttachmentUpdateOne {
_u.mutation.SetUploader(v)
return _u
}
// SetNillableUploader sets the "uploader" field if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableUploader(v *string) *AttachmentUpdateOne {
if v != nil {
_u.SetUploader(*v)
}
return _u
}
// Mutation returns the AttachmentMutation object of the builder.
func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation {
return _u.mutation
}
// Where appends a list predicates to the AttachmentUpdate builder.
func (_u *AttachmentUpdateOne) Where(ps ...predicate.Attachment) *AttachmentUpdateOne {
_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 *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated Attachment entity.
func (_u *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AttachmentUpdateOne) SaveX(ctx context.Context) *Attachment {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AttachmentUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AttachmentUpdateOne) 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 *AttachmentUpdateOne) check() error {
if v, ok := _u.mutation.BizType(); ok {
if err := attachment.BizTypeValidator(v); err != nil {
return &ValidationError{Name: "bizType", err: fmt.Errorf(`ent: validator failed for field "Attachment.bizType": %w`, err)}
}
}
if v, ok := _u.mutation.BizId(); ok {
if err := attachment.BizIdValidator(v); err != nil {
return &ValidationError{Name: "bizId", err: fmt.Errorf(`ent: validator failed for field "Attachment.bizId": %w`, err)}
}
}
if v, ok := _u.mutation.FileName(); ok {
if err := attachment.FileNameValidator(v); err != nil {
return &ValidationError{Name: "fileName", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileName": %w`, err)}
}
}
if v, ok := _u.mutation.FilePath(); ok {
if err := attachment.FilePathValidator(v); err != nil {
return &ValidationError{Name: "filePath", err: fmt.Errorf(`ent: validator failed for field "Attachment.filePath": %w`, err)}
}
}
if v, ok := _u.mutation.Uploader(); ok {
if err := attachment.UploaderValidator(v); err != nil {
return &ValidationError{Name: "uploader", err: fmt.Errorf(`ent: validator failed for field "Attachment.uploader": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *AttachmentUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AttachmentUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attachment.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, attachment.FieldID)
for _, f := range fields {
if !attachment.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != attachment.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.BizType(); ok {
_spec.SetField(attachment.FieldBizType, field.TypeString, value)
}
if value, ok := _u.mutation.BizId(); ok {
_spec.SetField(attachment.FieldBizId, field.TypeString, value)
}
if value, ok := _u.mutation.FileName(); ok {
_spec.SetField(attachment.FieldFileName, field.TypeString, value)
}
if value, ok := _u.mutation.FilePath(); ok {
_spec.SetField(attachment.FieldFilePath, field.TypeString, value)
}
if value, ok := _u.mutation.FileSize(); ok {
_spec.SetField(attachment.FieldFileSize, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedFileSize(); ok {
_spec.AddField(attachment.FieldFileSize, field.TypeInt, value)
}
if value, ok := _u.mutation.Uploader(); ok {
_spec.SetField(attachment.FieldUploader, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &Attachment{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{attachment.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}