- 新增过程巡检按步骤上报、数量不符上报、工位退料功能 - 增加工单工程编号三级归属字段 - 新增物料安全库存与缺货预警 - 新增附件管理、退库单管理模块 - 优化生产看板展示逻辑与前端页面文案 - 清理冗余的工艺路线相关代码与备份文件
524 lines
15 KiB
Go
524 lines
15 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/attachment"
|
|
"bj_power_wms/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
|
|
}
|
|
|
|
// 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 "biz_type" field.
|
|
func (_u *AttachmentUpdate) SetBizType(v string) *AttachmentUpdate {
|
|
_u.mutation.SetBizType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizType sets the "biz_type" 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 "biz_id" field.
|
|
func (_u *AttachmentUpdate) SetBizID(v string) *AttachmentUpdate {
|
|
_u.mutation.SetBizID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizID sets the "biz_id" 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 "file_name" field.
|
|
func (_u *AttachmentUpdate) SetFileName(v string) *AttachmentUpdate {
|
|
_u.mutation.SetFileName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFileName sets the "file_name" 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 "file_path" field.
|
|
func (_u *AttachmentUpdate) SetFilePath(v string) *AttachmentUpdate {
|
|
_u.mutation.SetFilePath(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFilePath sets the "file_path" 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 "file_size" field.
|
|
func (_u *AttachmentUpdate) SetFileSize(v int64) *AttachmentUpdate {
|
|
_u.mutation.ResetFileSize()
|
|
_u.mutation.SetFileSize(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFileSize sets the "file_size" field if the given value is not nil.
|
|
func (_u *AttachmentUpdate) SetNillableFileSize(v *int64) *AttachmentUpdate {
|
|
if v != nil {
|
|
_u.SetFileSize(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFileSize adds value to the "file_size" field.
|
|
func (_u *AttachmentUpdate) AddFileSize(v int64) *AttachmentUpdate {
|
|
_u.mutation.AddFileSize(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMimeType sets the "mime_type" field.
|
|
func (_u *AttachmentUpdate) SetMimeType(v string) *AttachmentUpdate {
|
|
_u.mutation.SetMimeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
|
|
func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate {
|
|
if v != nil {
|
|
_u.SetMimeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMimeType clears the value of the "mime_type" field.
|
|
func (_u *AttachmentUpdate) ClearMimeType() *AttachmentUpdate {
|
|
_u.mutation.ClearMimeType()
|
|
return _u
|
|
}
|
|
|
|
// SetUploadedBy sets the "uploaded_by" field.
|
|
func (_u *AttachmentUpdate) SetUploadedBy(v string) *AttachmentUpdate {
|
|
_u.mutation.SetUploadedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUploadedBy sets the "uploaded_by" field if the given value is not nil.
|
|
func (_u *AttachmentUpdate) SetNillableUploadedBy(v *string) *AttachmentUpdate {
|
|
if v != nil {
|
|
_u.SetUploadedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUploadedBy clears the value of the "uploaded_by" field.
|
|
func (_u *AttachmentUpdate) ClearUploadedBy() *AttachmentUpdate {
|
|
_u.mutation.ClearUploadedBy()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AttachmentUpdate) SetCreatedAt(v int64) *AttachmentUpdate {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AttachmentUpdate) SetNillableCreatedAt(v *int64) *AttachmentUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *AttachmentUpdate) AddCreatedAt(v int64) *AttachmentUpdate {
|
|
_u.mutation.AddCreatedAt(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)
|
|
}
|
|
}
|
|
|
|
func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_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.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFileSize(); ok {
|
|
_spec.AddField(attachment.FieldFileSize, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.MimeType(); ok {
|
|
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MimeTypeCleared() {
|
|
_spec.ClearField(attachment.FieldMimeType, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.UploadedBy(); ok {
|
|
_spec.SetField(attachment.FieldUploadedBy, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UploadedByCleared() {
|
|
_spec.ClearField(attachment.FieldUploadedBy, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(attachment.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
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
|
|
}
|
|
|
|
// SetBizType sets the "biz_type" field.
|
|
func (_u *AttachmentUpdateOne) SetBizType(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetBizType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizType sets the "biz_type" 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 "biz_id" field.
|
|
func (_u *AttachmentUpdateOne) SetBizID(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetBizID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizID sets the "biz_id" 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 "file_name" field.
|
|
func (_u *AttachmentUpdateOne) SetFileName(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetFileName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFileName sets the "file_name" 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 "file_path" field.
|
|
func (_u *AttachmentUpdateOne) SetFilePath(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetFilePath(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFilePath sets the "file_path" 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 "file_size" field.
|
|
func (_u *AttachmentUpdateOne) SetFileSize(v int64) *AttachmentUpdateOne {
|
|
_u.mutation.ResetFileSize()
|
|
_u.mutation.SetFileSize(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFileSize sets the "file_size" field if the given value is not nil.
|
|
func (_u *AttachmentUpdateOne) SetNillableFileSize(v *int64) *AttachmentUpdateOne {
|
|
if v != nil {
|
|
_u.SetFileSize(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFileSize adds value to the "file_size" field.
|
|
func (_u *AttachmentUpdateOne) AddFileSize(v int64) *AttachmentUpdateOne {
|
|
_u.mutation.AddFileSize(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMimeType sets the "mime_type" field.
|
|
func (_u *AttachmentUpdateOne) SetMimeType(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetMimeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
|
|
func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateOne {
|
|
if v != nil {
|
|
_u.SetMimeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMimeType clears the value of the "mime_type" field.
|
|
func (_u *AttachmentUpdateOne) ClearMimeType() *AttachmentUpdateOne {
|
|
_u.mutation.ClearMimeType()
|
|
return _u
|
|
}
|
|
|
|
// SetUploadedBy sets the "uploaded_by" field.
|
|
func (_u *AttachmentUpdateOne) SetUploadedBy(v string) *AttachmentUpdateOne {
|
|
_u.mutation.SetUploadedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUploadedBy sets the "uploaded_by" field if the given value is not nil.
|
|
func (_u *AttachmentUpdateOne) SetNillableUploadedBy(v *string) *AttachmentUpdateOne {
|
|
if v != nil {
|
|
_u.SetUploadedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUploadedBy clears the value of the "uploaded_by" field.
|
|
func (_u *AttachmentUpdateOne) ClearUploadedBy() *AttachmentUpdateOne {
|
|
_u.mutation.ClearUploadedBy()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AttachmentUpdateOne) SetCreatedAt(v int64) *AttachmentUpdateOne {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AttachmentUpdateOne) SetNillableCreatedAt(v *int64) *AttachmentUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *AttachmentUpdateOne) AddCreatedAt(v int64) *AttachmentUpdateOne {
|
|
_u.mutation.AddCreatedAt(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)
|
|
}
|
|
}
|
|
|
|
func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) {
|
|
_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.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFileSize(); ok {
|
|
_spec.AddField(attachment.FieldFileSize, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.MimeType(); ok {
|
|
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MimeTypeCleared() {
|
|
_spec.ClearField(attachment.FieldMimeType, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.UploadedBy(); ok {
|
|
_spec.SetField(attachment.FieldUploadedBy, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UploadedByCleared() {
|
|
_spec.ClearField(attachment.FieldUploadedBy, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(attachment.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
_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
|
|
}
|