From 62e45b7379fe0ce8ef659a526ab89281a57997c4 Mon Sep 17 00:00:00 2001 From: SunYF <123@hard_man.com> Date: Sat, 19 Sep 2026 10:54:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E9=87=8D=E6=9E=84=E4=B8=8E=E7=A3=81=E7=9B=98?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=89=A9=E6=96=99=E6=A1=A3=E6=A1=88=E4=B8=8E=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8D=95=E8=A7=84=E5=88=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增跨平台磁盘空间监控能力,每日7点自动检测附件目录剩余空间,触发阈值告警 2. 重构附件存储方案为年/月/日/文件类型分层结构,统一MES与WMS的附件管理逻辑 3. 对齐物料档案与入库单的质量状态校验规则,仅合格品计入库存与出库 4. 实现入库单作废功能与区域库位的多级父子结构管理 5. 删除物料简称字段,补充规格型号与单位必填项,统一系统数据口径 6. 新增附件中心与磁盘状态查询接口,完善权限控制与操作日志 --- bj_power_mes/ent/attachment.go | 107 +- bj_power_mes/ent/attachment/attachment.go | 100 ++ bj_power_mes/ent/attachment/where.go | 470 ++++++ bj_power_mes/ent/attachment_create.go | 250 +++ bj_power_mes/ent/attachment_update.go | 396 +++++ bj_power_mes/ent/migrate/schema.go | 24 +- bj_power_mes/ent/mutation.go | 662 +++++++- bj_power_mes/ent/producttype.go | 27 +- bj_power_mes/ent/producttype/producttype.go | 32 +- bj_power_mes/ent/producttype/where.go | 154 +- bj_power_mes/ent/producttype_create.go | 64 +- bj_power_mes/ent/producttype_update.go | 88 +- bj_power_mes/ent/runtime.go | 70 +- bj_power_mes/etc/bj_power_mes-api.yaml | 20 +- bj_power_mes/frontend/src/help.js | 27 +- .../frontend/src/pages/Attachment.vue | 242 ++- .../frontend/src/pages/ProductType.vue | 26 +- .../frontend/src/pages/QualityInspection.vue | 3 +- bj_power_mes/go.mod | 2 +- bj_power_mes/internal/config/config.go | 15 +- bj_power_mes/internal/db/db.go | 18 + bj_power_mes/internal/handler/attachment.go | 295 +++- .../internal/handler/attachment_monitor.go | 105 ++ .../internal/handler/disk_space_unix.go | 19 + .../internal/handler/disk_space_windows.go | 22 + bj_power_mes/internal/handler/inspection.go | 8 +- bj_power_mes/internal/handler/processflow.go | 15 +- .../internal/handler/routes_production.go | 12 +- bj_power_mes/internal/handler/upload.go | 275 +++- bj_power_mes/internal/logic/attachment.go | 89 +- bj_power_mes/internal/logic/product.go | 29 +- bj_power_mes/internal/wmsclient/client.go | 14 +- bj_power_mes/main.go | 3 + bj_power_mes/schema/attachment.go | 17 +- bj_power_mes/schema/product_type.go | 5 +- bj_power_wms/bj_power_wms.go | 3 + bj_power_wms/ent/attachment.go | 96 +- bj_power_wms/ent/attachment/attachment.go | 68 + bj_power_wms/ent/attachment/where.go | 460 ++++++ bj_power_wms/ent/attachment_create.go | 638 ++++++++ bj_power_wms/ent/attachment_update.go | 420 ++++++ bj_power_wms/ent/dock.go | 4 +- bj_power_wms/ent/inboundorder.go | 50 +- bj_power_wms/ent/inboundorder/inboundorder.go | 34 + bj_power_wms/ent/inboundorder/where.go | 230 +++ bj_power_wms/ent/inboundorder_create.go | 319 ++++ bj_power_wms/ent/inboundorder_update.go | 210 +++ bj_power_wms/ent/material.go | 13 +- bj_power_wms/ent/material/material.go | 8 - bj_power_wms/ent/material/where.go | 80 - bj_power_wms/ent/material_create.go | 78 - bj_power_wms/ent/material_update.go | 52 - bj_power_wms/ent/migrate/schema.go | 38 +- bj_power_wms/ent/mutation.go | 1342 +++++++++++++++-- bj_power_wms/ent/runtime.go | 40 +- bj_power_wms/ent/zone.go | 60 +- bj_power_wms/ent/zone/where.go | 285 ++++ bj_power_wms/ent/zone/zone.go | 32 + bj_power_wms/ent/zone_create.go | 319 +++- bj_power_wms/ent/zone_query.go | 8 +- bj_power_wms/ent/zone_update.go | 210 +++ bj_power_wms/etc/bj_power_wms-api-verify.yaml | 10 + bj_power_wms/etc/bj_power_wms-api.yaml | 17 + bj_power_wms/frontend/src/help.js | 56 +- .../frontend/src/layouts/MainLayout.vue | 5 +- .../frontend/src/pages/AttachmentCenter.vue | 222 +++ bj_power_wms/frontend/src/pages/BaseData.vue | 818 ++++++---- bj_power_wms/frontend/src/pages/Inbound.vue | 224 ++- bj_power_wms/frontend/src/router/index.js | 3 +- bj_power_wms/go.mod | 2 +- bj_power_wms/internal/config/config.go | 29 +- bj_power_wms/internal/db/db.go | 45 +- bj_power_wms/internal/db/seed.go | 12 +- bj_power_wms/internal/handler/attachment.go | 491 +++++- bj_power_wms/internal/handler/backflush.go | 3 +- .../internal/handler/disk_space_unix.go | 19 + .../internal/handler/disk_space_windows.go | 22 + bj_power_wms/internal/handler/inbound.go | 6 + bj_power_wms/internal/handler/inbound_void.go | 163 ++ bj_power_wms/internal/handler/material.go | 111 +- bj_power_wms/internal/handler/misc.go | 5 +- bj_power_wms/internal/handler/outbound.go | 29 +- bj_power_wms/internal/handler/producttype.go | 41 +- bj_power_wms/internal/handler/quality.go | 29 + bj_power_wms/internal/handler/rbac_admin.go | 3 + bj_power_wms/internal/handler/routes.go | 21 +- bj_power_wms/internal/handler/stock.go | 19 +- bj_power_wms/internal/handler/zone.go | 728 +++++---- .../internal/handler/zone_recommend.go | 116 +- bj_power_wms/schema/attachment.go | 23 +- bj_power_wms/schema/inbound_order.go | 6 + bj_power_wms/schema/material.go | 5 +- bj_power_wms/schema/zone.go | 35 +- .../internal/handler/proxy.go | 32 +- 临时.md | 992 ------------ 95 files changed, 10467 insertions(+), 2677 deletions(-) create mode 100644 bj_power_mes/internal/handler/attachment_monitor.go create mode 100644 bj_power_mes/internal/handler/disk_space_unix.go create mode 100644 bj_power_mes/internal/handler/disk_space_windows.go create mode 100644 bj_power_wms/frontend/src/pages/AttachmentCenter.vue create mode 100644 bj_power_wms/internal/handler/disk_space_unix.go create mode 100644 bj_power_wms/internal/handler/disk_space_windows.go create mode 100644 bj_power_wms/internal/handler/inbound_void.go create mode 100644 bj_power_wms/internal/handler/quality.go diff --git a/bj_power_mes/ent/attachment.go b/bj_power_mes/ent/attachment.go index 57c3986..72b09f9 100644 --- a/bj_power_mes/ent/attachment.go +++ b/bj_power_mes/ent/attachment.go @@ -30,7 +30,25 @@ type Attachment struct { // 上传人 Uploader string `json:"uploader,omitempty"` // CreatedAt holds the value of the "createdAt" field. - CreatedAt time.Time `json:"createdAt,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty"` + // 文件类型 大写枚举 PROCESS_PDF/INSPECTION_PHOTO/... + FileType string `json:"fileType,omitempty"` + // 扩展名(小写,不含点) + FileExt string `json:"fileExt,omitempty"` + // 文件MD5(秒传/去重) + FileMd5 string `json:"fileMd5,omitempty"` + // MIME类型 + MimeType string `json:"mimeType,omitempty"` + // 是否已归档 + Archived bool `json:"archived,omitempty"` + // 归档时间(unix秒) + ArchivedAt int64 `json:"archivedAt,omitempty"` + // 逻辑删除 + Deleted bool `json:"deleted,omitempty"` + // 删除时间(unix秒) + DeletedAt int64 `json:"deletedAt,omitempty"` + // 删除人 + DeletedBy string `json:"deletedBy,omitempty"` selectValues sql.SelectValues } @@ -39,9 +57,11 @@ func (*Attachment) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case attachment.FieldID, attachment.FieldFileSize: + case attachment.FieldArchived, attachment.FieldDeleted: + values[i] = new(sql.NullBool) + case attachment.FieldID, attachment.FieldFileSize, attachment.FieldArchivedAt, attachment.FieldDeletedAt: values[i] = new(sql.NullInt64) - case attachment.FieldBizType, attachment.FieldBizId, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldUploader: + case attachment.FieldBizType, attachment.FieldBizId, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldUploader, attachment.FieldFileType, attachment.FieldFileExt, attachment.FieldFileMd5, attachment.FieldMimeType, attachment.FieldDeletedBy: values[i] = new(sql.NullString) case attachment.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -108,6 +128,60 @@ func (_m *Attachment) assignValues(columns []string, values []any) error { } else if value.Valid { _m.CreatedAt = value.Time } + case attachment.FieldFileType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field fileType", values[i]) + } else if value.Valid { + _m.FileType = value.String + } + case attachment.FieldFileExt: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field fileExt", values[i]) + } else if value.Valid { + _m.FileExt = value.String + } + case attachment.FieldFileMd5: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field fileMd5", values[i]) + } else if value.Valid { + _m.FileMd5 = value.String + } + case attachment.FieldMimeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field mimeType", values[i]) + } else if value.Valid { + _m.MimeType = value.String + } + case attachment.FieldArchived: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field archived", values[i]) + } else if value.Valid { + _m.Archived = value.Bool + } + case attachment.FieldArchivedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field archivedAt", values[i]) + } else if value.Valid { + _m.ArchivedAt = value.Int64 + } + case attachment.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case attachment.FieldDeletedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deletedAt", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Int64 + } + case attachment.FieldDeletedBy: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field deletedBy", values[i]) + } else if value.Valid { + _m.DeletedBy = value.String + } default: _m.selectValues.Set(columns[i], values[i]) } @@ -164,6 +238,33 @@ func (_m *Attachment) String() string { builder.WriteString(", ") builder.WriteString("createdAt=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("fileType=") + builder.WriteString(_m.FileType) + builder.WriteString(", ") + builder.WriteString("fileExt=") + builder.WriteString(_m.FileExt) + builder.WriteString(", ") + builder.WriteString("fileMd5=") + builder.WriteString(_m.FileMd5) + builder.WriteString(", ") + builder.WriteString("mimeType=") + builder.WriteString(_m.MimeType) + builder.WriteString(", ") + builder.WriteString("archived=") + builder.WriteString(fmt.Sprintf("%v", _m.Archived)) + builder.WriteString(", ") + builder.WriteString("archivedAt=") + builder.WriteString(fmt.Sprintf("%v", _m.ArchivedAt)) + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("deletedAt=") + builder.WriteString(fmt.Sprintf("%v", _m.DeletedAt)) + builder.WriteString(", ") + builder.WriteString("deletedBy=") + builder.WriteString(_m.DeletedBy) builder.WriteByte(')') return builder.String() } diff --git a/bj_power_mes/ent/attachment/attachment.go b/bj_power_mes/ent/attachment/attachment.go index 182d659..dd7c713 100644 --- a/bj_power_mes/ent/attachment/attachment.go +++ b/bj_power_mes/ent/attachment/attachment.go @@ -27,6 +27,24 @@ const ( FieldUploader = "uploader" // FieldCreatedAt holds the string denoting the createdat field in the database. FieldCreatedAt = "created_at" + // FieldFileType holds the string denoting the filetype field in the database. + FieldFileType = "file_type" + // FieldFileExt holds the string denoting the fileext field in the database. + FieldFileExt = "file_ext" + // FieldFileMd5 holds the string denoting the filemd5 field in the database. + FieldFileMd5 = "file_md5" + // FieldMimeType holds the string denoting the mimetype field in the database. + FieldMimeType = "mime_type" + // FieldArchived holds the string denoting the archived field in the database. + FieldArchived = "archived" + // FieldArchivedAt holds the string denoting the archivedat field in the database. + FieldArchivedAt = "archived_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldDeletedAt holds the string denoting the deletedat field in the database. + FieldDeletedAt = "deleted_at" + // FieldDeletedBy holds the string denoting the deletedby field in the database. + FieldDeletedBy = "deleted_by" // Table holds the table name of the attachment in the database. Table = "attachment" ) @@ -41,6 +59,15 @@ var Columns = []string{ FieldFileSize, FieldUploader, FieldCreatedAt, + FieldFileType, + FieldFileExt, + FieldFileMd5, + FieldMimeType, + FieldArchived, + FieldArchivedAt, + FieldDeleted, + FieldDeletedAt, + FieldDeletedBy, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -70,6 +97,34 @@ var ( UploaderValidator func(string) error // DefaultCreatedAt holds the default value on creation for the "createdAt" field. DefaultCreatedAt func() time.Time + // DefaultFileType holds the default value on creation for the "fileType" field. + DefaultFileType string + // FileTypeValidator is a validator for the "fileType" field. It is called by the builders before save. + FileTypeValidator func(string) error + // DefaultFileExt holds the default value on creation for the "fileExt" field. + DefaultFileExt string + // FileExtValidator is a validator for the "fileExt" field. It is called by the builders before save. + FileExtValidator func(string) error + // DefaultFileMd5 holds the default value on creation for the "fileMd5" field. + DefaultFileMd5 string + // FileMd5Validator is a validator for the "fileMd5" field. It is called by the builders before save. + FileMd5Validator func(string) error + // DefaultMimeType holds the default value on creation for the "mimeType" field. + DefaultMimeType string + // MimeTypeValidator is a validator for the "mimeType" field. It is called by the builders before save. + MimeTypeValidator func(string) error + // DefaultArchived holds the default value on creation for the "archived" field. + DefaultArchived bool + // DefaultArchivedAt holds the default value on creation for the "archivedAt" field. + DefaultArchivedAt int64 + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted bool + // DefaultDeletedAt holds the default value on creation for the "deletedAt" field. + DefaultDeletedAt int64 + // DefaultDeletedBy holds the default value on creation for the "deletedBy" field. + DefaultDeletedBy string + // DeletedByValidator is a validator for the "deletedBy" field. It is called by the builders before save. + DeletedByValidator func(string) error // IDValidator is a validator for the "id" field. It is called by the builders before save. IDValidator func(int) error ) @@ -116,3 +171,48 @@ func ByUploader(opts ...sql.OrderTermOption) OrderOption { func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } + +// ByFileType orders the results by the fileType field. +func ByFileType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileType, opts...).ToFunc() +} + +// ByFileExt orders the results by the fileExt field. +func ByFileExt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileExt, opts...).ToFunc() +} + +// ByFileMd5 orders the results by the fileMd5 field. +func ByFileMd5(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileMd5, opts...).ToFunc() +} + +// ByMimeType orders the results by the mimeType field. +func ByMimeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMimeType, opts...).ToFunc() +} + +// ByArchived orders the results by the archived field. +func ByArchived(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArchived, opts...).ToFunc() +} + +// ByArchivedAt orders the results by the archivedAt field. +func ByArchivedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArchivedAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deletedAt field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByDeletedBy orders the results by the deletedBy field. +func ByDeletedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedBy, opts...).ToFunc() +} diff --git a/bj_power_mes/ent/attachment/where.go b/bj_power_mes/ent/attachment/where.go index ae306d5..a14150c 100644 --- a/bj_power_mes/ent/attachment/where.go +++ b/bj_power_mes/ent/attachment/where.go @@ -89,6 +89,51 @@ func CreatedAt(v time.Time) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldCreatedAt, v)) } +// FileType applies equality check predicate on the "fileType" field. It's identical to FileTypeEQ. +func FileType(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileType, v)) +} + +// FileExt applies equality check predicate on the "fileExt" field. It's identical to FileExtEQ. +func FileExt(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileExt, v)) +} + +// FileMd5 applies equality check predicate on the "fileMd5" field. It's identical to FileMd5EQ. +func FileMd5(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileMd5, v)) +} + +// MimeType applies equality check predicate on the "mimeType" field. It's identical to MimeTypeEQ. +func MimeType(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldMimeType, v)) +} + +// Archived applies equality check predicate on the "archived" field. It's identical to ArchivedEQ. +func Archived(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchived, v)) +} + +// ArchivedAt applies equality check predicate on the "archivedAt" field. It's identical to ArchivedAtEQ. +func ArchivedAt(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchivedAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedAt applies equality check predicate on the "deletedAt" field. It's identical to DeletedAtEQ. +func DeletedAt(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedBy applies equality check predicate on the "deletedBy" field. It's identical to DeletedByEQ. +func DeletedBy(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedBy, v)) +} + // BizTypeEQ applies the EQ predicate on the "bizType" field. func BizTypeEQ(v string) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldBizType, v)) @@ -494,6 +539,431 @@ func CreatedAtLTE(v time.Time) predicate.Attachment { return predicate.Attachment(sql.FieldLTE(FieldCreatedAt, v)) } +// FileTypeEQ applies the EQ predicate on the "fileType" field. +func FileTypeEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileType, v)) +} + +// FileTypeNEQ applies the NEQ predicate on the "fileType" field. +func FileTypeNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileType, v)) +} + +// FileTypeIn applies the In predicate on the "fileType" field. +func FileTypeIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileType, vs...)) +} + +// FileTypeNotIn applies the NotIn predicate on the "fileType" field. +func FileTypeNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileType, vs...)) +} + +// FileTypeGT applies the GT predicate on the "fileType" field. +func FileTypeGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileType, v)) +} + +// FileTypeGTE applies the GTE predicate on the "fileType" field. +func FileTypeGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileType, v)) +} + +// FileTypeLT applies the LT predicate on the "fileType" field. +func FileTypeLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileType, v)) +} + +// FileTypeLTE applies the LTE predicate on the "fileType" field. +func FileTypeLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileType, v)) +} + +// FileTypeContains applies the Contains predicate on the "fileType" field. +func FileTypeContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileType, v)) +} + +// FileTypeHasPrefix applies the HasPrefix predicate on the "fileType" field. +func FileTypeHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileType, v)) +} + +// FileTypeHasSuffix applies the HasSuffix predicate on the "fileType" field. +func FileTypeHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileType, v)) +} + +// FileTypeEqualFold applies the EqualFold predicate on the "fileType" field. +func FileTypeEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileType, v)) +} + +// FileTypeContainsFold applies the ContainsFold predicate on the "fileType" field. +func FileTypeContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileType, v)) +} + +// FileExtEQ applies the EQ predicate on the "fileExt" field. +func FileExtEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileExt, v)) +} + +// FileExtNEQ applies the NEQ predicate on the "fileExt" field. +func FileExtNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileExt, v)) +} + +// FileExtIn applies the In predicate on the "fileExt" field. +func FileExtIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileExt, vs...)) +} + +// FileExtNotIn applies the NotIn predicate on the "fileExt" field. +func FileExtNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileExt, vs...)) +} + +// FileExtGT applies the GT predicate on the "fileExt" field. +func FileExtGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileExt, v)) +} + +// FileExtGTE applies the GTE predicate on the "fileExt" field. +func FileExtGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileExt, v)) +} + +// FileExtLT applies the LT predicate on the "fileExt" field. +func FileExtLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileExt, v)) +} + +// FileExtLTE applies the LTE predicate on the "fileExt" field. +func FileExtLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileExt, v)) +} + +// FileExtContains applies the Contains predicate on the "fileExt" field. +func FileExtContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileExt, v)) +} + +// FileExtHasPrefix applies the HasPrefix predicate on the "fileExt" field. +func FileExtHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileExt, v)) +} + +// FileExtHasSuffix applies the HasSuffix predicate on the "fileExt" field. +func FileExtHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileExt, v)) +} + +// FileExtEqualFold applies the EqualFold predicate on the "fileExt" field. +func FileExtEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileExt, v)) +} + +// FileExtContainsFold applies the ContainsFold predicate on the "fileExt" field. +func FileExtContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileExt, v)) +} + +// FileMd5EQ applies the EQ predicate on the "fileMd5" field. +func FileMd5EQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileMd5, v)) +} + +// FileMd5NEQ applies the NEQ predicate on the "fileMd5" field. +func FileMd5NEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileMd5, v)) +} + +// FileMd5In applies the In predicate on the "fileMd5" field. +func FileMd5In(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileMd5, vs...)) +} + +// FileMd5NotIn applies the NotIn predicate on the "fileMd5" field. +func FileMd5NotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileMd5, vs...)) +} + +// FileMd5GT applies the GT predicate on the "fileMd5" field. +func FileMd5GT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileMd5, v)) +} + +// FileMd5GTE applies the GTE predicate on the "fileMd5" field. +func FileMd5GTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileMd5, v)) +} + +// FileMd5LT applies the LT predicate on the "fileMd5" field. +func FileMd5LT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileMd5, v)) +} + +// FileMd5LTE applies the LTE predicate on the "fileMd5" field. +func FileMd5LTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileMd5, v)) +} + +// FileMd5Contains applies the Contains predicate on the "fileMd5" field. +func FileMd5Contains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileMd5, v)) +} + +// FileMd5HasPrefix applies the HasPrefix predicate on the "fileMd5" field. +func FileMd5HasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileMd5, v)) +} + +// FileMd5HasSuffix applies the HasSuffix predicate on the "fileMd5" field. +func FileMd5HasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileMd5, v)) +} + +// FileMd5EqualFold applies the EqualFold predicate on the "fileMd5" field. +func FileMd5EqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileMd5, v)) +} + +// FileMd5ContainsFold applies the ContainsFold predicate on the "fileMd5" field. +func FileMd5ContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileMd5, v)) +} + +// MimeTypeEQ applies the EQ predicate on the "mimeType" field. +func MimeTypeEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldMimeType, v)) +} + +// MimeTypeNEQ applies the NEQ predicate on the "mimeType" field. +func MimeTypeNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldMimeType, v)) +} + +// MimeTypeIn applies the In predicate on the "mimeType" field. +func MimeTypeIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldMimeType, vs...)) +} + +// MimeTypeNotIn applies the NotIn predicate on the "mimeType" field. +func MimeTypeNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldMimeType, vs...)) +} + +// MimeTypeGT applies the GT predicate on the "mimeType" field. +func MimeTypeGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldMimeType, v)) +} + +// MimeTypeGTE applies the GTE predicate on the "mimeType" field. +func MimeTypeGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldMimeType, v)) +} + +// MimeTypeLT applies the LT predicate on the "mimeType" field. +func MimeTypeLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldMimeType, v)) +} + +// MimeTypeLTE applies the LTE predicate on the "mimeType" field. +func MimeTypeLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldMimeType, v)) +} + +// MimeTypeContains applies the Contains predicate on the "mimeType" field. +func MimeTypeContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldMimeType, v)) +} + +// MimeTypeHasPrefix applies the HasPrefix predicate on the "mimeType" field. +func MimeTypeHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldMimeType, v)) +} + +// MimeTypeHasSuffix applies the HasSuffix predicate on the "mimeType" field. +func MimeTypeHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldMimeType, v)) +} + +// MimeTypeEqualFold applies the EqualFold predicate on the "mimeType" field. +func MimeTypeEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldMimeType, v)) +} + +// MimeTypeContainsFold applies the ContainsFold predicate on the "mimeType" field. +func MimeTypeContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldMimeType, v)) +} + +// ArchivedEQ applies the EQ predicate on the "archived" field. +func ArchivedEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchived, v)) +} + +// ArchivedNEQ applies the NEQ predicate on the "archived" field. +func ArchivedNEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldArchived, v)) +} + +// ArchivedAtEQ applies the EQ predicate on the "archivedAt" field. +func ArchivedAtEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchivedAt, v)) +} + +// ArchivedAtNEQ applies the NEQ predicate on the "archivedAt" field. +func ArchivedAtNEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldArchivedAt, v)) +} + +// ArchivedAtIn applies the In predicate on the "archivedAt" field. +func ArchivedAtIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldArchivedAt, vs...)) +} + +// ArchivedAtNotIn applies the NotIn predicate on the "archivedAt" field. +func ArchivedAtNotIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldArchivedAt, vs...)) +} + +// ArchivedAtGT applies the GT predicate on the "archivedAt" field. +func ArchivedAtGT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldArchivedAt, v)) +} + +// ArchivedAtGTE applies the GTE predicate on the "archivedAt" field. +func ArchivedAtGTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldArchivedAt, v)) +} + +// ArchivedAtLT applies the LT predicate on the "archivedAt" field. +func ArchivedAtLT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldArchivedAt, v)) +} + +// ArchivedAtLTE applies the LTE predicate on the "archivedAt" field. +func ArchivedAtLTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldArchivedAt, v)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deletedAt" field. +func DeletedAtEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deletedAt" field. +func DeletedAtNEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deletedAt" field. +func DeletedAtIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deletedAt" field. +func DeletedAtNotIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deletedAt" field. +func DeletedAtGT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deletedAt" field. +func DeletedAtGTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deletedAt" field. +func DeletedAtLT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deletedAt" field. +func DeletedAtLTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedByEQ applies the EQ predicate on the "deletedBy" field. +func DeletedByEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedBy, v)) +} + +// DeletedByNEQ applies the NEQ predicate on the "deletedBy" field. +func DeletedByNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeletedBy, v)) +} + +// DeletedByIn applies the In predicate on the "deletedBy" field. +func DeletedByIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldDeletedBy, vs...)) +} + +// DeletedByNotIn applies the NotIn predicate on the "deletedBy" field. +func DeletedByNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldDeletedBy, vs...)) +} + +// DeletedByGT applies the GT predicate on the "deletedBy" field. +func DeletedByGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldDeletedBy, v)) +} + +// DeletedByGTE applies the GTE predicate on the "deletedBy" field. +func DeletedByGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldDeletedBy, v)) +} + +// DeletedByLT applies the LT predicate on the "deletedBy" field. +func DeletedByLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldDeletedBy, v)) +} + +// DeletedByLTE applies the LTE predicate on the "deletedBy" field. +func DeletedByLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldDeletedBy, v)) +} + +// DeletedByContains applies the Contains predicate on the "deletedBy" field. +func DeletedByContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldDeletedBy, v)) +} + +// DeletedByHasPrefix applies the HasPrefix predicate on the "deletedBy" field. +func DeletedByHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldDeletedBy, v)) +} + +// DeletedByHasSuffix applies the HasSuffix predicate on the "deletedBy" field. +func DeletedByHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldDeletedBy, v)) +} + +// DeletedByEqualFold applies the EqualFold predicate on the "deletedBy" field. +func DeletedByEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldDeletedBy, v)) +} + +// DeletedByContainsFold applies the ContainsFold predicate on the "deletedBy" field. +func DeletedByContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldDeletedBy, v)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Attachment) predicate.Attachment { return predicate.Attachment(sql.AndPredicates(predicates...)) diff --git a/bj_power_mes/ent/attachment_create.go b/bj_power_mes/ent/attachment_create.go index 0a1aaf4..ce07d77 100644 --- a/bj_power_mes/ent/attachment_create.go +++ b/bj_power_mes/ent/attachment_create.go @@ -86,6 +86,132 @@ func (_c *AttachmentCreate) SetNillableCreatedAt(v *time.Time) *AttachmentCreate return _c } +// SetFileType sets the "fileType" field. +func (_c *AttachmentCreate) SetFileType(v string) *AttachmentCreate { + _c.mutation.SetFileType(v) + return _c +} + +// SetNillableFileType sets the "fileType" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileType(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileType(*v) + } + return _c +} + +// SetFileExt sets the "fileExt" field. +func (_c *AttachmentCreate) SetFileExt(v string) *AttachmentCreate { + _c.mutation.SetFileExt(v) + return _c +} + +// SetNillableFileExt sets the "fileExt" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileExt(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileExt(*v) + } + return _c +} + +// SetFileMd5 sets the "fileMd5" field. +func (_c *AttachmentCreate) SetFileMd5(v string) *AttachmentCreate { + _c.mutation.SetFileMd5(v) + return _c +} + +// SetNillableFileMd5 sets the "fileMd5" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileMd5(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileMd5(*v) + } + return _c +} + +// SetMimeType sets the "mimeType" field. +func (_c *AttachmentCreate) SetMimeType(v string) *AttachmentCreate { + _c.mutation.SetMimeType(v) + return _c +} + +// SetNillableMimeType sets the "mimeType" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableMimeType(v *string) *AttachmentCreate { + if v != nil { + _c.SetMimeType(*v) + } + return _c +} + +// SetArchived sets the "archived" field. +func (_c *AttachmentCreate) SetArchived(v bool) *AttachmentCreate { + _c.mutation.SetArchived(v) + return _c +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableArchived(v *bool) *AttachmentCreate { + if v != nil { + _c.SetArchived(*v) + } + return _c +} + +// SetArchivedAt sets the "archivedAt" field. +func (_c *AttachmentCreate) SetArchivedAt(v int64) *AttachmentCreate { + _c.mutation.SetArchivedAt(v) + return _c +} + +// SetNillableArchivedAt sets the "archivedAt" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableArchivedAt(v *int64) *AttachmentCreate { + if v != nil { + _c.SetArchivedAt(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *AttachmentCreate) SetDeleted(v bool) *AttachmentCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeleted(v *bool) *AttachmentCreate { + if v != nil { + _c.SetDeleted(*v) + } + return _c +} + +// SetDeletedAt sets the "deletedAt" field. +func (_c *AttachmentCreate) SetDeletedAt(v int64) *AttachmentCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deletedAt" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeletedAt(v *int64) *AttachmentCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetDeletedBy sets the "deletedBy" field. +func (_c *AttachmentCreate) SetDeletedBy(v string) *AttachmentCreate { + _c.mutation.SetDeletedBy(v) + return _c +} + +// SetNillableDeletedBy sets the "deletedBy" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeletedBy(v *string) *AttachmentCreate { + if v != nil { + _c.SetDeletedBy(*v) + } + return _c +} + // SetID sets the "id" field. func (_c *AttachmentCreate) SetID(v int) *AttachmentCreate { _c.mutation.SetID(v) @@ -139,6 +265,42 @@ func (_c *AttachmentCreate) defaults() { v := attachment.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } + if _, ok := _c.mutation.FileType(); !ok { + v := attachment.DefaultFileType + _c.mutation.SetFileType(v) + } + if _, ok := _c.mutation.FileExt(); !ok { + v := attachment.DefaultFileExt + _c.mutation.SetFileExt(v) + } + if _, ok := _c.mutation.FileMd5(); !ok { + v := attachment.DefaultFileMd5 + _c.mutation.SetFileMd5(v) + } + if _, ok := _c.mutation.MimeType(); !ok { + v := attachment.DefaultMimeType + _c.mutation.SetMimeType(v) + } + if _, ok := _c.mutation.Archived(); !ok { + v := attachment.DefaultArchived + _c.mutation.SetArchived(v) + } + if _, ok := _c.mutation.ArchivedAt(); !ok { + v := attachment.DefaultArchivedAt + _c.mutation.SetArchivedAt(v) + } + if _, ok := _c.mutation.Deleted(); !ok { + v := attachment.DefaultDeleted + _c.mutation.SetDeleted(v) + } + if _, ok := _c.mutation.DeletedAt(); !ok { + v := attachment.DefaultDeletedAt + _c.mutation.SetDeletedAt(v) + } + if _, ok := _c.mutation.DeletedBy(); !ok { + v := attachment.DefaultDeletedBy + _c.mutation.SetDeletedBy(v) + } } // check runs all checks and user-defined validators on the builder. @@ -189,6 +351,58 @@ func (_c *AttachmentCreate) check() error { if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "Attachment.createdAt"`)} } + if _, ok := _c.mutation.FileType(); !ok { + return &ValidationError{Name: "fileType", err: errors.New(`ent: missing required field "Attachment.fileType"`)} + } + if v, ok := _c.mutation.FileType(); ok { + if err := attachment.FileTypeValidator(v); err != nil { + return &ValidationError{Name: "fileType", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileType": %w`, err)} + } + } + if _, ok := _c.mutation.FileExt(); !ok { + return &ValidationError{Name: "fileExt", err: errors.New(`ent: missing required field "Attachment.fileExt"`)} + } + if v, ok := _c.mutation.FileExt(); ok { + if err := attachment.FileExtValidator(v); err != nil { + return &ValidationError{Name: "fileExt", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileExt": %w`, err)} + } + } + if _, ok := _c.mutation.FileMd5(); !ok { + return &ValidationError{Name: "fileMd5", err: errors.New(`ent: missing required field "Attachment.fileMd5"`)} + } + if v, ok := _c.mutation.FileMd5(); ok { + if err := attachment.FileMd5Validator(v); err != nil { + return &ValidationError{Name: "fileMd5", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileMd5": %w`, err)} + } + } + if _, ok := _c.mutation.MimeType(); !ok { + return &ValidationError{Name: "mimeType", err: errors.New(`ent: missing required field "Attachment.mimeType"`)} + } + if v, ok := _c.mutation.MimeType(); ok { + if err := attachment.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mimeType", err: fmt.Errorf(`ent: validator failed for field "Attachment.mimeType": %w`, err)} + } + } + if _, ok := _c.mutation.Archived(); !ok { + return &ValidationError{Name: "archived", err: errors.New(`ent: missing required field "Attachment.archived"`)} + } + if _, ok := _c.mutation.ArchivedAt(); !ok { + return &ValidationError{Name: "archivedAt", err: errors.New(`ent: missing required field "Attachment.archivedAt"`)} + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "Attachment.deleted"`)} + } + if _, ok := _c.mutation.DeletedAt(); !ok { + return &ValidationError{Name: "deletedAt", err: errors.New(`ent: missing required field "Attachment.deletedAt"`)} + } + if _, ok := _c.mutation.DeletedBy(); !ok { + return &ValidationError{Name: "deletedBy", err: errors.New(`ent: missing required field "Attachment.deletedBy"`)} + } + if v, ok := _c.mutation.DeletedBy(); ok { + if err := attachment.DeletedByValidator(v); err != nil { + return &ValidationError{Name: "deletedBy", err: fmt.Errorf(`ent: validator failed for field "Attachment.deletedBy": %w`, err)} + } + } if v, ok := _c.mutation.ID(); ok { if err := attachment.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Attachment.id": %w`, err)} @@ -254,6 +468,42 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { _spec.SetField(attachment.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } + if value, ok := _c.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + _node.FileType = value + } + if value, ok := _c.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + _node.FileExt = value + } + if value, ok := _c.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + _node.FileMd5 = value + } + if value, ok := _c.mutation.MimeType(); ok { + _spec.SetField(attachment.FieldMimeType, field.TypeString, value) + _node.MimeType = value + } + if value, ok := _c.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + _node.Archived = value + } + if value, ok := _c.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + _node.ArchivedAt = value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + _node.DeletedBy = value + } return _node, _spec } diff --git a/bj_power_mes/ent/attachment_update.go b/bj_power_mes/ent/attachment_update.go index f69b6ab..13fffa1 100644 --- a/bj_power_mes/ent/attachment_update.go +++ b/bj_power_mes/ent/attachment_update.go @@ -119,6 +119,146 @@ func (_u *AttachmentUpdate) SetNillableUploader(v *string) *AttachmentUpdate { return _u } +// SetFileType sets the "fileType" field. +func (_u *AttachmentUpdate) SetFileType(v string) *AttachmentUpdate { + _u.mutation.SetFileType(v) + return _u +} + +// SetNillableFileType sets the "fileType" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileType(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileType(*v) + } + return _u +} + +// SetFileExt sets the "fileExt" field. +func (_u *AttachmentUpdate) SetFileExt(v string) *AttachmentUpdate { + _u.mutation.SetFileExt(v) + return _u +} + +// SetNillableFileExt sets the "fileExt" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileExt(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileExt(*v) + } + return _u +} + +// SetFileMd5 sets the "fileMd5" field. +func (_u *AttachmentUpdate) SetFileMd5(v string) *AttachmentUpdate { + _u.mutation.SetFileMd5(v) + return _u +} + +// SetNillableFileMd5 sets the "fileMd5" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileMd5(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileMd5(*v) + } + return _u +} + +// SetMimeType sets the "mimeType" field. +func (_u *AttachmentUpdate) SetMimeType(v string) *AttachmentUpdate { + _u.mutation.SetMimeType(v) + return _u +} + +// SetNillableMimeType sets the "mimeType" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate { + if v != nil { + _u.SetMimeType(*v) + } + return _u +} + +// SetArchived sets the "archived" field. +func (_u *AttachmentUpdate) SetArchived(v bool) *AttachmentUpdate { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableArchived(v *bool) *AttachmentUpdate { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetArchivedAt sets the "archivedAt" field. +func (_u *AttachmentUpdate) SetArchivedAt(v int64) *AttachmentUpdate { + _u.mutation.ResetArchivedAt() + _u.mutation.SetArchivedAt(v) + return _u +} + +// SetNillableArchivedAt sets the "archivedAt" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableArchivedAt(v *int64) *AttachmentUpdate { + if v != nil { + _u.SetArchivedAt(*v) + } + return _u +} + +// AddArchivedAt adds value to the "archivedAt" field. +func (_u *AttachmentUpdate) AddArchivedAt(v int64) *AttachmentUpdate { + _u.mutation.AddArchivedAt(v) + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *AttachmentUpdate) SetDeleted(v bool) *AttachmentUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeleted(v *bool) *AttachmentUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetDeletedAt sets the "deletedAt" field. +func (_u *AttachmentUpdate) SetDeletedAt(v int64) *AttachmentUpdate { + _u.mutation.ResetDeletedAt() + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deletedAt" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeletedAt(v *int64) *AttachmentUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// AddDeletedAt adds value to the "deletedAt" field. +func (_u *AttachmentUpdate) AddDeletedAt(v int64) *AttachmentUpdate { + _u.mutation.AddDeletedAt(v) + return _u +} + +// SetDeletedBy sets the "deletedBy" field. +func (_u *AttachmentUpdate) SetDeletedBy(v string) *AttachmentUpdate { + _u.mutation.SetDeletedBy(v) + return _u +} + +// SetNillableDeletedBy sets the "deletedBy" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeletedBy(v *string) *AttachmentUpdate { + if v != nil { + _u.SetDeletedBy(*v) + } + return _u +} + // Mutation returns the AttachmentMutation object of the builder. func (_u *AttachmentUpdate) Mutation() *AttachmentMutation { return _u.mutation @@ -178,6 +318,31 @@ func (_u *AttachmentUpdate) check() error { return &ValidationError{Name: "uploader", err: fmt.Errorf(`ent: validator failed for field "Attachment.uploader": %w`, err)} } } + if v, ok := _u.mutation.FileType(); ok { + if err := attachment.FileTypeValidator(v); err != nil { + return &ValidationError{Name: "fileType", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileType": %w`, err)} + } + } + if v, ok := _u.mutation.FileExt(); ok { + if err := attachment.FileExtValidator(v); err != nil { + return &ValidationError{Name: "fileExt", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileExt": %w`, err)} + } + } + if v, ok := _u.mutation.FileMd5(); ok { + if err := attachment.FileMd5Validator(v); err != nil { + return &ValidationError{Name: "fileMd5", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileMd5": %w`, err)} + } + } + if v, ok := _u.mutation.MimeType(); ok { + if err := attachment.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mimeType", err: fmt.Errorf(`ent: validator failed for field "Attachment.mimeType": %w`, err)} + } + } + if v, ok := _u.mutation.DeletedBy(); ok { + if err := attachment.DeletedByValidator(v); err != nil { + return &ValidationError{Name: "deletedBy", err: fmt.Errorf(`ent: validator failed for field "Attachment.deletedBy": %w`, err)} + } + } return nil } @@ -220,6 +385,39 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.Uploader(); ok { _spec.SetField(attachment.FieldUploader, field.TypeString, value) } + if value, ok := _u.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + } + if value, ok := _u.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + } + if value, ok := _u.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + } + if value, ok := _u.mutation.MimeType(); ok { + _spec.SetField(attachment.FieldMimeType, field.TypeString, value) + } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedArchivedAt(); ok { + _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDeletedAt(); ok { + _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -333,6 +531,146 @@ func (_u *AttachmentUpdateOne) SetNillableUploader(v *string) *AttachmentUpdateO return _u } +// SetFileType sets the "fileType" field. +func (_u *AttachmentUpdateOne) SetFileType(v string) *AttachmentUpdateOne { + _u.mutation.SetFileType(v) + return _u +} + +// SetNillableFileType sets the "fileType" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileType(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileType(*v) + } + return _u +} + +// SetFileExt sets the "fileExt" field. +func (_u *AttachmentUpdateOne) SetFileExt(v string) *AttachmentUpdateOne { + _u.mutation.SetFileExt(v) + return _u +} + +// SetNillableFileExt sets the "fileExt" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileExt(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileExt(*v) + } + return _u +} + +// SetFileMd5 sets the "fileMd5" field. +func (_u *AttachmentUpdateOne) SetFileMd5(v string) *AttachmentUpdateOne { + _u.mutation.SetFileMd5(v) + return _u +} + +// SetNillableFileMd5 sets the "fileMd5" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileMd5(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileMd5(*v) + } + return _u +} + +// SetMimeType sets the "mimeType" field. +func (_u *AttachmentUpdateOne) SetMimeType(v string) *AttachmentUpdateOne { + _u.mutation.SetMimeType(v) + return _u +} + +// SetNillableMimeType sets the "mimeType" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetMimeType(*v) + } + return _u +} + +// SetArchived sets the "archived" field. +func (_u *AttachmentUpdateOne) SetArchived(v bool) *AttachmentUpdateOne { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableArchived(v *bool) *AttachmentUpdateOne { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetArchivedAt sets the "archivedAt" field. +func (_u *AttachmentUpdateOne) SetArchivedAt(v int64) *AttachmentUpdateOne { + _u.mutation.ResetArchivedAt() + _u.mutation.SetArchivedAt(v) + return _u +} + +// SetNillableArchivedAt sets the "archivedAt" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableArchivedAt(v *int64) *AttachmentUpdateOne { + if v != nil { + _u.SetArchivedAt(*v) + } + return _u +} + +// AddArchivedAt adds value to the "archivedAt" field. +func (_u *AttachmentUpdateOne) AddArchivedAt(v int64) *AttachmentUpdateOne { + _u.mutation.AddArchivedAt(v) + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *AttachmentUpdateOne) SetDeleted(v bool) *AttachmentUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeleted(v *bool) *AttachmentUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetDeletedAt sets the "deletedAt" field. +func (_u *AttachmentUpdateOne) SetDeletedAt(v int64) *AttachmentUpdateOne { + _u.mutation.ResetDeletedAt() + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deletedAt" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeletedAt(v *int64) *AttachmentUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// AddDeletedAt adds value to the "deletedAt" field. +func (_u *AttachmentUpdateOne) AddDeletedAt(v int64) *AttachmentUpdateOne { + _u.mutation.AddDeletedAt(v) + return _u +} + +// SetDeletedBy sets the "deletedBy" field. +func (_u *AttachmentUpdateOne) SetDeletedBy(v string) *AttachmentUpdateOne { + _u.mutation.SetDeletedBy(v) + return _u +} + +// SetNillableDeletedBy sets the "deletedBy" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeletedBy(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetDeletedBy(*v) + } + return _u +} + // Mutation returns the AttachmentMutation object of the builder. func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation { return _u.mutation @@ -405,6 +743,31 @@ func (_u *AttachmentUpdateOne) check() error { return &ValidationError{Name: "uploader", err: fmt.Errorf(`ent: validator failed for field "Attachment.uploader": %w`, err)} } } + if v, ok := _u.mutation.FileType(); ok { + if err := attachment.FileTypeValidator(v); err != nil { + return &ValidationError{Name: "fileType", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileType": %w`, err)} + } + } + if v, ok := _u.mutation.FileExt(); ok { + if err := attachment.FileExtValidator(v); err != nil { + return &ValidationError{Name: "fileExt", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileExt": %w`, err)} + } + } + if v, ok := _u.mutation.FileMd5(); ok { + if err := attachment.FileMd5Validator(v); err != nil { + return &ValidationError{Name: "fileMd5", err: fmt.Errorf(`ent: validator failed for field "Attachment.fileMd5": %w`, err)} + } + } + if v, ok := _u.mutation.MimeType(); ok { + if err := attachment.MimeTypeValidator(v); err != nil { + return &ValidationError{Name: "mimeType", err: fmt.Errorf(`ent: validator failed for field "Attachment.mimeType": %w`, err)} + } + } + if v, ok := _u.mutation.DeletedBy(); ok { + if err := attachment.DeletedByValidator(v); err != nil { + return &ValidationError{Name: "deletedBy", err: fmt.Errorf(`ent: validator failed for field "Attachment.deletedBy": %w`, err)} + } + } return nil } @@ -464,6 +827,39 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, if value, ok := _u.mutation.Uploader(); ok { _spec.SetField(attachment.FieldUploader, field.TypeString, value) } + if value, ok := _u.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + } + if value, ok := _u.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + } + if value, ok := _u.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + } + if value, ok := _u.mutation.MimeType(); ok { + _spec.SetField(attachment.FieldMimeType, field.TypeString, value) + } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedArchivedAt(); ok { + _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDeletedAt(); ok { + _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + } _spec.AddModifiers(_u.modifiers...) _node = &Attachment{config: _u.config} _spec.Assign = _node.assignValues diff --git a/bj_power_mes/ent/migrate/schema.go b/bj_power_mes/ent/migrate/schema.go index 0f4aec0..fd090f8 100644 --- a/bj_power_mes/ent/migrate/schema.go +++ b/bj_power_mes/ent/migrate/schema.go @@ -108,6 +108,15 @@ var ( {Name: "file_size", Type: field.TypeInt, Default: 0}, {Name: "uploader", Type: field.TypeString, Size: 64, Default: ""}, {Name: "created_at", Type: field.TypeTime}, + {Name: "file_type", Type: field.TypeString, Size: 32, Default: "OTHER"}, + {Name: "file_ext", Type: field.TypeString, Size: 16, Default: ""}, + {Name: "file_md5", Type: field.TypeString, Size: 64, Default: ""}, + {Name: "mime_type", Type: field.TypeString, Size: 128, Default: ""}, + {Name: "archived", Type: field.TypeBool, Default: false}, + {Name: "archived_at", Type: field.TypeInt64, Default: 0}, + {Name: "deleted", Type: field.TypeBool, Default: false}, + {Name: "deleted_at", Type: field.TypeInt64, Default: 0}, + {Name: "deleted_by", Type: field.TypeString, Size: 64, Default: ""}, } // AttachmentTable holds the schema information for the "attachment" table. AttachmentTable = &schema.Table{ @@ -125,6 +134,16 @@ var ( Unique: false, Columns: []*schema.Column{AttachmentColumns[7]}, }, + { + Name: "attachment_file_type", + Unique: false, + Columns: []*schema.Column{AttachmentColumns[8]}, + }, + { + Name: "attachment_file_md5", + Unique: false, + Columns: []*schema.Column{AttachmentColumns[10]}, + }, }, } // WorkOrderBomColumns holds the columns for the "work_order_bom" table. @@ -566,7 +585,8 @@ var ( {Name: "name", Type: field.TypeString, Size: 50}, {Name: "code", Type: field.TypeString, Size: 20}, {Name: "category", Type: field.TypeString, Size: 30, Default: ""}, - {Name: "remark", Type: field.TypeString, Size: 255, Default: ""}, + {Name: "spec", Type: field.TypeString, Size: 128, Default: ""}, + {Name: "unit", Type: field.TypeString, Size: 32, Default: ""}, {Name: "is_active", Type: field.TypeBool, Default: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, @@ -585,7 +605,7 @@ var ( { Name: "producttype_is_active", Unique: false, - Columns: []*schema.Column{ProductTypeColumns[5]}, + Columns: []*schema.Column{ProductTypeColumns[6]}, }, }, } diff --git a/bj_power_mes/ent/mutation.go b/bj_power_mes/ent/mutation.go index 9d84881..3199e3f 100644 --- a/bj_power_mes/ent/mutation.go +++ b/bj_power_mes/ent/mutation.go @@ -2326,6 +2326,17 @@ type AttachmentMutation struct { addfileSize *int uploader *string createdAt *time.Time + fileType *string + fileExt *string + fileMd5 *string + mimeType *string + archived *bool + archivedAt *int64 + addarchivedAt *int64 + deleted *bool + deletedAt *int64 + adddeletedAt *int64 + deletedBy *string clearedFields map[string]struct{} done bool oldValue func(context.Context) (*Attachment, error) @@ -2708,6 +2719,370 @@ func (m *AttachmentMutation) ResetCreatedAt() { m.createdAt = nil } +// SetFileType sets the "fileType" field. +func (m *AttachmentMutation) SetFileType(s string) { + m.fileType = &s +} + +// FileType returns the value of the "fileType" field in the mutation. +func (m *AttachmentMutation) FileType() (r string, exists bool) { + v := m.fileType + if v == nil { + return + } + return *v, true +} + +// OldFileType returns the old "fileType" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileType: %w", err) + } + return oldValue.FileType, nil +} + +// ResetFileType resets all changes to the "fileType" field. +func (m *AttachmentMutation) ResetFileType() { + m.fileType = nil +} + +// SetFileExt sets the "fileExt" field. +func (m *AttachmentMutation) SetFileExt(s string) { + m.fileExt = &s +} + +// FileExt returns the value of the "fileExt" field in the mutation. +func (m *AttachmentMutation) FileExt() (r string, exists bool) { + v := m.fileExt + if v == nil { + return + } + return *v, true +} + +// OldFileExt returns the old "fileExt" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileExt(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileExt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileExt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileExt: %w", err) + } + return oldValue.FileExt, nil +} + +// ResetFileExt resets all changes to the "fileExt" field. +func (m *AttachmentMutation) ResetFileExt() { + m.fileExt = nil +} + +// SetFileMd5 sets the "fileMd5" field. +func (m *AttachmentMutation) SetFileMd5(s string) { + m.fileMd5 = &s +} + +// FileMd5 returns the value of the "fileMd5" field in the mutation. +func (m *AttachmentMutation) FileMd5() (r string, exists bool) { + v := m.fileMd5 + if v == nil { + return + } + return *v, true +} + +// OldFileMd5 returns the old "fileMd5" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileMd5(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileMd5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileMd5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileMd5: %w", err) + } + return oldValue.FileMd5, nil +} + +// ResetFileMd5 resets all changes to the "fileMd5" field. +func (m *AttachmentMutation) ResetFileMd5() { + m.fileMd5 = nil +} + +// SetMimeType sets the "mimeType" field. +func (m *AttachmentMutation) SetMimeType(s string) { + m.mimeType = &s +} + +// MimeType returns the value of the "mimeType" field in the mutation. +func (m *AttachmentMutation) MimeType() (r string, exists bool) { + v := m.mimeType + if v == nil { + return + } + return *v, true +} + +// OldMimeType returns the old "mimeType" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldMimeType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMimeType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMimeType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMimeType: %w", err) + } + return oldValue.MimeType, nil +} + +// ResetMimeType resets all changes to the "mimeType" field. +func (m *AttachmentMutation) ResetMimeType() { + m.mimeType = nil +} + +// SetArchived sets the "archived" field. +func (m *AttachmentMutation) SetArchived(b bool) { + m.archived = &b +} + +// Archived returns the value of the "archived" field in the mutation. +func (m *AttachmentMutation) Archived() (r bool, exists bool) { + v := m.archived + if v == nil { + return + } + return *v, true +} + +// OldArchived returns the old "archived" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldArchived(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchived is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchived requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchived: %w", err) + } + return oldValue.Archived, nil +} + +// ResetArchived resets all changes to the "archived" field. +func (m *AttachmentMutation) ResetArchived() { + m.archived = nil +} + +// SetArchivedAt sets the "archivedAt" field. +func (m *AttachmentMutation) SetArchivedAt(i int64) { + m.archivedAt = &i + m.addarchivedAt = nil +} + +// ArchivedAt returns the value of the "archivedAt" field in the mutation. +func (m *AttachmentMutation) ArchivedAt() (r int64, exists bool) { + v := m.archivedAt + if v == nil { + return + } + return *v, true +} + +// OldArchivedAt returns the old "archivedAt" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldArchivedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchivedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchivedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchivedAt: %w", err) + } + return oldValue.ArchivedAt, nil +} + +// AddArchivedAt adds i to the "archivedAt" field. +func (m *AttachmentMutation) AddArchivedAt(i int64) { + if m.addarchivedAt != nil { + *m.addarchivedAt += i + } else { + m.addarchivedAt = &i + } +} + +// AddedArchivedAt returns the value that was added to the "archivedAt" field in this mutation. +func (m *AttachmentMutation) AddedArchivedAt() (r int64, exists bool) { + v := m.addarchivedAt + if v == nil { + return + } + return *v, true +} + +// ResetArchivedAt resets all changes to the "archivedAt" field. +func (m *AttachmentMutation) ResetArchivedAt() { + m.archivedAt = nil + m.addarchivedAt = nil +} + +// SetDeleted sets the "deleted" field. +func (m *AttachmentMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *AttachmentMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *AttachmentMutation) ResetDeleted() { + m.deleted = nil +} + +// SetDeletedAt sets the "deletedAt" field. +func (m *AttachmentMutation) SetDeletedAt(i int64) { + m.deletedAt = &i + m.adddeletedAt = nil +} + +// DeletedAt returns the value of the "deletedAt" field in the mutation. +func (m *AttachmentMutation) DeletedAt() (r int64, exists bool) { + v := m.deletedAt + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deletedAt" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeletedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// AddDeletedAt adds i to the "deletedAt" field. +func (m *AttachmentMutation) AddDeletedAt(i int64) { + if m.adddeletedAt != nil { + *m.adddeletedAt += i + } else { + m.adddeletedAt = &i + } +} + +// AddedDeletedAt returns the value that was added to the "deletedAt" field in this mutation. +func (m *AttachmentMutation) AddedDeletedAt() (r int64, exists bool) { + v := m.adddeletedAt + if v == nil { + return + } + return *v, true +} + +// ResetDeletedAt resets all changes to the "deletedAt" field. +func (m *AttachmentMutation) ResetDeletedAt() { + m.deletedAt = nil + m.adddeletedAt = nil +} + +// SetDeletedBy sets the "deletedBy" field. +func (m *AttachmentMutation) SetDeletedBy(s string) { + m.deletedBy = &s +} + +// DeletedBy returns the value of the "deletedBy" field in the mutation. +func (m *AttachmentMutation) DeletedBy() (r string, exists bool) { + v := m.deletedBy + if v == nil { + return + } + return *v, true +} + +// OldDeletedBy returns the old "deletedBy" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeletedBy(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedBy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedBy: %w", err) + } + return oldValue.DeletedBy, nil +} + +// ResetDeletedBy resets all changes to the "deletedBy" field. +func (m *AttachmentMutation) ResetDeletedBy() { + m.deletedBy = nil +} + // Where appends a list predicates to the AttachmentMutation builder. func (m *AttachmentMutation) Where(ps ...predicate.Attachment) { m.predicates = append(m.predicates, ps...) @@ -2742,7 +3117,7 @@ func (m *AttachmentMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *AttachmentMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 16) if m.bizType != nil { fields = append(fields, attachment.FieldBizType) } @@ -2764,6 +3139,33 @@ func (m *AttachmentMutation) Fields() []string { if m.createdAt != nil { fields = append(fields, attachment.FieldCreatedAt) } + if m.fileType != nil { + fields = append(fields, attachment.FieldFileType) + } + if m.fileExt != nil { + fields = append(fields, attachment.FieldFileExt) + } + if m.fileMd5 != nil { + fields = append(fields, attachment.FieldFileMd5) + } + if m.mimeType != nil { + fields = append(fields, attachment.FieldMimeType) + } + if m.archived != nil { + fields = append(fields, attachment.FieldArchived) + } + if m.archivedAt != nil { + fields = append(fields, attachment.FieldArchivedAt) + } + if m.deleted != nil { + fields = append(fields, attachment.FieldDeleted) + } + if m.deletedAt != nil { + fields = append(fields, attachment.FieldDeletedAt) + } + if m.deletedBy != nil { + fields = append(fields, attachment.FieldDeletedBy) + } return fields } @@ -2786,6 +3188,24 @@ func (m *AttachmentMutation) Field(name string) (ent.Value, bool) { return m.Uploader() case attachment.FieldCreatedAt: return m.CreatedAt() + case attachment.FieldFileType: + return m.FileType() + case attachment.FieldFileExt: + return m.FileExt() + case attachment.FieldFileMd5: + return m.FileMd5() + case attachment.FieldMimeType: + return m.MimeType() + case attachment.FieldArchived: + return m.Archived() + case attachment.FieldArchivedAt: + return m.ArchivedAt() + case attachment.FieldDeleted: + return m.Deleted() + case attachment.FieldDeletedAt: + return m.DeletedAt() + case attachment.FieldDeletedBy: + return m.DeletedBy() } return nil, false } @@ -2809,6 +3229,24 @@ func (m *AttachmentMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldUploader(ctx) case attachment.FieldCreatedAt: return m.OldCreatedAt(ctx) + case attachment.FieldFileType: + return m.OldFileType(ctx) + case attachment.FieldFileExt: + return m.OldFileExt(ctx) + case attachment.FieldFileMd5: + return m.OldFileMd5(ctx) + case attachment.FieldMimeType: + return m.OldMimeType(ctx) + case attachment.FieldArchived: + return m.OldArchived(ctx) + case attachment.FieldArchivedAt: + return m.OldArchivedAt(ctx) + case attachment.FieldDeleted: + return m.OldDeleted(ctx) + case attachment.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case attachment.FieldDeletedBy: + return m.OldDeletedBy(ctx) } return nil, fmt.Errorf("unknown Attachment field %s", name) } @@ -2867,6 +3305,69 @@ func (m *AttachmentMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil + case attachment.FieldFileType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileType(v) + return nil + case attachment.FieldFileExt: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileExt(v) + return nil + case attachment.FieldFileMd5: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileMd5(v) + return nil + case attachment.FieldMimeType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMimeType(v) + return nil + case attachment.FieldArchived: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchived(v) + return nil + case attachment.FieldArchivedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchivedAt(v) + return nil + case attachment.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case attachment.FieldDeletedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case attachment.FieldDeletedBy: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedBy(v) + return nil } return fmt.Errorf("unknown Attachment field %s", name) } @@ -2878,6 +3379,12 @@ func (m *AttachmentMutation) AddedFields() []string { if m.addfileSize != nil { fields = append(fields, attachment.FieldFileSize) } + if m.addarchivedAt != nil { + fields = append(fields, attachment.FieldArchivedAt) + } + if m.adddeletedAt != nil { + fields = append(fields, attachment.FieldDeletedAt) + } return fields } @@ -2888,6 +3395,10 @@ func (m *AttachmentMutation) AddedField(name string) (ent.Value, bool) { switch name { case attachment.FieldFileSize: return m.AddedFileSize() + case attachment.FieldArchivedAt: + return m.AddedArchivedAt() + case attachment.FieldDeletedAt: + return m.AddedDeletedAt() } return nil, false } @@ -2904,6 +3415,20 @@ func (m *AttachmentMutation) AddField(name string, value ent.Value) error { } m.AddFileSize(v) return nil + case attachment.FieldArchivedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddArchivedAt(v) + return nil + case attachment.FieldDeletedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeletedAt(v) + return nil } return fmt.Errorf("unknown Attachment numeric field %s", name) } @@ -2952,6 +3477,33 @@ func (m *AttachmentMutation) ResetField(name string) error { case attachment.FieldCreatedAt: m.ResetCreatedAt() return nil + case attachment.FieldFileType: + m.ResetFileType() + return nil + case attachment.FieldFileExt: + m.ResetFileExt() + return nil + case attachment.FieldFileMd5: + m.ResetFileMd5() + return nil + case attachment.FieldMimeType: + m.ResetMimeType() + return nil + case attachment.FieldArchived: + m.ResetArchived() + return nil + case attachment.FieldArchivedAt: + m.ResetArchivedAt() + return nil + case attachment.FieldDeleted: + m.ResetDeleted() + return nil + case attachment.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case attachment.FieldDeletedBy: + m.ResetDeletedBy() + return nil } return fmt.Errorf("unknown Attachment field %s", name) } @@ -14994,7 +15546,8 @@ type ProductTypeMutation struct { name *string code *string category *string - remark *string + spec *string + unit *string isActive *bool createdAt *time.Time updatedAt *time.Time @@ -15216,40 +15769,76 @@ func (m *ProductTypeMutation) ResetCategory() { m.category = nil } -// SetRemark sets the "remark" field. -func (m *ProductTypeMutation) SetRemark(s string) { - m.remark = &s +// SetSpec sets the "spec" field. +func (m *ProductTypeMutation) SetSpec(s string) { + m.spec = &s } -// Remark returns the value of the "remark" field in the mutation. -func (m *ProductTypeMutation) Remark() (r string, exists bool) { - v := m.remark +// Spec returns the value of the "spec" field in the mutation. +func (m *ProductTypeMutation) Spec() (r string, exists bool) { + v := m.spec if v == nil { return } return *v, true } -// OldRemark returns the old "remark" field's value of the ProductType entity. +// OldSpec returns the old "spec" field's value of the ProductType entity. // If the ProductType object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProductTypeMutation) OldRemark(ctx context.Context) (v string, err error) { +func (m *ProductTypeMutation) OldSpec(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") + return v, errors.New("OldSpec is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") + return v, errors.New("OldSpec requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) + return v, fmt.Errorf("querying old value for OldSpec: %w", err) } - return oldValue.Remark, nil + return oldValue.Spec, nil } -// ResetRemark resets all changes to the "remark" field. -func (m *ProductTypeMutation) ResetRemark() { - m.remark = nil +// ResetSpec resets all changes to the "spec" field. +func (m *ProductTypeMutation) ResetSpec() { + m.spec = nil +} + +// SetUnit sets the "unit" field. +func (m *ProductTypeMutation) SetUnit(s string) { + m.unit = &s +} + +// Unit returns the value of the "unit" field in the mutation. +func (m *ProductTypeMutation) Unit() (r string, exists bool) { + v := m.unit + if v == nil { + return + } + return *v, true +} + +// OldUnit returns the old "unit" field's value of the ProductType entity. +// If the ProductType object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProductTypeMutation) OldUnit(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUnit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUnit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUnit: %w", err) + } + return oldValue.Unit, nil +} + +// ResetUnit resets all changes to the "unit" field. +func (m *ProductTypeMutation) ResetUnit() { + m.unit = nil } // SetIsActive sets the "isActive" field. @@ -15407,7 +15996,7 @@ func (m *ProductTypeMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ProductTypeMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.name != nil { fields = append(fields, producttype.FieldName) } @@ -15417,8 +16006,11 @@ func (m *ProductTypeMutation) Fields() []string { if m.category != nil { fields = append(fields, producttype.FieldCategory) } - if m.remark != nil { - fields = append(fields, producttype.FieldRemark) + if m.spec != nil { + fields = append(fields, producttype.FieldSpec) + } + if m.unit != nil { + fields = append(fields, producttype.FieldUnit) } if m.isActive != nil { fields = append(fields, producttype.FieldIsActive) @@ -15443,8 +16035,10 @@ func (m *ProductTypeMutation) Field(name string) (ent.Value, bool) { return m.Code() case producttype.FieldCategory: return m.Category() - case producttype.FieldRemark: - return m.Remark() + case producttype.FieldSpec: + return m.Spec() + case producttype.FieldUnit: + return m.Unit() case producttype.FieldIsActive: return m.IsActive() case producttype.FieldCreatedAt: @@ -15466,8 +16060,10 @@ func (m *ProductTypeMutation) OldField(ctx context.Context, name string) (ent.Va return m.OldCode(ctx) case producttype.FieldCategory: return m.OldCategory(ctx) - case producttype.FieldRemark: - return m.OldRemark(ctx) + case producttype.FieldSpec: + return m.OldSpec(ctx) + case producttype.FieldUnit: + return m.OldUnit(ctx) case producttype.FieldIsActive: return m.OldIsActive(ctx) case producttype.FieldCreatedAt: @@ -15504,12 +16100,19 @@ func (m *ProductTypeMutation) SetField(name string, value ent.Value) error { } m.SetCategory(v) return nil - case producttype.FieldRemark: + case producttype.FieldSpec: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemark(v) + m.SetSpec(v) + return nil + case producttype.FieldUnit: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUnit(v) return nil case producttype.FieldIsActive: v, ok := value.(bool) @@ -15599,8 +16202,11 @@ func (m *ProductTypeMutation) ResetField(name string) error { case producttype.FieldCategory: m.ResetCategory() return nil - case producttype.FieldRemark: - m.ResetRemark() + case producttype.FieldSpec: + m.ResetSpec() + return nil + case producttype.FieldUnit: + m.ResetUnit() return nil case producttype.FieldIsActive: m.ResetIsActive() diff --git a/bj_power_mes/ent/producttype.go b/bj_power_mes/ent/producttype.go index 033e037..2cb7791 100644 --- a/bj_power_mes/ent/producttype.go +++ b/bj_power_mes/ent/producttype.go @@ -23,8 +23,10 @@ type ProductType struct { Code string `json:"code,omitempty"` // 产品分类 Category string `json:"category,omitempty"` - // Remark holds the value of the "remark" field. - Remark string `json:"remark,omitempty"` + // 规格型号 + Spec string `json:"spec,omitempty"` + // 单位 + Unit string `json:"unit,omitempty"` // IsActive holds the value of the "isActive" field. IsActive bool `json:"isActive,omitempty"` // CreatedAt holds the value of the "createdAt" field. @@ -43,7 +45,7 @@ func (*ProductType) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case producttype.FieldID: values[i] = new(sql.NullInt64) - case producttype.FieldName, producttype.FieldCode, producttype.FieldCategory, producttype.FieldRemark: + case producttype.FieldName, producttype.FieldCode, producttype.FieldCategory, producttype.FieldSpec, producttype.FieldUnit: values[i] = new(sql.NullString) case producttype.FieldCreatedAt, producttype.FieldUpdatedAt: values[i] = new(sql.NullTime) @@ -86,11 +88,17 @@ func (_m *ProductType) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Category = value.String } - case producttype.FieldRemark: + case producttype.FieldSpec: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field remark", values[i]) + return fmt.Errorf("unexpected type %T for field spec", values[i]) } else if value.Valid { - _m.Remark = value.String + _m.Spec = value.String + } + case producttype.FieldUnit: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field unit", values[i]) + } else if value.Valid { + _m.Unit = value.String } case producttype.FieldIsActive: if value, ok := values[i].(*sql.NullBool); !ok { @@ -156,8 +164,11 @@ func (_m *ProductType) String() string { builder.WriteString("category=") builder.WriteString(_m.Category) builder.WriteString(", ") - builder.WriteString("remark=") - builder.WriteString(_m.Remark) + builder.WriteString("spec=") + builder.WriteString(_m.Spec) + builder.WriteString(", ") + builder.WriteString("unit=") + builder.WriteString(_m.Unit) builder.WriteString(", ") builder.WriteString("isActive=") builder.WriteString(fmt.Sprintf("%v", _m.IsActive)) diff --git a/bj_power_mes/ent/producttype/producttype.go b/bj_power_mes/ent/producttype/producttype.go index afc4957..1164b87 100644 --- a/bj_power_mes/ent/producttype/producttype.go +++ b/bj_power_mes/ent/producttype/producttype.go @@ -19,8 +19,10 @@ const ( FieldCode = "code" // FieldCategory holds the string denoting the category field in the database. FieldCategory = "category" - // FieldRemark holds the string denoting the remark field in the database. - FieldRemark = "remark" + // FieldSpec holds the string denoting the spec field in the database. + FieldSpec = "spec" + // FieldUnit holds the string denoting the unit field in the database. + FieldUnit = "unit" // FieldIsActive holds the string denoting the isactive field in the database. FieldIsActive = "is_active" // FieldCreatedAt holds the string denoting the createdat field in the database. @@ -37,7 +39,8 @@ var Columns = []string{ FieldName, FieldCode, FieldCategory, - FieldRemark, + FieldSpec, + FieldUnit, FieldIsActive, FieldCreatedAt, FieldUpdatedAt, @@ -62,10 +65,14 @@ var ( DefaultCategory string // CategoryValidator is a validator for the "category" field. It is called by the builders before save. CategoryValidator func(string) error - // DefaultRemark holds the default value on creation for the "remark" field. - DefaultRemark string - // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. - RemarkValidator func(string) error + // DefaultSpec holds the default value on creation for the "spec" field. + DefaultSpec string + // SpecValidator is a validator for the "spec" field. It is called by the builders before save. + SpecValidator func(string) error + // DefaultUnit holds the default value on creation for the "unit" field. + DefaultUnit string + // UnitValidator is a validator for the "unit" field. It is called by the builders before save. + UnitValidator func(string) error // DefaultIsActive holds the default value on creation for the "isActive" field. DefaultIsActive bool // DefaultCreatedAt holds the default value on creation for the "createdAt" field. @@ -101,9 +108,14 @@ func ByCategory(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCategory, opts...).ToFunc() } -// ByRemark orders the results by the remark field. -func ByRemark(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRemark, opts...).ToFunc() +// BySpec orders the results by the spec field. +func BySpec(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpec, opts...).ToFunc() +} + +// ByUnit orders the results by the unit field. +func ByUnit(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUnit, opts...).ToFunc() } // ByIsActive orders the results by the isActive field. diff --git a/bj_power_mes/ent/producttype/where.go b/bj_power_mes/ent/producttype/where.go index 332ea0e..c47bc6c 100644 --- a/bj_power_mes/ent/producttype/where.go +++ b/bj_power_mes/ent/producttype/where.go @@ -69,9 +69,14 @@ func Category(v string) predicate.ProductType { return predicate.ProductType(sql.FieldEQ(FieldCategory, v)) } -// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. -func Remark(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldEQ(FieldRemark, v)) +// Spec applies equality check predicate on the "spec" field. It's identical to SpecEQ. +func Spec(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEQ(FieldSpec, v)) +} + +// Unit applies equality check predicate on the "unit" field. It's identical to UnitEQ. +func Unit(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEQ(FieldUnit, v)) } // IsActive applies equality check predicate on the "isActive" field. It's identical to IsActiveEQ. @@ -284,69 +289,134 @@ func CategoryContainsFold(v string) predicate.ProductType { return predicate.ProductType(sql.FieldContainsFold(FieldCategory, v)) } -// RemarkEQ applies the EQ predicate on the "remark" field. -func RemarkEQ(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldEQ(FieldRemark, v)) +// SpecEQ applies the EQ predicate on the "spec" field. +func SpecEQ(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEQ(FieldSpec, v)) } -// RemarkNEQ applies the NEQ predicate on the "remark" field. -func RemarkNEQ(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldNEQ(FieldRemark, v)) +// SpecNEQ applies the NEQ predicate on the "spec" field. +func SpecNEQ(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldNEQ(FieldSpec, v)) } -// RemarkIn applies the In predicate on the "remark" field. -func RemarkIn(vs ...string) predicate.ProductType { - return predicate.ProductType(sql.FieldIn(FieldRemark, vs...)) +// SpecIn applies the In predicate on the "spec" field. +func SpecIn(vs ...string) predicate.ProductType { + return predicate.ProductType(sql.FieldIn(FieldSpec, vs...)) } -// RemarkNotIn applies the NotIn predicate on the "remark" field. -func RemarkNotIn(vs ...string) predicate.ProductType { - return predicate.ProductType(sql.FieldNotIn(FieldRemark, vs...)) +// SpecNotIn applies the NotIn predicate on the "spec" field. +func SpecNotIn(vs ...string) predicate.ProductType { + return predicate.ProductType(sql.FieldNotIn(FieldSpec, vs...)) } -// RemarkGT applies the GT predicate on the "remark" field. -func RemarkGT(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldGT(FieldRemark, v)) +// SpecGT applies the GT predicate on the "spec" field. +func SpecGT(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldGT(FieldSpec, v)) } -// RemarkGTE applies the GTE predicate on the "remark" field. -func RemarkGTE(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldGTE(FieldRemark, v)) +// SpecGTE applies the GTE predicate on the "spec" field. +func SpecGTE(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldGTE(FieldSpec, v)) } -// RemarkLT applies the LT predicate on the "remark" field. -func RemarkLT(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldLT(FieldRemark, v)) +// SpecLT applies the LT predicate on the "spec" field. +func SpecLT(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldLT(FieldSpec, v)) } -// RemarkLTE applies the LTE predicate on the "remark" field. -func RemarkLTE(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldLTE(FieldRemark, v)) +// SpecLTE applies the LTE predicate on the "spec" field. +func SpecLTE(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldLTE(FieldSpec, v)) } -// RemarkContains applies the Contains predicate on the "remark" field. -func RemarkContains(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldContains(FieldRemark, v)) +// SpecContains applies the Contains predicate on the "spec" field. +func SpecContains(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldContains(FieldSpec, v)) } -// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. -func RemarkHasPrefix(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldHasPrefix(FieldRemark, v)) +// SpecHasPrefix applies the HasPrefix predicate on the "spec" field. +func SpecHasPrefix(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldHasPrefix(FieldSpec, v)) } -// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. -func RemarkHasSuffix(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldHasSuffix(FieldRemark, v)) +// SpecHasSuffix applies the HasSuffix predicate on the "spec" field. +func SpecHasSuffix(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldHasSuffix(FieldSpec, v)) } -// RemarkEqualFold applies the EqualFold predicate on the "remark" field. -func RemarkEqualFold(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldEqualFold(FieldRemark, v)) +// SpecEqualFold applies the EqualFold predicate on the "spec" field. +func SpecEqualFold(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEqualFold(FieldSpec, v)) } -// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. -func RemarkContainsFold(v string) predicate.ProductType { - return predicate.ProductType(sql.FieldContainsFold(FieldRemark, v)) +// SpecContainsFold applies the ContainsFold predicate on the "spec" field. +func SpecContainsFold(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldContainsFold(FieldSpec, v)) +} + +// UnitEQ applies the EQ predicate on the "unit" field. +func UnitEQ(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEQ(FieldUnit, v)) +} + +// UnitNEQ applies the NEQ predicate on the "unit" field. +func UnitNEQ(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldNEQ(FieldUnit, v)) +} + +// UnitIn applies the In predicate on the "unit" field. +func UnitIn(vs ...string) predicate.ProductType { + return predicate.ProductType(sql.FieldIn(FieldUnit, vs...)) +} + +// UnitNotIn applies the NotIn predicate on the "unit" field. +func UnitNotIn(vs ...string) predicate.ProductType { + return predicate.ProductType(sql.FieldNotIn(FieldUnit, vs...)) +} + +// UnitGT applies the GT predicate on the "unit" field. +func UnitGT(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldGT(FieldUnit, v)) +} + +// UnitGTE applies the GTE predicate on the "unit" field. +func UnitGTE(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldGTE(FieldUnit, v)) +} + +// UnitLT applies the LT predicate on the "unit" field. +func UnitLT(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldLT(FieldUnit, v)) +} + +// UnitLTE applies the LTE predicate on the "unit" field. +func UnitLTE(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldLTE(FieldUnit, v)) +} + +// UnitContains applies the Contains predicate on the "unit" field. +func UnitContains(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldContains(FieldUnit, v)) +} + +// UnitHasPrefix applies the HasPrefix predicate on the "unit" field. +func UnitHasPrefix(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldHasPrefix(FieldUnit, v)) +} + +// UnitHasSuffix applies the HasSuffix predicate on the "unit" field. +func UnitHasSuffix(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldHasSuffix(FieldUnit, v)) +} + +// UnitEqualFold applies the EqualFold predicate on the "unit" field. +func UnitEqualFold(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldEqualFold(FieldUnit, v)) +} + +// UnitContainsFold applies the ContainsFold predicate on the "unit" field. +func UnitContainsFold(v string) predicate.ProductType { + return predicate.ProductType(sql.FieldContainsFold(FieldUnit, v)) } // IsActiveEQ applies the EQ predicate on the "isActive" field. diff --git a/bj_power_mes/ent/producttype_create.go b/bj_power_mes/ent/producttype_create.go index 699adb6..646adb0 100644 --- a/bj_power_mes/ent/producttype_create.go +++ b/bj_power_mes/ent/producttype_create.go @@ -46,16 +46,30 @@ func (_c *ProductTypeCreate) SetNillableCategory(v *string) *ProductTypeCreate { return _c } -// SetRemark sets the "remark" field. -func (_c *ProductTypeCreate) SetRemark(v string) *ProductTypeCreate { - _c.mutation.SetRemark(v) +// SetSpec sets the "spec" field. +func (_c *ProductTypeCreate) SetSpec(v string) *ProductTypeCreate { + _c.mutation.SetSpec(v) return _c } -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_c *ProductTypeCreate) SetNillableRemark(v *string) *ProductTypeCreate { +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_c *ProductTypeCreate) SetNillableSpec(v *string) *ProductTypeCreate { if v != nil { - _c.SetRemark(*v) + _c.SetSpec(*v) + } + return _c +} + +// SetUnit sets the "unit" field. +func (_c *ProductTypeCreate) SetUnit(v string) *ProductTypeCreate { + _c.mutation.SetUnit(v) + return _c +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_c *ProductTypeCreate) SetNillableUnit(v *string) *ProductTypeCreate { + if v != nil { + _c.SetUnit(*v) } return _c } @@ -147,9 +161,13 @@ func (_c *ProductTypeCreate) defaults() { v := producttype.DefaultCategory _c.mutation.SetCategory(v) } - if _, ok := _c.mutation.Remark(); !ok { - v := producttype.DefaultRemark - _c.mutation.SetRemark(v) + if _, ok := _c.mutation.Spec(); !ok { + v := producttype.DefaultSpec + _c.mutation.SetSpec(v) + } + if _, ok := _c.mutation.Unit(); !ok { + v := producttype.DefaultUnit + _c.mutation.SetUnit(v) } if _, ok := _c.mutation.IsActive(); !ok { v := producttype.DefaultIsActive @@ -191,12 +209,20 @@ func (_c *ProductTypeCreate) check() error { return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "ProductType.category": %w`, err)} } } - if _, ok := _c.mutation.Remark(); !ok { - return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "ProductType.remark"`)} + if _, ok := _c.mutation.Spec(); !ok { + return &ValidationError{Name: "spec", err: errors.New(`ent: missing required field "ProductType.spec"`)} } - if v, ok := _c.mutation.Remark(); ok { - if err := producttype.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductType.remark": %w`, err)} + if v, ok := _c.mutation.Spec(); ok { + if err := producttype.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "ProductType.spec": %w`, err)} + } + } + if _, ok := _c.mutation.Unit(); !ok { + return &ValidationError{Name: "unit", err: errors.New(`ent: missing required field "ProductType.unit"`)} + } + if v, ok := _c.mutation.Unit(); ok { + if err := producttype.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "ProductType.unit": %w`, err)} } } if _, ok := _c.mutation.IsActive(); !ok { @@ -254,9 +280,13 @@ func (_c *ProductTypeCreate) createSpec() (*ProductType, *sqlgraph.CreateSpec) { _spec.SetField(producttype.FieldCategory, field.TypeString, value) _node.Category = value } - if value, ok := _c.mutation.Remark(); ok { - _spec.SetField(producttype.FieldRemark, field.TypeString, value) - _node.Remark = value + if value, ok := _c.mutation.Spec(); ok { + _spec.SetField(producttype.FieldSpec, field.TypeString, value) + _node.Spec = value + } + if value, ok := _c.mutation.Unit(); ok { + _spec.SetField(producttype.FieldUnit, field.TypeString, value) + _node.Unit = value } if value, ok := _c.mutation.IsActive(); ok { _spec.SetField(producttype.FieldIsActive, field.TypeBool, value) diff --git a/bj_power_mes/ent/producttype_update.go b/bj_power_mes/ent/producttype_update.go index f366058..8ef754e 100644 --- a/bj_power_mes/ent/producttype_update.go +++ b/bj_power_mes/ent/producttype_update.go @@ -71,16 +71,30 @@ func (_u *ProductTypeUpdate) SetNillableCategory(v *string) *ProductTypeUpdate { return _u } -// SetRemark sets the "remark" field. -func (_u *ProductTypeUpdate) SetRemark(v string) *ProductTypeUpdate { - _u.mutation.SetRemark(v) +// SetSpec sets the "spec" field. +func (_u *ProductTypeUpdate) SetSpec(v string) *ProductTypeUpdate { + _u.mutation.SetSpec(v) return _u } -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_u *ProductTypeUpdate) SetNillableRemark(v *string) *ProductTypeUpdate { +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_u *ProductTypeUpdate) SetNillableSpec(v *string) *ProductTypeUpdate { if v != nil { - _u.SetRemark(*v) + _u.SetSpec(*v) + } + return _u +} + +// SetUnit sets the "unit" field. +func (_u *ProductTypeUpdate) SetUnit(v string) *ProductTypeUpdate { + _u.mutation.SetUnit(v) + return _u +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_u *ProductTypeUpdate) SetNillableUnit(v *string) *ProductTypeUpdate { + if v != nil { + _u.SetUnit(*v) } return _u } @@ -169,9 +183,14 @@ func (_u *ProductTypeUpdate) check() error { return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "ProductType.category": %w`, err)} } } - if v, ok := _u.mutation.Remark(); ok { - if err := producttype.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductType.remark": %w`, err)} + if v, ok := _u.mutation.Spec(); ok { + if err := producttype.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "ProductType.spec": %w`, err)} + } + } + if v, ok := _u.mutation.Unit(); ok { + if err := producttype.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "ProductType.unit": %w`, err)} } } return nil @@ -204,8 +223,11 @@ func (_u *ProductTypeUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.Category(); ok { _spec.SetField(producttype.FieldCategory, field.TypeString, value) } - if value, ok := _u.mutation.Remark(); ok { - _spec.SetField(producttype.FieldRemark, field.TypeString, value) + if value, ok := _u.mutation.Spec(); ok { + _spec.SetField(producttype.FieldSpec, field.TypeString, value) + } + if value, ok := _u.mutation.Unit(); ok { + _spec.SetField(producttype.FieldUnit, field.TypeString, value) } if value, ok := _u.mutation.IsActive(); ok { _spec.SetField(producttype.FieldIsActive, field.TypeBool, value) @@ -280,16 +302,30 @@ func (_u *ProductTypeUpdateOne) SetNillableCategory(v *string) *ProductTypeUpdat return _u } -// SetRemark sets the "remark" field. -func (_u *ProductTypeUpdateOne) SetRemark(v string) *ProductTypeUpdateOne { - _u.mutation.SetRemark(v) +// SetSpec sets the "spec" field. +func (_u *ProductTypeUpdateOne) SetSpec(v string) *ProductTypeUpdateOne { + _u.mutation.SetSpec(v) return _u } -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_u *ProductTypeUpdateOne) SetNillableRemark(v *string) *ProductTypeUpdateOne { +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_u *ProductTypeUpdateOne) SetNillableSpec(v *string) *ProductTypeUpdateOne { if v != nil { - _u.SetRemark(*v) + _u.SetSpec(*v) + } + return _u +} + +// SetUnit sets the "unit" field. +func (_u *ProductTypeUpdateOne) SetUnit(v string) *ProductTypeUpdateOne { + _u.mutation.SetUnit(v) + return _u +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_u *ProductTypeUpdateOne) SetNillableUnit(v *string) *ProductTypeUpdateOne { + if v != nil { + _u.SetUnit(*v) } return _u } @@ -391,9 +427,14 @@ func (_u *ProductTypeUpdateOne) check() error { return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "ProductType.category": %w`, err)} } } - if v, ok := _u.mutation.Remark(); ok { - if err := producttype.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductType.remark": %w`, err)} + if v, ok := _u.mutation.Spec(); ok { + if err := producttype.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "ProductType.spec": %w`, err)} + } + } + if v, ok := _u.mutation.Unit(); ok { + if err := producttype.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "ProductType.unit": %w`, err)} } } return nil @@ -443,8 +484,11 @@ func (_u *ProductTypeUpdateOne) sqlSave(ctx context.Context) (_node *ProductType if value, ok := _u.mutation.Category(); ok { _spec.SetField(producttype.FieldCategory, field.TypeString, value) } - if value, ok := _u.mutation.Remark(); ok { - _spec.SetField(producttype.FieldRemark, field.TypeString, value) + if value, ok := _u.mutation.Spec(); ok { + _spec.SetField(producttype.FieldSpec, field.TypeString, value) + } + if value, ok := _u.mutation.Unit(); ok { + _spec.SetField(producttype.FieldUnit, field.TypeString, value) } if value, ok := _u.mutation.IsActive(); ok { _spec.SetField(producttype.FieldIsActive, field.TypeBool, value) diff --git a/bj_power_mes/ent/runtime.go b/bj_power_mes/ent/runtime.go index 30660e8..5c80c8d 100644 --- a/bj_power_mes/ent/runtime.go +++ b/bj_power_mes/ent/runtime.go @@ -197,6 +197,52 @@ func init() { attachmentDescCreatedAt := attachmentFields[7].Descriptor() // attachment.DefaultCreatedAt holds the default value on creation for the createdAt field. attachment.DefaultCreatedAt = attachmentDescCreatedAt.Default.(func() time.Time) + // attachmentDescFileType is the schema descriptor for fileType field. + attachmentDescFileType := attachmentFields[8].Descriptor() + // attachment.DefaultFileType holds the default value on creation for the fileType field. + attachment.DefaultFileType = attachmentDescFileType.Default.(string) + // attachment.FileTypeValidator is a validator for the "fileType" field. It is called by the builders before save. + attachment.FileTypeValidator = attachmentDescFileType.Validators[0].(func(string) error) + // attachmentDescFileExt is the schema descriptor for fileExt field. + attachmentDescFileExt := attachmentFields[9].Descriptor() + // attachment.DefaultFileExt holds the default value on creation for the fileExt field. + attachment.DefaultFileExt = attachmentDescFileExt.Default.(string) + // attachment.FileExtValidator is a validator for the "fileExt" field. It is called by the builders before save. + attachment.FileExtValidator = attachmentDescFileExt.Validators[0].(func(string) error) + // attachmentDescFileMd5 is the schema descriptor for fileMd5 field. + attachmentDescFileMd5 := attachmentFields[10].Descriptor() + // attachment.DefaultFileMd5 holds the default value on creation for the fileMd5 field. + attachment.DefaultFileMd5 = attachmentDescFileMd5.Default.(string) + // attachment.FileMd5Validator is a validator for the "fileMd5" field. It is called by the builders before save. + attachment.FileMd5Validator = attachmentDescFileMd5.Validators[0].(func(string) error) + // attachmentDescMimeType is the schema descriptor for mimeType field. + attachmentDescMimeType := attachmentFields[11].Descriptor() + // attachment.DefaultMimeType holds the default value on creation for the mimeType field. + attachment.DefaultMimeType = attachmentDescMimeType.Default.(string) + // attachment.MimeTypeValidator is a validator for the "mimeType" field. It is called by the builders before save. + attachment.MimeTypeValidator = attachmentDescMimeType.Validators[0].(func(string) error) + // attachmentDescArchived is the schema descriptor for archived field. + attachmentDescArchived := attachmentFields[12].Descriptor() + // attachment.DefaultArchived holds the default value on creation for the archived field. + attachment.DefaultArchived = attachmentDescArchived.Default.(bool) + // attachmentDescArchivedAt is the schema descriptor for archivedAt field. + attachmentDescArchivedAt := attachmentFields[13].Descriptor() + // attachment.DefaultArchivedAt holds the default value on creation for the archivedAt field. + attachment.DefaultArchivedAt = attachmentDescArchivedAt.Default.(int64) + // attachmentDescDeleted is the schema descriptor for deleted field. + attachmentDescDeleted := attachmentFields[14].Descriptor() + // attachment.DefaultDeleted holds the default value on creation for the deleted field. + attachment.DefaultDeleted = attachmentDescDeleted.Default.(bool) + // attachmentDescDeletedAt is the schema descriptor for deletedAt field. + attachmentDescDeletedAt := attachmentFields[15].Descriptor() + // attachment.DefaultDeletedAt holds the default value on creation for the deletedAt field. + attachment.DefaultDeletedAt = attachmentDescDeletedAt.Default.(int64) + // attachmentDescDeletedBy is the schema descriptor for deletedBy field. + attachmentDescDeletedBy := attachmentFields[16].Descriptor() + // attachment.DefaultDeletedBy holds the default value on creation for the deletedBy field. + attachment.DefaultDeletedBy = attachmentDescDeletedBy.Default.(string) + // attachment.DeletedByValidator is a validator for the "deletedBy" field. It is called by the builders before save. + attachment.DeletedByValidator = attachmentDescDeletedBy.Validators[0].(func(string) error) // attachmentDescID is the schema descriptor for id field. attachmentDescID := attachmentFields[0].Descriptor() // attachment.IDValidator is a validator for the "id" field. It is called by the builders before save. @@ -947,22 +993,28 @@ func init() { producttype.DefaultCategory = producttypeDescCategory.Default.(string) // producttype.CategoryValidator is a validator for the "category" field. It is called by the builders before save. producttype.CategoryValidator = producttypeDescCategory.Validators[0].(func(string) error) - // producttypeDescRemark is the schema descriptor for remark field. - producttypeDescRemark := producttypeFields[4].Descriptor() - // producttype.DefaultRemark holds the default value on creation for the remark field. - producttype.DefaultRemark = producttypeDescRemark.Default.(string) - // producttype.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. - producttype.RemarkValidator = producttypeDescRemark.Validators[0].(func(string) error) + // producttypeDescSpec is the schema descriptor for spec field. + producttypeDescSpec := producttypeFields[4].Descriptor() + // producttype.DefaultSpec holds the default value on creation for the spec field. + producttype.DefaultSpec = producttypeDescSpec.Default.(string) + // producttype.SpecValidator is a validator for the "spec" field. It is called by the builders before save. + producttype.SpecValidator = producttypeDescSpec.Validators[0].(func(string) error) + // producttypeDescUnit is the schema descriptor for unit field. + producttypeDescUnit := producttypeFields[5].Descriptor() + // producttype.DefaultUnit holds the default value on creation for the unit field. + producttype.DefaultUnit = producttypeDescUnit.Default.(string) + // producttype.UnitValidator is a validator for the "unit" field. It is called by the builders before save. + producttype.UnitValidator = producttypeDescUnit.Validators[0].(func(string) error) // producttypeDescIsActive is the schema descriptor for isActive field. - producttypeDescIsActive := producttypeFields[5].Descriptor() + producttypeDescIsActive := producttypeFields[6].Descriptor() // producttype.DefaultIsActive holds the default value on creation for the isActive field. producttype.DefaultIsActive = producttypeDescIsActive.Default.(bool) // producttypeDescCreatedAt is the schema descriptor for createdAt field. - producttypeDescCreatedAt := producttypeFields[6].Descriptor() + producttypeDescCreatedAt := producttypeFields[7].Descriptor() // producttype.DefaultCreatedAt holds the default value on creation for the createdAt field. producttype.DefaultCreatedAt = producttypeDescCreatedAt.Default.(func() time.Time) // producttypeDescUpdatedAt is the schema descriptor for updatedAt field. - producttypeDescUpdatedAt := producttypeFields[7].Descriptor() + producttypeDescUpdatedAt := producttypeFields[8].Descriptor() // producttype.DefaultUpdatedAt holds the default value on creation for the updatedAt field. producttype.DefaultUpdatedAt = producttypeDescUpdatedAt.Default.(func() time.Time) // producttype.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field. diff --git a/bj_power_mes/etc/bj_power_mes-api.yaml b/bj_power_mes/etc/bj_power_mes-api.yaml index b62dff0..addb080 100644 --- a/bj_power_mes/etc/bj_power_mes-api.yaml +++ b/bj_power_mes/etc/bj_power_mes-api.yaml @@ -2,6 +2,8 @@ Name: bj_power_mes Host: 0.0.0.0 Port: 8888 Timeout: 10000 +# 请求体上限:go-zero 默认仅 1MB,会拦住照片/PDF 上传;取各文件类型上限的最大值(50MB) +MaxBytes: 52428800 # PostgreSQL(独立库 bj_power_mes) Database: @@ -54,7 +56,19 @@ Plc: Host: 127.0.0.1 Port: 102 -# 文件上传(工艺图纸 PDF / 巡检照片):Dir 相对服务启动目录,可改绝对路径;按天自动分子目录 +# 附件统一存储(与 WMS 共用同一根目录,落盘 年/月/日/文件类型/uuid.ext,库内只存相对路径) +# 生产环境改 Dir: /data/bj_power/attachments Upload: - Dir: uploads - MaxMB: 20 \ No newline at end of file + Dir: "D:/hardman/bj_power/attachments" + MaxMB: 20 # 默认单文件上限 20MB + MaxSize: + PROCESS_PDF: 52428800 # 工艺流程作业指导书 50MB + INSPECTION_PHOTO: 20971520 # 检验/巡检照片 20MB + INSPECTION_PDF: 52428800 # 检验报告 50MB + DRAWING: 52428800 # 图纸 50MB + EXCEL_IMPORT: 10485760 # Excel 导入 10MB + LocalRetentionYears: 1 # 本地保留最近 1 年 + DiskWarnPercent: 20 # 剩余空间 <20% 告警 + DiskCriticalPercent: 10 # 剩余空间 <10% 提示清理/归档 + DiskCheckHour: 7 # 每天 07:00 检测 + ArchiveDir: "" # 外部备份目录(NAS/移动硬盘),留空则归档仅标记 \ No newline at end of file diff --git a/bj_power_mes/frontend/src/help.js b/bj_power_mes/frontend/src/help.js index 35391bc..07cf799 100644 --- a/bj_power_mes/frontend/src/help.js +++ b/bj_power_mes/frontend/src/help.js @@ -7,16 +7,17 @@ export const helpProductType = { overview: '物料档案 = 本页是 WMS「基础数据(物料主数据)」中"成品"品类在本系统的视图,与 WMS 指向同一份主数据(以 WMS 为准,实时拉取、不双录)。本页承载的是"要生产哪些成品",是整条产线的源头基础数据。\n\n品类来源(与 WMS 一致):原材料=进货来的(外购);半成品、成品=自己生产的;其他=辅料/工装/试验设备等。成品还可以作为零部件,放进另一个成品的物料清单(BOM)里被再次加工成新的成品。\n\n主数据链条:物料档案(成品) → 工单(选成品+物料清单) → 物料清单(给该产品编号配料) → 日排产 → 备料单 → 库房出库 → 产线生产 → 完工成品自动回流 WMS 入库。\n\n关系说明(几对几):\n· 成品 ↔ 工单:1 对 N。一个成品可以建多个工单(同一型号今天做一批、明天做一批,工单号不同、产品编号相同)。\n· 成品 ↔ 物料清单:1 对多(选用制)。同一成品可并存多份物料清单(不同厂家供货/含半成品结构),用「物料清单名称」区分,工单建单时选定一份,备料/装机都按工单锁定的那份算。\n· 成品 ↔ 备料单:间接。备料单由「日排产 × 工单锁定的物料清单」算出,与成品无直接约束。\n· 强约束:工单/物料清单都挂在产品编号下,成品编码变了,下游关联会断,建议建好后不要改。\n· 与 WMS 的关系:两套系统解耦。物料/图号主数据以 WMS 为单一来源,MES 实时拉取(WMS 不可达时降级为本地只读缓存);成品完工后由系统自动生成 SN 回流 WMS 入库,无需人工对账。', fields: [ - { name: '名称', source: '手工填写。用户自定义,无上游来源。', purpose: '成品的中文名,用于识别与下拉展示', fill: '如:智能电表、断路器、配电柜' }, + { name: '名称', source: '手工填写(必填)。用户自定义,无上游来源。', purpose: '成品的中文名,用于识别与下拉展示', fill: '如:智能电表、断路器、配电柜' }, { name: '编码', source: '系统自动生成 + 可手动修改。新建时会自动带出(格式 PROD-YYYYMMDD-序号),你可直接使用或改为自定义编码;编辑时保留已存值。一个产品编号可对应多个工单(同一型号今天做一批、明天做一批,工单号不同,产品编号相同)。', purpose: '产品唯一编码。它是 MES 内部识别该产品的标识,决定该产品的物料清单内容,也是工单、备料、拧紧、追溯的挂靠键。', fill: '建议用有意义的编码,如 METER-01。要点:①编码主数据以 WMS(库房) 为单一来源,本系统实时从 WMS 拉取物料/成品档案;WMS 不可达时降级为本地只读缓存;②成品完工后系统自动生成 SN 并回流 WMS 入库,无需人工对账;③如产品编号就是成品编码,则直接沿用该编码即可;④建好后不要随意改,否则下游工单/追溯的关联会断。' }, + { name: '规格', source: '手工填写(必填)。与 WMS 物料档案必填口径一致。', purpose: '成品的规格型号,用于识别与打印', fill: '如:500×300×200' }, + { name: '单位', source: '手工填写(必填)。与 WMS 物料档案必填口径一致。', purpose: '计量单位', fill: '如:台 / 套' }, { name: '类别', source: '手工填写。可选,无上游来源。', purpose: '产品所属大类,便于分类统计', fill: '如:计量表 / 开关柜;可空' }, - { name: '启用', source: '开关选择。默认开启。', purpose: '启用后才允许在新建工单/备料的下拉里被选到', fill: '默认开启;暂时停产的可关闭(不删除,保留档案)' }, - { name: '备注', source: '手工填写。可选。', purpose: '补充说明', fill: '可不填' } + { name: '启用', source: '开关选择。默认开启。', purpose: '启用后才允许在新建工单/备料的下拉里被选到', fill: '默认开启;暂时停产的可关闭(不删除,保留档案)' } ] } @@ -449,3 +450,23 @@ export const helpAlertCenter = { { name: '标记已读', source: '人工在本页操作。', purpose: '处置完成后闭环该预警', fill: '核对处置后点「标记已读」' } ] } + +export const helpAttachment = { + title: '附件中心(统一存储与查阅)', + overview: + '附件中心集中登记并查阅全系统附件(图纸、检验照片、检验报告、工艺流程、流程卡、包装照片、Excel 导入等),新增在各业务页面内完成,本页负责查阅、下载、删除与归档清理。\n\n统一存储规则:所有附件按「附件根目录/年/月/日/文件类型/文件」分层存放,文件类型目录全部大写(PROCESS_PDF、INSPECTION_PHOTO、INSPECTION_PDF、DRAWING、PROCESS_CARD、PACKAGE_PHOTO、EXCEL_IMPORT、OTHER);文件名统一用 UUID,扩展名小写,不含中文与特殊字符;数据库只存相对路径(如 2026/09/19/INSPECTION_PHOTO/xxx.jpg),不存绝对路径。附件根目录由配置文件 Upload.Dir 指定,不硬编码。\n\n上传为流式写入(边写边算 MD5),同业务对象同 MD5 自动秒传不重复占空间;单文件大小按文件类型配置上限(默认 20MB)。\n\n删除为逻辑删除:库内标记「已删除」并记录删除人/时间,物理文件保留,勾选「含已删除」可追溯。\n\n归档清理:本地只保留最近「配置的年数」(默认 1 年),更早的附件可一键归档到外部备份目录并标记「已归档」,释放本地磁盘。\n\n磁盘空间监控:系统每天早上 7 点自动检测磁盘剩余空间,剩余低于 20% 告警、低于 10% 提示执行备份归档清理(本页顶部同步横幅提示,critical 时可直接点「立即归档清理」)。', + fields: [ + { name: '文件类型', source: '上传时由业务场景指定或按扩展名推断(大写枚举)。', purpose: '决定存储目录分层,也是查阅时的主要筛选维度', fill: '下拉单选八类之一,留空=全部' }, + { name: '业务类型', source: '上传时随附件记录写入(工单/物料/工艺流程/检验/入库 等)。', purpose: '区分附件挂在哪种业务单据上', fill: '下拉单选,留空=全部' }, + { name: '业务ID', source: '上传时写入的业务键(工单号/图号/SN)。', purpose: '定位某个具体单据的全部附件', fill: '支持模糊匹配,如输入工单号' }, + { name: '文件名', source: '上传时的原始文件名。', purpose: '按名称模糊查找', fill: '支持模糊匹配' }, + { name: '上传时间', source: '系统记录上传时刻。', purpose: '按时间区间缩小范围', fill: '可选起止日期,留空=不限' }, + { name: '含已删除', source: '勾选后包含逻辑删除的记录。', purpose: '追溯已删除附件', fill: '默认不勾选' }, + { name: '相对路径', source: '系统按统一规则生成(年/月/日/类型/UUID.ext)。', purpose: '直观看到物理存放位置;点击即在线预览', fill: '只读' }, + { name: '大小', source: '系统统计上传达字节数。', purpose: '评估占用空间', fill: '只读' }, + { name: '状态', source: '系统维护(有效/已归档/已删除)。', purpose: '区分当前可用的与已归档/已删除的附件', fill: '只读' }, + { name: '预览 / 下载', source: '预览走免鉴权直链(PDF/图片浏览器内联打开);下载走鉴权路由并带回中文文件名。', purpose: '查看或另存附件', fill: '点击对应按钮' }, + { name: '删除', source: '人工在本页操作(逻辑删除,需二次确认)。', purpose: '移除无效附件(保留可追溯索引)', fill: '点「删除」并确认' }, + { name: '归档清理', source: '人工在本页操作(先预览数量再确认执行)。', purpose: '把早于本地保留年数的附件移到外部备份目录并标记已归档,释放磁盘', fill: '点「归档清理」→确认' } + ] +} diff --git a/bj_power_mes/frontend/src/pages/Attachment.vue b/bj_power_mes/frontend/src/pages/Attachment.vue index 2054d46..b1f4f61 100644 --- a/bj_power_mes/frontend/src/pages/Attachment.vue +++ b/bj_power_mes/frontend/src/pages/Attachment.vue @@ -1,63 +1,202 @@ - - + + + + + 附件根目录:{{ disk.rootDir }}|剩余 {{ freePercent }}%(剩余 {{ fmtSize(disk.freeBytes) }} / 共 {{ fmtSize(disk.totalBytes) }}) + 立即归档清理 + + + + + + + + + - - - - - - + + - + + + + + + + + + + 含已删除 + + + 查询 + 重置 + 归档清理 - 查询 - - - - - {{ row.filePath || '-' }} + + + + + + + {{ fileTypeText(row.fileType) }} - - {{ fmtSize(row.fileSize) }} + + + {{ row.filePath || '-' }} + + + + {{ fmtSize(row.fileSize) }} + + + {{ bizTypeText(row.bizType) }} + + + + {{ row.uploader || '-' }} + + + {{ fmtTime(row.createdAt) }} + + + + 已删除 + 已归档 + 有效 + + + + + 预览 + 下载 + 删除 + - - - - + + + { page.current = p; load() }" + @size-change="(s) => { page.size = s; page.current = 1; load() }" /> + + + diff --git a/bj_power_mes/frontend/src/pages/ProductType.vue b/bj_power_mes/frontend/src/pages/ProductType.vue index 2e50868..275c5b9 100644 --- a/bj_power_mes/frontend/src/pages/ProductType.vue +++ b/bj_power_mes/frontend/src/pages/ProductType.vue @@ -30,8 +30,11 @@ {{ row.isActive?'是':'否' }} - - {{ row.remark || '-' }} + + {{ row.spec || '-' }} + + + {{ row.unit || '-' }} {{ row.createdAt ? fmtTime(row.createdAt) : '-' }} @@ -53,9 +56,10 @@ + + - 取消 @@ -83,7 +87,7 @@ const page = ref(1) const pageSize = ref(20) const wmsOnline = ref(true) const filters = reactive({ code: '', name: '', category: '', isActive: '', startDate: '', endDate: '' }) -const dialog = reactive({ show: false, id: 0, name: '', code: '', category: '', remark: '', isActive: true }) +const dialog = reactive({ show: false, id: 0, name: '', code: '', spec: '', unit: '', category: '', isActive: true }) function defaultRange() { const d = new Date() @@ -117,13 +121,17 @@ async function load() { function search() { page.value = 1; load() } async function openAdd() { - Object.assign(dialog, { show: true, id: 0, name: '', code: '', category: '', remark: '', isActive: true }) + Object.assign(dialog, { show: true, id: 0, name: '', code: '', spec: '', unit: '', category: '', isActive: true }) } -function openEdit(row) { Object.assign(dialog, { show: true, id: row.id, name: row.name, code: row.code, category: row.category, remark: row.remark, isActive: row.isActive }) } +function openEdit(row) { Object.assign(dialog, { show: true, id: row.id, name: row.name, code: row.code, spec: row.spec || '', unit: row.unit || '', category: row.category, isActive: row.isActive }) } async function save() { - if (!dialog.name) return ElMessage.warning('名称必填') - if (dialog.id) await request.put('/product-types', { id: dialog.id, name: dialog.name, category: dialog.category, remark: dialog.remark, isActive: dialog.isActive }) - else await request.post('/product-types', { code: dialog.code, name: dialog.name, category: dialog.category, remark: dialog.remark, isActive: dialog.isActive }) + // 必填口径与 WMS 物料档案一致(2026-09-19):除类别外均必填 + if (!trim(dialog.name)) return ElMessage.warning('名称为必填项') + if (!trim(dialog.spec)) return ElMessage.warning('规格型号为必填项') + if (!trim(dialog.unit)) return ElMessage.warning('单位为必填项') + const body = { name: trim(dialog.name), spec: trim(dialog.spec), unit: trim(dialog.unit), category: dialog.category, isActive: dialog.isActive } + if (dialog.id) await request.put('/product-types', { id: dialog.id, ...body }) + else await request.post('/product-types', { code: dialog.code, ...body }) ElMessage.success('保存成功') dialog.show = false load() diff --git a/bj_power_mes/frontend/src/pages/QualityInspection.vue b/bj_power_mes/frontend/src/pages/QualityInspection.vue index 1422e04..153a992 100644 --- a/bj_power_mes/frontend/src/pages/QualityInspection.vue +++ b/bj_power_mes/frontend/src/pages/QualityInspection.vue @@ -326,7 +326,8 @@ async function viewAttachments(row) { } async function downloadAttachment(row) { const token = getToken() - const resp = await fetch('/api/v1/attachment/download?name=' + encodeURIComponent(row.filePath), { + // 统一存储后按附件 id 下载(服务端回中文文件名 + Content-Disposition) + const resp = await fetch('/api/v1/attachment/file/' + row.id + '?dl=1', { headers: { Authorization: 'Bearer ' + token } }) if (!resp.ok) { ElMessage.error('下载失败'); return } diff --git a/bj_power_mes/go.mod b/bj_power_mes/go.mod index 53644b4..bb3fd1e 100644 --- a/bj_power_mes/go.mod +++ b/bj_power_mes/go.mod @@ -11,6 +11,7 @@ require ( github.com/zeromicro/go-zero v1.8.3 go.opentelemetry.io/otel/trace v1.24.0 golang.org/x/crypto v0.53.0 + golang.org/x/sys v0.46.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v3 v3.0.1 ) @@ -70,7 +71,6 @@ require ( golang.org/x/mod v0.36.0 // indirect golang.org/x/net v0.55.0 // indirect golang.org/x/sync v0.21.0 // indirect - golang.org/x/sys v0.46.0 // indirect golang.org/x/text v0.38.0 // indirect golang.org/x/tools v0.45.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect diff --git a/bj_power_mes/internal/config/config.go b/bj_power_mes/internal/config/config.go index 7e532e5..b17502a 100644 --- a/bj_power_mes/internal/config/config.go +++ b/bj_power_mes/internal/config/config.go @@ -56,8 +56,19 @@ type PlcConf struct { Port int `json:",default=102"` } -// UploadConf 工艺图纸 PDF / 巡检照片 等文件上传目录 +// UploadConf 附件统一存储配置。 +// Dir 即附件根目录(相对服务启动目录或绝对路径),落盘结构:Dir/年/月/日/<文件类型>/.。 type UploadConf struct { Dir string `json:",default=uploads"` - MaxMB int64 `json:",default=20"` + MaxMB int64 `json:",default=20"` // 单文件默认上限(MB) + // 按文件类型覆盖上限(字节),键为大写枚举,如 PROCESS_PDF: 52428800 + MaxSize map[string]int64 `json:",optional"` + // 本地保留年数(超过该年数的附件可归档到 ArchiveDir 后释放本地空间) + LocalRetentionYears int `json:",default=1"` + // 归档备份目录(NAS/移动硬盘等);为空时归档只标记不移动 + ArchiveDir string `json:",default="` + // 磁盘空间监控:每天 DiskCheckHour 点检测一次 + DiskWarnPercent int `json:",default=20"` // 剩余低于该百分比告警 + DiskCriticalPercent int `json:",default=10"` // 剩余低于该百分比提示清理 + DiskCheckHour int `json:",default=7"` // 每天检测时刻(0~23) } diff --git a/bj_power_mes/internal/db/db.go b/bj_power_mes/internal/db/db.go index 0465d1b..f4178d2 100644 --- a/bj_power_mes/internal/db/db.go +++ b/bj_power_mes/internal/db/db.go @@ -147,6 +147,24 @@ var schemaPatchSQL = []string{ `ALTER TABLE material_request ADD COLUMN IF NOT EXISTS batch_no varchar(64) NOT NULL DEFAULT ''`, // 日排产各工位产量分配 `ALTER TABLE daily_plan ADD COLUMN IF NOT EXISTS station_plan_qty jsonb NOT NULL DEFAULT '{}'::jsonb`, + + // ---- 物料档案「简称」删除(2026-09-19 用户裁决)---- + // 本地 product_type 仅作 WMS 不可达时的离线兜底缓存:原 remark(备注) 一并删除, + // 改存 spec/unit,与 WMS 物料档案必填口径(图号/名称/规格/单位/品类/类型)保持一致。 + `ALTER TABLE product_type ADD COLUMN IF NOT EXISTS spec varchar(128) NOT NULL DEFAULT ''`, + `ALTER TABLE product_type ADD COLUMN IF NOT EXISTS unit varchar(32) NOT NULL DEFAULT ''`, + `ALTER TABLE product_type DROP COLUMN IF EXISTS remark`, + + // ---- 附件统一存储方案(2026-09-19):年/月/日/文件类型/uuid.ext ---- + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS file_type varchar(32) NOT NULL DEFAULT 'OTHER'`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS file_ext varchar(16) NOT NULL DEFAULT ''`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS file_md5 varchar(64) NOT NULL DEFAULT ''`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS mime_type varchar(128) NOT NULL DEFAULT ''`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS archived boolean NOT NULL DEFAULT false`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS archived_at bigint NOT NULL DEFAULT 0`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS deleted boolean NOT NULL DEFAULT false`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS deleted_at bigint NOT NULL DEFAULT 0`, + `ALTER TABLE attachment ADD COLUMN IF NOT EXISTS deleted_by varchar(64) NOT NULL DEFAULT ''`, } // EnsureSchema ent 建表 + 幂等列补丁(只增,不删数据) diff --git a/bj_power_mes/internal/handler/attachment.go b/bj_power_mes/internal/handler/attachment.go index 9e4028d..837b002 100644 --- a/bj_power_mes/internal/handler/attachment.go +++ b/bj_power_mes/internal/handler/attachment.go @@ -1,43 +1,123 @@ package handler import ( + "fmt" "net/http" + "net/url" "os" "path/filepath" + "strconv" + "strings" + "time" "bj_power_mes/common/httpx" + "bj_power_mes/ent" "bj_power_mes/internal/logic" "bj_power_mes/internal/svc" + + "github.com/zeromicro/go-zero/rest/pathvar" ) -// AttachmentUploadHandler POST /attachment/upload 上传并登记(multipart: bizType,bizId,file) +// ---------- 附件(统一存储方案) ---------- +// +// 落盘:/年/月/日/<文件类型大写枚举>/. +// 库内:filePath 只存相对路径;下载/预览按 id 提供,避免中文与多级路径问题。 + +// attachmentRow 附件返回视图(前端友好:附可直接预览/下载的 URL)。 +type attachmentRow struct { + ID int `json:"id"` + BizType string `json:"bizType"` + BizID string `json:"bizId"` + FileType string `json:"fileType"` + FileName string `json:"fileName"` + FilePath string `json:"filePath"` + FileSize int `json:"fileSize"` + FileExt string `json:"fileExt"` + MimeType string `json:"mimeType"` + Uploader string `json:"uploader"` + Archived bool `json:"archived"` + Deleted bool `json:"deleted"` + DeletedBy string `json:"deletedBy"` + CreatedAt int64 `json:"createdAt"` + URL string `json:"url"` + PreviewURL string `json:"previewUrl"` +} + +func toAttachmentRow(a *ent.Attachment) *attachmentRow { + // 预览走公开直链(文件名不可枚举:UUID + 日期目录),/ 无法携带 JWT; + // 下载走带鉴权的 id 路由,由服务端给出 RFC5987 中文文件名与 Content-Disposition。 + return &attachmentRow{ + ID: a.ID, BizType: a.BizType, BizID: a.BizId, FileType: a.FileType, + FileName: a.FileName, FilePath: a.FilePath, FileSize: a.FileSize, + FileExt: a.FileExt, MimeType: a.MimeType, Uploader: a.Uploader, + Archived: a.Archived, Deleted: a.Deleted, DeletedBy: a.DeletedBy, + CreatedAt: a.CreatedAt.Unix(), + URL: "/api/v1/attachment/file/" + strconv.Itoa(a.ID) + "?dl=1", + PreviewURL: previewURL(a.FilePath), + } +} + +// previewURL 相对路径 → 公开免鉴权直链(复用 /files 路由,天然支持多级目录)。 +func previewURL(relPath string) string { + if relPath == "" { + return "" + } + return fileURL(relPath) +} + +// AttachmentUploadHandler POST /attachment/upload +// multipart 字段:bizType(必填)、bizId(必填)、file(必填)、fileType(可选,大写枚举) +// 流式落盘 + MD5 秒传(同业务对象同 MD5 直接返回既有记录,不重复存文件)。 func AttachmentUploadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if err := r.ParseMultipartForm(32 << 20); err != nil { - httpx.BadRequest(w, "表单解析失败") + if err := r.ParseMultipartForm(4 << 20); err != nil && err != http.ErrNotMultipart { + httpx.BadRequest(w, "表单解析失败:"+err.Error()) return } - bizType := r.FormValue("bizType") - bizId := r.FormValue("bizId") + bizType := strings.TrimSpace(r.FormValue("bizType")) + bizId := strings.TrimSpace(r.FormValue("bizId")) if bizType == "" || bizId == "" { httpx.BadRequest(w, "bizType 与 bizId 必填") return } - rel, fname, size, err := saveUploadFileFull(r, "file", svcCtx.Config.Upload.Dir) - if err != nil { - httpx.Fail(w, 3311, "文件保存失败:"+err.Error()) - return + fileType := strings.ToUpper(strings.TrimSpace(r.FormValue("fileType"))) + dir := svcCtx.Config.Upload.Dir + + // 先解析扩展名推断文件类型,再取对应大小上限 + if fileType == "" || !validFileTypes[fileType] { + // 由 saveTypedUpload 内部按扩展名推断(此处先给空值) + fileType = "" } - rec, err := logic.New(svcCtx).AddAttachment(r.Context(), bizType, bizId, fname, rel, int(size), operator(r, "")) + maxBytes := uploadMaxBytes(svcCtx.Config.Upload.MaxSize, svcCtx.Config.Upload.MaxMB, fileType) + res, err := saveTypedUpload(r, "file", dir, bizType, fileType, maxBytes) if err != nil { httpx.Fail(w, 3311, err.Error()) return } - httpx.Ok(w, rec) + + // MD5 秒传:同业务对象 + 同 MD5 已存在 → 直接返回既有记录(删除刚落盘文件) + if exist, e := logic.New(svcCtx).FindByMD5(r.Context(), bizType, bizId, res.MD5); e == nil && exist != nil { + if abs, ok := safeAbsPath(dir, res.RelPath); ok { + _ = os.Remove(abs) + } + httpx.Ok(w, toAttachmentRow(exist)) + return + } + + uploader := operator(r, "") + rec, err := logic.New(svcCtx).AddAttachment(r.Context(), bizType, bizId, + res.RelPath2FileType(), res.FileName, res.RelPath, res.Ext, res.MD5, res.MimeType, int(res.Size), uploader) + if err != nil { + httpx.Fail(w, 3311, "附件登记失败:"+err.Error()) + return + } + svcCtx.EventLog.Write(r.Context(), "attachment.upload", "", uploader, "attachment", bizId, + "上传附件 "+res.FileName, map[string]any{"bizType": bizType, "fileType": res.RelPath2FileType(), "size": res.Size}) + httpx.Ok(w, toAttachmentRow(rec)) } } -// AttachmentListHandler GET /attachments?bizType=&bizId= 附件列表 +// AttachmentListHandler GET /attachments?bizType=&bizId= 某业务对象的附件列表 func AttachmentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { q := r.URL.Query() @@ -46,39 +126,202 @@ func AttachmentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.Fail(w, 3312, err.Error()) return } - httpx.Ok(w, data) + rows := make([]*attachmentRow, 0, len(data)) + for _, a := range data { + rows = append(rows, toAttachmentRow(a)) + } + httpx.Ok(w, map[string]any{"list": rows, "total": len(rows)}) } } -// AttachmentDownloadHandler GET /attachment/download?name= 下载 -func AttachmentDownloadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { +// AttachmentCenterHandler GET /attachment/all 附件中心(全量分页 + 磁盘状态) +// 参数:fileType / bizType / bizId / fileName / startDate / endDate / includeDeleted / page / pageSize +func AttachmentCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - name := r.URL.Query().Get("name") - if name == "" { - httpx.BadRequest(w, "缺少 name") + q := r.URL.Query() + page := atoiDefault(q.Get("page"), 1) + pageSize := atoiDefault(q.Get("pageSize"), 20) + if page < 1 { + page = 1 + } + if pageSize < 1 || pageSize > 200 { + pageSize = 20 + } + var start, end time.Time + if v := strings.TrimSpace(q.Get("startDate")); v != "" { + if t, err := time.ParseInLocation("2006-01-02", v, time.Local); err == nil { + start = t + } + } + if v := strings.TrimSpace(q.Get("endDate")); v != "" { + if t, err := time.ParseInLocation("2006-01-02", v, time.Local); err == nil { + end = t.Add(24*time.Hour - time.Second) + } + } + total, list, err := logic.New(svcCtx).ListAttachmentPage(r.Context(), + strings.ToUpper(strings.TrimSpace(q.Get("fileType"))), strings.TrimSpace(q.Get("bizType")), + strings.TrimSpace(q.Get("bizId")), strings.TrimSpace(q.Get("fileName")), + start, end, q.Get("includeDeleted") == "true", page, pageSize) + if err != nil { + httpx.Fail(w, 3312, err.Error()) return } - serveUploadFile(w, r, svcCtx.Config.Upload.Dir, name) + rows := make([]*attachmentRow, 0, len(list)) + for _, a := range list { + rows = append(rows, toAttachmentRow(a)) + } + httpx.Ok(w, map[string]any{ + "total": total, "list": rows, "page": page, "pageSize": pageSize, + "disk": diskStatus(svcCtx), + }) } } -// AttachmentDeleteHandler POST /attachment/delete {id} 删除(记录+物理文件) +// AttachmentFileHandler GET /attachment/file/:id 下载/预览(支持 Range 断点续传;?dl=1 强制下载) +func AttachmentFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := atoiDefault(pathvar.Vars(r)["id"], 0) + if id <= 0 { + httpx.BadRequest(w, "id 非法") + return + } + rec, err := logic.New(svcCtx).GetAttachment(r.Context(), id) + if err != nil { + http.NotFound(w, r) + return + } + abs, ok := safeAbsPath(svcCtx.Config.Upload.Dir, rec.FilePath) + if !ok { + http.NotFound(w, r) + return + } + if _, err := os.Stat(abs); err != nil { + http.NotFound(w, r) + return + } + // 中文文件名走 RFC 5987;下载(dl=1)才强制 attachment,否则内联预览 + disp := "inline" + if r.URL.Query().Get("dl") == "1" { + disp = "attachment" + } + w.Header().Set("Content-Disposition", fmt.Sprintf(`%s; filename*=UTF-8''%s`, disp, url.QueryEscape(rec.FileName))) + http.ServeFile(w, r, abs) // ServeFile 自带 Range 支持 + } +} + +// AttachmentDeleteHandler POST /attachment/delete {id} 逻辑删除(库内标记,物理文件交由归档任务处理) func AttachmentDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req struct { Id int `json:"id"` } - if err := httpx.ParseJSON(r, &req); err != nil { - httpx.BadRequest(w, "请求体解析失败") + if err := httpx.ParseJSON(r, &req); err != nil || req.Id <= 0 { + httpx.BadRequest(w, "参数错误:id 必填") return } - att, err := logic.New(svcCtx).DeleteAttachment(r.Context(), req.Id) + att, err := logic.New(svcCtx).DeleteAttachment(r.Context(), req.Id, operator(r, "")) if err != nil { - httpx.Fail(w, 3313, err.Error()) + httpx.Fail(w, 3313, "删除附件失败:"+err.Error()) return } - full := filepath.Join(svcCtx.Config.Upload.Dir, filepath.FromSlash(att.FilePath)) - _ = os.Remove(full) + svcCtx.EventLog.Write(r.Context(), "attachment.delete", "", operator(r, ""), "attachment", att.BizId, + "删除附件 "+att.FileName, nil) httpx.OkMessage(w, "删除成功", nil) } } + +// AttachmentDiskStatusHandler GET /attachment/disk-status 磁盘剩余空间状态 +func AttachmentDiskStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + httpx.Ok(w, diskStatus(svcCtx)) + } +} + +// AttachmentArchiveHandler POST /attachment/archive {dryRun} 归档 +// 把「早于本地保留年数」的附件移动到 ArchiveDir 并标记 archived=true(保留索引可追溯)。 +// ArchiveDir 为空时只标记不移动;dryRun=true 时仅返回将被归档的数量。 +func AttachmentArchiveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req struct { + DryRun bool `json:"dryRun"` + } + _ = httpx.ParseJSON(r, &req) + cfg := svcCtx.Config.Upload + years := cfg.LocalRetentionYears + if years <= 0 { + years = 1 + } + cutYear := time.Now().Year() - years // 早于该年份的附件可归档 + svc := logic.New(svcCtx) + recs, err := svc.ListArchivableAttachments(r.Context()) + if err != nil { + httpx.Fail(w, 3314, err.Error()) + return + } + moved, marked, failed := 0, 0, 0 + for _, rec := range recs { + if rec.CreatedAt.Year() > cutYear-1 { + continue + } + if req.DryRun { + marked++ + continue + } + if cfg.ArchiveDir != "" { + src, ok1 := safeAbsPath(cfg.Dir, rec.FilePath) + dst, ok2 := safeAbsPath(cfg.ArchiveDir, rec.FilePath) + if !ok1 || !ok2 { + failed++ + continue + } + if err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil { + failed++ + continue + } + if err := os.Rename(src, dst); err != nil { + if err2 := copyFile(src, dst); err2 != nil { + failed++ + continue + } + _ = os.Remove(src) + } + moved++ + } + if err := svc.MarkArchived(r.Context(), rec.ID); err != nil { + failed++ + continue + } + marked++ + } + if !req.DryRun { + svcCtx.EventLog.Write(r.Context(), "attachment.archive", "", operator(r, ""), "attachment", "archive", + fmt.Sprintf("附件归档:移动%d 标记%d 失败%d(早于 %d 年)", moved, marked, failed, cutYear), + map[string]any{"moved": moved, "marked": marked, "failed": failed}) + } + httpx.Ok(w, map[string]any{ + "moved": moved, "marked": marked, "failed": failed, + "cutYear": cutYear, "archiveDir": cfg.ArchiveDir, "dryRun": req.DryRun, + }) + } +} + +// copyFile 兜底复制(跨盘符 Rename 失败时用)。 +func copyFile(src, dst string) error { + in, err := os.Open(src) + if err != nil { + return err + } + defer in.Close() + if err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil { + return err + } + out, err := os.Create(dst) + if err != nil { + return err + } + if _, err := out.ReadFrom(in); err != nil { + _ = out.Close() + return err + } + return out.Close() +} diff --git a/bj_power_mes/internal/handler/attachment_monitor.go b/bj_power_mes/internal/handler/attachment_monitor.go new file mode 100644 index 0000000..fc9deb5 --- /dev/null +++ b/bj_power_mes/internal/handler/attachment_monitor.go @@ -0,0 +1,105 @@ +package handler + +import ( + "context" + "fmt" + "net/http" + "os" + "time" + + "bj_power_mes/common/httpx" + "bj_power_mes/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +// diskStatusView 磁盘空间状态视图(附件中心顶部提示 + 定时告警共用)。 +type diskStatusView struct { + RootDir string `json:"rootDir"` + UsedPercent int `json:"usedPercent"` + FreeBytes uint64 `json:"freeBytes"` + TotalBytes uint64 `json:"totalBytes"` + WarnPercent int `json:"warnPercent"` + CritPercent int `json:"critPercent"` + Level string `json:"level"` // ok / warn / critical / unknown + Message string `json:"message"` + CheckedAt int64 `json:"checkedAt"` +} + +// diskStatus 读取附件根目录所在磁盘剩余空间并给出告警级别。 +// 剩余 < DiskCriticalPercent → critical(提示执行备份归档清理);< DiskWarnPercent → warn。 +func diskStatus(svcCtx *svc.ServiceContext) diskStatusView { + cfg := svcCtx.Config.Upload + root := cfg.Dir + if root == "" { + root = "uploads" + } + v := diskStatusView{ + RootDir: root, WarnPercent: cfg.DiskWarnPercent, CritPercent: cfg.DiskCriticalPercent, + Level: "ok", Message: "磁盘空间正常", CheckedAt: time.Now().Unix(), + } + used, free, total, err := diskUsage(root) + if err != nil { + _ = os.MkdirAll(root, 0o755) + used, free, total, err = diskUsage(root) + } + if err != nil { + v.Level = "unknown" + v.Message = "磁盘空间检测失败:" + err.Error() + return v + } + v.UsedPercent, v.FreeBytes, v.TotalBytes = used, free, total + freePercent := 100 - used + switch { + case freePercent < cfg.DiskCriticalPercent: + v.Level = "critical" + v.Message = fmt.Sprintf("磁盘剩余空间仅 %d%%,低于 %d%%,请立即执行备份归档清理(附件中心可一键归档)", freePercent, cfg.DiskCriticalPercent) + case freePercent < cfg.DiskWarnPercent: + v.Level = "warn" + v.Message = fmt.Sprintf("磁盘剩余空间 %d%%,低于 %d%% 告警线,请及时清理", freePercent, cfg.DiskWarnPercent) + } + return v +} + +// DiskStatusHandler GET /attachment/disk-status +func DiskStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + httpx.Ok(w, diskStatus(svcCtx)) + } +} + +// StartDiskMonitor 启动磁盘空间监控:每天 DiskCheckHour(默认 7 点) 检测一次, +// 剩余 <20% 告警、<10% 提示清理(写服务日志 + 操作日志,附件中心顶部同步展示)。 +func StartDiskMonitor(svcCtx *svc.ServiceContext) { + go func() { + hour := svcCtx.Config.Upload.DiskCheckHour + if hour < 0 || hour > 23 { + hour = 7 + } + for { + now := time.Now() + next := time.Date(now.Year(), now.Month(), now.Day(), hour, 0, 0, 0, time.Local) + if !next.After(now) { + next = next.Add(24 * time.Hour) + } + time.Sleep(time.Until(next)) + checkDiskOnce(svcCtx) + } + }() +} + +func checkDiskOnce(svcCtx *svc.ServiceContext) { + st := diskStatus(svcCtx) + switch st.Level { + case "critical": + logx.Errorf("[磁盘监控] %s(已用 %d%%,剩余 %d%%)", st.Message, st.UsedPercent, 100-st.UsedPercent) + svcCtx.EventLog.Write(context.Background(), "system.disk", "", "system", "attachment", "disk", st.Message, + map[string]any{"usedPercent": st.UsedPercent, "freeBytes": st.FreeBytes}) + case "warn": + logx.Alert("[磁盘监控] " + st.Message) + svcCtx.EventLog.Write(context.Background(), "system.disk", "", "system", "attachment", "disk", st.Message, + map[string]any{"usedPercent": st.UsedPercent, "freeBytes": st.FreeBytes}) + default: + logx.Infof("[磁盘监控] 正常:剩余 %d%%(%s)", 100-st.UsedPercent, st.RootDir) + } +} diff --git a/bj_power_mes/internal/handler/disk_space_unix.go b/bj_power_mes/internal/handler/disk_space_unix.go new file mode 100644 index 0000000..396eba5 --- /dev/null +++ b/bj_power_mes/internal/handler/disk_space_unix.go @@ -0,0 +1,19 @@ +//go:build !windows + +package handler + +import "golang.org/x/sys/unix" + +// diskUsage 返回指定目录所在磁盘的已用百分比(0-100)、可用字节、总字节。 +func diskUsage(path string) (usedPercent int, freeBytes, totalBytes uint64, err error) { + var st unix.Statfs_t + if err := unix.Statfs(path, &st); err != nil { + return 0, 0, 0, err + } + total := st.Blocks * uint64(st.Bsize) + free := st.Bavail * uint64(st.Bsize) + if total == 0 { + return 0, free, total, nil + } + return int((total - free) * 100 / total), free, total, nil +} diff --git a/bj_power_mes/internal/handler/disk_space_windows.go b/bj_power_mes/internal/handler/disk_space_windows.go new file mode 100644 index 0000000..6c215b1 --- /dev/null +++ b/bj_power_mes/internal/handler/disk_space_windows.go @@ -0,0 +1,22 @@ +//go:build windows + +package handler + +import "golang.org/x/sys/windows" + +// diskUsage 返回指定目录所在磁盘的已用百分比(0-100)、可用字节、总字节。 +func diskUsage(path string) (usedPercent int, freeBytes, totalBytes uint64, err error) { + p, e := windows.UTF16PtrFromString(path) + if e != nil { + return 0, 0, 0, e + } + var freeAvail, total, totalFree uint64 + if e := windows.GetDiskFreeSpaceEx(p, &freeAvail, &total, &totalFree); e != nil { + return 0, 0, 0, e + } + if total == 0 { + return 0, totalFree, total, nil + } + used := total - totalFree + return int(used * 100 / total), totalFree, total, nil +} diff --git a/bj_power_mes/internal/handler/inspection.go b/bj_power_mes/internal/handler/inspection.go index fe96258..beaf9ed 100644 --- a/bj_power_mes/internal/handler/inspection.go +++ b/bj_power_mes/internal/handler/inspection.go @@ -71,19 +71,21 @@ func ListInspectionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } } -// UploadPhotoHandler POST /inspections/upload(巡检拍照上传,返回文件名) +// UploadPhotoHandler POST /inspections/upload(巡检/异常拍照上传) +// 统一存储:/年/月/日/INSPECTION_PHOTO/.;返回相对路径 + 免鉴权直链。 func UploadPhotoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if err := r.ParseMultipartForm(svcCtx.Config.Upload.MaxMB << 20); err != nil { httpx.BadRequest(w, "上传文件过大或格式错误") return } - name, err := saveUploadFile(r, "file", svcCtx.Config.Upload.Dir) + res, err := saveTypedUpload(r, "file", svcCtx.Config.Upload.Dir, "inspection", FileTypeInspectionPhoto, + uploadMaxBytes(svcCtx.Config.Upload.MaxSize, svcCtx.Config.Upload.MaxMB, FileTypeInspectionPhoto)) if err != nil { httpx.Fail(w, 2303, "照片保存失败:"+err.Error()) return } - httpx.Ok(w, map[string]any{"filename": name, "url": "/api/v1/files/" + name}) + httpx.Ok(w, map[string]any{"filename": res.RelPath, "url": "/api/v1/files/" + res.RelPath}) } } diff --git a/bj_power_mes/internal/handler/processflow.go b/bj_power_mes/internal/handler/processflow.go index b127b23..40387b4 100644 --- a/bj_power_mes/internal/handler/processflow.go +++ b/bj_power_mes/internal/handler/processflow.go @@ -59,12 +59,13 @@ func UploadPdfHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.BadRequest(w, "上传文件过大或格式错误") return } - name, err := saveUploadFile(r, "file", svcCtx.Config.Upload.Dir) + res, err := saveTypedUpload(r, "file", svcCtx.Config.Upload.Dir, "process_flow", FileTypeProcessPDF, + uploadMaxBytes(svcCtx.Config.Upload.MaxSize, svcCtx.Config.Upload.MaxMB, FileTypeProcessPDF)) if err != nil { httpx.Fail(w, 2204, "文件保存失败:"+err.Error()) return } - httpx.Ok(w, map[string]any{"filename": name, "url": "/api/v1/files/" + name}) + httpx.Ok(w, map[string]any{"filename": res.RelPath, "url": "/api/v1/files/" + res.RelPath}) } } @@ -84,6 +85,16 @@ func FilePathHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } } +// FileDeepPathHandler GET /files/:y/:m/:d/:t/:f —— 统一存储格式的路径式 URL +// (年/月/日/文件类型/uuid.ext)。go-zero 路由不支持多段通配,故按固定 5 段显式声明。 +func FileDeepPathHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := pathvar.Vars(r) + rel := vars["y"] + "/" + vars["m"] + "/" + vars["d"] + "/" + vars["t"] + "/" + vars["f"] + serveUploadFile(w, r, svcCtx.Config.Upload.Dir, rel) + } +} + // ListStationsHandler GET /stations func ListStationsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { diff --git a/bj_power_mes/internal/handler/routes_production.go b/bj_power_mes/internal/handler/routes_production.go index 082013b..8fadc00 100644 --- a/bj_power_mes/internal/handler/routes_production.go +++ b/bj_power_mes/internal/handler/routes_production.go @@ -212,10 +212,13 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext {Method: http.MethodGet, Path: "/alerts", Handler: production.ListAlertsHandler(serverCtx)}, {Method: http.MethodPost, Path: "/alert/read", Handler: production.MarkAlertReadHandler(serverCtx)}, - // ---------- 附件中心(M10) ---------- + // ---------- 附件中心(统一存储方案 2026-09-19) ---------- {Method: http.MethodPost, Path: "/attachment/upload", Handler: AttachmentUploadHandler(serverCtx)}, {Method: http.MethodGet, Path: "/attachments", Handler: AttachmentListHandler(serverCtx)}, - {Method: http.MethodGet, Path: "/attachment/download", Handler: AttachmentDownloadHandler(serverCtx)}, + {Method: http.MethodGet, Path: "/attachment/all", Handler: AttachmentCenterHandler(serverCtx)}, + {Method: http.MethodGet, Path: "/attachment/file/:id", Handler: AttachmentFileHandler(serverCtx)}, + {Method: http.MethodGet, Path: "/attachment/disk-status", Handler: DiskStatusHandler(serverCtx)}, + {Method: http.MethodPost, Path: "/attachment/archive", Handler: AttachmentArchiveHandler(serverCtx)}, {Method: http.MethodPost, Path: "/attachment/delete", Handler: AttachmentDeleteHandler(serverCtx)}, // ---------- 工艺流程/工位(块3) ---------- @@ -266,8 +269,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext rest.WithMiddlewares([]rest.Middleware{permissionGuard(serverCtx)}, jwtRoutes...), rest.WithPrefix("/api/v1"), rest.WithJwt(serverCtx.Config.Auth.AccessSecret), - // 请求体上限跟随 Upload.MaxMB(默认20MB),否则 go-zero 默认 1MB 会 413(PDF/照片上传在此分组) - rest.WithMaxBytes(serverCtx.Config.Upload.MaxMB<<20), + // 请求体上限取「Upload.MaxMB 与各文件类型 MaxSize 的最大值」,否则 go-zero 默认 1MB 会 413 + // (PDF/照片上传在此分组;大写枚举若配了 50MB,此处必须放宽到 50MB 才不会被网关先拦) + rest.WithMaxBytes(maxUploadBytes(serverCtx.Config.Upload.MaxMB, serverCtx.Config.Upload.MaxSize)), ) // ---------- 公开文件访问(免 JWT) ---------- diff --git a/bj_power_mes/internal/handler/upload.go b/bj_power_mes/internal/handler/upload.go index 5130068..31aa861 100644 --- a/bj_power_mes/internal/handler/upload.go +++ b/bj_power_mes/internal/handler/upload.go @@ -1,69 +1,251 @@ package handler import ( + "crypto/md5" "crypto/rand" "encoding/hex" + "fmt" "io" "net/http" + "net/url" "os" "path/filepath" "strings" "time" ) -// saveUploadFile 保存上传文件(工艺图纸PDF / 巡检照片),返回生成的相对文件名(含日期子目录) -func saveUploadFile(r *http.Request, field, dir string) (string, error) { - sub := time.Now().Format("2006-01-02") - full := filepath.Join(dir, sub) - if err := os.MkdirAll(full, 0o755); err != nil { - return "", err +// ---------------- 附件统一存储方案(2026-09-19) ---------------- +// +// 目录结构:/年/月/日/<文件类型>/. +// - 年月日按当前日期自动生成(月/日补零) +// - 业务类型目录全部大写(见下方枚举) +// - 文件名统一 UUID,扩展名小写,不含中文/空格/特殊字符 +// - 数据库只存相对路径(如 2026/09/19/PROCESS_PDF/xxx.pdf),不存绝对路径 +// - 根目录从 etc/*.yaml 的 Upload.Dir 读取,不硬编码 + +// 文件类型枚举(全部大写) +const ( + FileTypeProcessPDF = "PROCESS_PDF" // 工艺流程作业指导书 + FileTypeInspectionPhoto = "INSPECTION_PHOTO" // 检验/巡检照片 + FileTypeInspectionPDF = "INSPECTION_PDF" // 检验报告 + FileTypeDrawing = "DRAWING" // 图纸 + FileTypeProcessCard = "PROCESS_CARD" // 流程卡 + FileTypePackagePhoto = "PACKAGE_PHOTO" // 包装照片 + FileTypeExcelImport = "EXCEL_IMPORT" // Excel 导入 + FileTypeOther = "OTHER" // 其他 +) + +var validFileTypes = map[string]bool{ + FileTypeProcessPDF: true, FileTypeInspectionPhoto: true, FileTypeInspectionPDF: true, + FileTypeDrawing: true, FileTypeProcessCard: true, FileTypePackagePhoto: true, + FileTypeExcelImport: true, FileTypeOther: true, +} + +// allowedExt 允许的扩展名白名单(图纸/报告/图片/表格/压缩包)。白名单而非黑名单,避免上传可执行文件。 +var allowedExt = map[string]bool{ + ".pdf": true, ".png": true, ".jpg": true, ".jpeg": true, ".gif": true, + ".xlsx": true, ".xls": true, ".doc": true, ".docx": true, + ".dwg": true, ".dxf": true, ".zip": true, ".txt": true, ".csv": true, +} + +// deriveFileType 未显式指定文件类型时,按业务类型 + 扩展名推断,兜底 OTHER。 +func deriveFileType(bizType, ext string) string { + ext = strings.ToLower(ext) + switch { + case ext == ".xlsx" || ext == ".xls" || ext == ".csv": + return FileTypeExcelImport + case bizType == "inspection": + if ext == ".pdf" { + return FileTypeInspectionPDF + } + if ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif" { + return FileTypeInspectionPhoto + } + case bizType == "material" && (ext == ".pdf" || ext == ".dwg" || ext == ".dxf"): + return FileTypeDrawing + case bizType == "work_order": + if ext == ".pdf" { + return FileTypeProcessCard + } + case bizType == "process_flow" && ext == ".pdf": + return FileTypeProcessPDF } + return FileTypeOther +} + +// buildRelDir 相对目录 年/月/日/文件类型(月/日补零)。 +func buildRelDir(fileType string, t time.Time) string { + return fmt.Sprintf("%d/%02d/%02d/%s", t.Year(), int(t.Month()), t.Day(), fileType) +} + +// safeAbsPath 把库内相对路径安全解析为根目录内的绝对路径(阻断 ../ 穿越)。 +func safeAbsPath(root, rel string) (string, bool) { + rel = strings.ReplaceAll(rel, "\\", "/") + clean := filepath.Clean(filepath.Join(root, rel)) + rootAbs, err := filepath.Abs(root) + if err != nil { + return "", false + } + abs, err := filepath.Abs(clean) + if err != nil { + return "", false + } + if abs != rootAbs && !strings.HasPrefix(abs, rootAbs+string(os.PathSeparator)) { + return "", false + } + return abs, true +} + +// newUUID 生成 RFC4122 v4 UUID(crypto/rand,不引第三方依赖)。 +func newUUID() string { + b := make([]byte, 16) + _, _ = rand.Read(b) + b[6] = (b[6] & 0x0f) | 0x40 + b[8] = (b[8] & 0x3f) | 0x80 + return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]) +} + +// UploadResult 上传落盘结果。 +type UploadResult struct { + RelPath string // 相对路径:年/月/日/文件类型/uuid.ext + FileName string // 原始文件名(含扩展名) + Size int64 + MD5 string + Ext string // 小写,不含点 + MimeType string +} + +// RelPath2FileType 从相对路径反推文件类型目录名(年/月/日/类型/uuid.ext → 类型)。 +// 供处理器在落盘后回填库内 fileType(避免再解析一次文件名)。 +func (u *UploadResult) RelPath2FileType() string { + parts := strings.Split(u.RelPath, "/") + if len(parts) >= 2 { + if ft := parts[len(parts)-2]; validFileTypes[ft] { + return ft + } + } + return FileTypeOther +} + +// saveTypedUpload 流式保存上传文件(边读边算 MD5,内存占用恒定;绝不 ReadAll)。 +// fileType 为空或非法时按 bizType+扩展名推断;maxBytes<=0 时用 Upload.MaxMB。 +// 返回相对路径(年/月/日/文件类型/uuid.ext)与原始文件名/大小/MD5。 +func saveTypedUpload(r *http.Request, field, rootDir, bizType, fileType string, maxBytes int64) (*UploadResult, error) { file, header, err := r.FormFile(field) if err != nil { - return "", err + return nil, err } defer file.Close() ext := strings.ToLower(filepath.Ext(header.Filename)) - if ext == "" { - ext = ".bin" + if ext == "" || !allowedExt[ext] { + return nil, fmt.Errorf("不支持的文件类型(仅支持 PDF/图片/Office/图纸/压缩包)") } - name := time.Now().Format("20060102150405") + "_" + randHex(6) + ext - dst, err := os.Create(filepath.Join(full, name)) + if fileType == "" || !validFileTypes[strings.ToUpper(fileType)] { + fileType = deriveFileType(bizType, ext) + } else { + fileType = strings.ToUpper(fileType) + } + if maxBytes > 0 && header.Size > 0 && header.Size > maxBytes { + return nil, fmt.Errorf("文件超过 %dMB 上限,请压缩后重传", maxBytes>>20) + } + + relDir := buildRelDir(fileType, time.Now()) + absDir, ok := safeAbsPath(rootDir, relDir) + if !ok { + return nil, fmt.Errorf("非法存储路径") + } + if err := os.MkdirAll(absDir, 0o755); err != nil { + return nil, err + } + storedName := newUUID() + ext + relPath := relDir + "/" + storedName + dst := filepath.Join(absDir, storedName) + + out, err := os.Create(dst) if err != nil { - return "", err + return nil, err } - defer dst.Close() - if _, err := io.Copy(dst, file); err != nil { - return "", err + hash := md5.New() + var written int64 + if maxBytes > 0 { + written, err = io.Copy(io.MultiWriter(out, hash), io.LimitReader(file, maxBytes+1)) + } else { + written, err = io.Copy(io.MultiWriter(out, hash), file) } - return filepath.ToSlash(filepath.Join(sub, name)), nil + _ = out.Close() + if err != nil { + _ = os.Remove(dst) + return nil, err + } + if maxBytes > 0 && written > maxBytes { + _ = os.Remove(dst) + return nil, fmt.Errorf("文件超过 %dMB 上限,请压缩后重传", maxBytes>>20) + } + + return &UploadResult{ + RelPath: relPath, + FileName: header.Filename, + Size: written, + MD5: hex.EncodeToString(hash.Sum(nil)), + Ext: strings.TrimPrefix(ext, "."), + MimeType: header.Header.Get("Content-Type"), + }, nil } -func randHex(n int) string { - b := make([]byte, n) - _, _ = rand.Read(b) - return hex.EncodeToString(b)[:n*2] +// uploadMaxBytes 单文件上限:按文件类型取 Upload.MaxSize 配置,未配置用 Upload.MaxMB。 +func uploadMaxBytes(maxSizes map[string]int64, maxMB int64, fileType string) int64 { + if maxSizes != nil { + if v, ok := maxSizes[strings.ToUpper(fileType)]; ok && v > 0 { + return v + } + } + if maxMB > 0 { + return maxMB << 20 + } + return 20 << 20 } -// serveUploadFile 下发上传目录中的文件(仅允许 单层日期子目录/文件名,防路径穿越) +// maxUploadBytes 计算路由组请求体上限:取 MaxMB 与各文件类型 MaxSize 的最大值(兜底 20MB)。 +func maxUploadBytes(maxMB int64, maxSizes map[string]int64) int64 { + limit := maxMB << 20 + if limit <= 0 { + limit = 20 << 20 + } + for _, v := range maxSizes { + if v > limit { + limit = v + } + } + return limit +} + +// fileURL 由相对路径生成免鉴权直链(query 传名,天然支持多级目录)。 +// 注:go-zero 路由不支持多段通配,故统一走 /api/v1/files?name=。 +func fileURL(relPath string) string { + return "/api/v1/files?name=" + url.QueryEscape(relPath) +} + +// serveUploadFile 下发上传目录中的文件(相对路径可为多级「年/月/日/类型/文件名」,防路径穿越)。 func serveUploadFile(w http.ResponseWriter, r *http.Request, dir, name string) { name = strings.TrimSpace(name) - clean := filepath.Clean(filepath.FromSlash(name)) - if clean == "." || clean == ".." || - strings.HasPrefix(clean, ".."+string(filepath.Separator)) || - filepath.IsAbs(clean) || strings.ContainsRune(name, '\x00') { + if name == "" { http.Error(w, "非法文件名", http.StatusBadRequest) return } - f, err := os.Open(filepath.Join(dir, clean)) + abs, ok := safeAbsPath(dir, name) + if !ok { + http.Error(w, "非法文件名", http.StatusBadRequest) + return + } + f, err := os.Open(abs) if err != nil { http.Error(w, "文件不存在", http.StatusNotFound) return } defer f.Close() ct := "application/octet-stream" - base := strings.ToLower(clean) + base := strings.ToLower(abs) switch { case strings.HasSuffix(base, ".pdf"): ct = "application/pdf" @@ -71,35 +253,20 @@ func serveUploadFile(w http.ResponseWriter, r *http.Request, dir, name string) { ct = "image/jpeg" case strings.HasSuffix(base, ".png"): ct = "image/png" + case strings.HasSuffix(base, ".gif"): + ct = "image/gif" + case strings.HasSuffix(base, ".xlsx"): + ct = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + case strings.HasSuffix(base, ".xls"): + ct = "application/vnd.ms-excel" } w.Header().Set("Content-Type", ct) - http.ServeContent(w, r, name, time.Time{}, f) + http.ServeContent(w, r, filepath.Base(abs), time.Time{}, f) } -// saveUploadFileFull 同 saveUploadFile,但额外返回原始文件名与字节大小(附件登记用) -func saveUploadFileFull(r *http.Request, field, dir string) (string, string, int64, error) { - sub := time.Now().Format("2006-01-02") - full := filepath.Join(dir, sub) - if err := os.MkdirAll(full, 0o755); err != nil { - return "", "", 0, err - } - file, header, err := r.FormFile(field) - if err != nil { - return "", "", 0, err - } - defer file.Close() - ext := strings.ToLower(filepath.Ext(header.Filename)) - if ext == "" { - ext = ".bin" - } - name := time.Now().Format("20060102150405") + "_" + randHex(6) + ext - dst, err := os.Create(filepath.Join(full, name)) - if err != nil { - return "", "", 0, err - } - defer dst.Close() - if _, err := io.Copy(dst, file); err != nil { - return "", "", 0, err - } - return filepath.ToSlash(filepath.Join(sub, name)), header.Filename, header.Size, nil +// randHex 随机十六进制串(保留给其他场景的短随机名使用)。 +func randHex(n int) string { + b := make([]byte, n) + _, _ = rand.Read(b) + return hex.EncodeToString(b)[:n*2] } diff --git a/bj_power_mes/internal/logic/attachment.go b/bj_power_mes/internal/logic/attachment.go index f4b2691..25c7113 100644 --- a/bj_power_mes/internal/logic/attachment.go +++ b/bj_power_mes/internal/logic/attachment.go @@ -2,38 +2,107 @@ package logic import ( "context" + "time" "bj_power_mes/ent" "bj_power_mes/ent/attachment" ) -// AddAttachment 新增附件记录 -func (s *Service) AddAttachment(ctx context.Context, bizType, bizId, fileName, filePath string, fileSize int, uploader string) (*ent.Attachment, error) { +// AddAttachment 新增附件记录(含统一存储方案字段:文件类型/扩展名/MD5/MIME)。 +func (s *Service) AddAttachment(ctx context.Context, bizType, bizId, fileType, fileName, filePath, fileExt, fileMD5, mimeType string, fileSize int, uploader string) (*ent.Attachment, error) { return s.ctx.EntClient.Attachment.Create(). SetBizType(bizType).SetBizId(bizId).SetFileName(fileName). - SetFilePath(filePath).SetFileSize(fileSize).SetUploader(uploader).Save(ctx) + SetFilePath(filePath).SetFileSize(fileSize).SetUploader(uploader). + SetFileType(fileType).SetFileExt(fileExt).SetFileMd5(fileMD5).SetMimeType(mimeType). + Save(ctx) } -// ListAttachments 按业务类型/ID 查询附件 +// ListAttachments 按业务类型/ID 查询附件(排除逻辑删除),供各业务页面的附件面板使用。 func (s *Service) ListAttachments(ctx context.Context, bizType, bizId string) ([]*ent.Attachment, error) { - q := s.ctx.EntClient.Attachment.Query() + q := s.ctx.EntClient.Attachment.Query().Where(attachment.DeletedEQ(false)) if bizType != "" { - q = q.Where(attachment.BizType(bizType)) + q = q.Where(attachment.BizTypeEQ(bizType)) } if bizId != "" { - q = q.Where(attachment.BizId(bizId)) + q = q.Where(attachment.BizIdEQ(bizId)) } return q.Order(ent.Desc(attachment.FieldCreatedAt), ent.Desc(attachment.FieldID)).All(ctx) } -// DeleteAttachment 删除附件记录并返回记录(供删除物理文件) -func (s *Service) DeleteAttachment(ctx context.Context, id int) (*ent.Attachment, error) { +// FindByMD5 同业务对象 + 同 MD5 且未删除的既有附件(秒传/去重用)。 +func (s *Service) FindByMD5(ctx context.Context, bizType, bizId, fileMD5 string) (*ent.Attachment, error) { + return s.ctx.EntClient.Attachment.Query(). + Where(attachment.BizTypeEQ(bizType), attachment.BizIdEQ(bizId), + attachment.FileMd5EQ(fileMD5), attachment.DeletedEQ(false)). + Only(ctx) +} + +// GetAttachment 按 id 取附件。 +func (s *Service) GetAttachment(ctx context.Context, id int) (*ent.Attachment, error) { + return s.ctx.EntClient.Attachment.Get(ctx, id) +} + +// DeleteAttachment 逻辑删除附件(DB 标记 deleted,物理文件由归档任务统一处理)。 +func (s *Service) DeleteAttachment(ctx context.Context, id int, operator string) (*ent.Attachment, error) { att, err := s.ctx.EntClient.Attachment.Get(ctx, id) if err != nil { return nil, err } - if err := s.ctx.EntClient.Attachment.DeleteOneID(id).Exec(ctx); err != nil { + if _, err := s.ctx.EntClient.Attachment.UpdateOneID(id). + SetDeleted(true).SetDeletedBy(operator).Save(ctx); err != nil { return nil, err } return att, nil } + +// ListAttachmentPage 附件中心:全量分页查询(文件类型/业务类型/业务标识/文件名/时间区间)。 +// 默认只统计未删除记录;includeDeleted=true 时含已逻辑删除(便于追溯)。 +func (s *Service) ListAttachmentPage(ctx context.Context, fileType, bizType, bizId, fileName string, + start, end time.Time, includeDeleted bool, page, pageSize int) (int, []*ent.Attachment, error) { + q := s.ctx.EntClient.Attachment.Query() + if !includeDeleted { + q = q.Where(attachment.DeletedEQ(false)) + } + if fileType != "" { + q = q.Where(attachment.FileTypeEQ(fileType)) + } + if bizType != "" { + q = q.Where(attachment.BizTypeEQ(bizType)) + } + if bizId != "" { + q = q.Where(attachment.BizIdContainsFold(bizId)) + } + if fileName != "" { + q = q.Where(attachment.FileNameContainsFold(fileName)) + } + if !start.IsZero() { + q = q.Where(attachment.CreatedAtGTE(start)) + } + if !end.IsZero() { + q = q.Where(attachment.CreatedAtLTE(end)) + } + total, err := q.Count(ctx) + if err != nil { + return 0, nil, err + } + list, err := q.Order(ent.Desc(attachment.FieldCreatedAt), ent.Desc(attachment.FieldID)). + Offset((page - 1) * pageSize).Limit(pageSize).All(ctx) + if err != nil { + return 0, nil, err + } + return total, list, nil +} + +// ListArchivableAttachments 列出「未归档且未删除」的附件(归档任务用,年份判断在调用方)。 +func (s *Service) ListArchivableAttachments(ctx context.Context) ([]*ent.Attachment, error) { + return s.ctx.EntClient.Attachment.Query(). + Where(attachment.ArchivedEQ(false), attachment.DeletedEQ(false)). + All(ctx) +} + +// MarkArchived 标记附件已归档(物理文件已移到外部备份目录)。 +func (s *Service) MarkArchived(ctx context.Context, id int) error { + _, err := s.ctx.EntClient.Attachment.UpdateOneID(id). + SetArchived(true).SetArchivedAt(time.Now().Unix()).Save(ctx) + return err +} diff --git a/bj_power_mes/internal/logic/product.go b/bj_power_mes/internal/logic/product.go index cef832b..bf6a2a4 100644 --- a/bj_power_mes/internal/logic/product.go +++ b/bj_power_mes/internal/logic/product.go @@ -21,8 +21,9 @@ type ProductTypeReq struct { Id int `json:"id"` Name string `json:"name"` Code string `json:"code"` + Spec string `json:"spec"` + Unit string `json:"unit"` Category string `json:"category"` - Remark string `json:"remark"` IsActive bool `json:"isActive"` } @@ -31,7 +32,16 @@ func (s *Service) CreateProductType(ctx context.Context, req ProductTypeReq) err if !req.IsActive { active = true } - if err := s.ctx.Wms.CreateProductType(ctx, req.Code, req.Name, req.Category, req.Remark, active); err != nil { + if strings.TrimSpace(req.Name) == "" { + return errors.New("名称为必填项") + } + if strings.TrimSpace(req.Spec) == "" { + return errors.New("规格型号为必填项") + } + if strings.TrimSpace(req.Unit) == "" { + return errors.New("单位为必填项") + } + if err := s.ctx.Wms.CreateProductType(ctx, req.Code, req.Name, req.Spec, req.Unit, req.Category, active); err != nil { return errors.New("WMS 不可达或拒绝写入(编码主数据以 WMS 为单一来源):" + err.Error()) } return nil @@ -41,7 +51,16 @@ func (s *Service) UpdateProductType(ctx context.Context, req ProductTypeReq) err if req.Id == 0 { return errors.New("缺少 id") } - if err := s.ctx.Wms.UpdateProductType(ctx, req.Id, req.Name, req.Category, req.Remark, req.IsActive); err != nil { + if strings.TrimSpace(req.Name) == "" { + return errors.New("名称为必填项") + } + if strings.TrimSpace(req.Spec) == "" { + return errors.New("规格型号为必填项") + } + if strings.TrimSpace(req.Unit) == "" { + return errors.New("单位为必填项") + } + if err := s.ctx.Wms.UpdateProductType(ctx, req.Id, req.Name, req.Spec, req.Unit, req.Category, req.IsActive); err != nil { return errors.New("WMS 不可达或拒绝写入:" + err.Error()) } return nil @@ -143,8 +162,8 @@ func (s *Service) localProductTypes(ctx context.Context, code, name, category st continue } rows = append(rows, wmsclient.ProductTypeRow{ - ID: p.ID, Code: p.Code, Name: p.Name, Category: p.Category, - Remark: p.Remark, IsActive: p.IsActive, + ID: p.ID, Code: p.Code, Name: p.Name, Spec: p.Spec, Unit: p.Unit, + Category: p.Category, IsActive: p.IsActive, CreatedAt: p.CreatedAt.Unix(), }) } diff --git a/bj_power_mes/internal/wmsclient/client.go b/bj_power_mes/internal/wmsclient/client.go index b0ac3cc..0df78eb 100644 --- a/bj_power_mes/internal/wmsclient/client.go +++ b/bj_power_mes/internal/wmsclient/client.go @@ -87,12 +87,15 @@ func (c *Client) MaterialExists(ctx context.Context, codes []string) ([]string, } // ProductTypeRow 产品型号档案行(WMS materials item_type=3) +// 注:原「备注」随 WMS 物料档案「简称」一并删除(2026-09-19), +// 改为与 WMS 必填口径一致的「规格 / 单位」。 type ProductTypeRow struct { ID int `json:"id"` Code string `json:"code"` Name string `json:"name"` + Spec string `json:"spec"` + Unit string `json:"unit"` Category string `json:"category"` - Remark string `json:"remark"` IsActive bool `json:"isActive"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` @@ -193,16 +196,17 @@ func (c *Client) ProductTypePage(ctx context.Context, code, name, category, isAc } // CreateProductType 新建产品型号(code 可空由 WMS 自动生成 PROD-日期-流水) -func (c *Client) CreateProductType(ctx context.Context, code, name, category, remark string, isActive bool) error { +// spec/unit 必填(与 WMS 物料档案必填口径一致) +func (c *Client) CreateProductType(ctx context.Context, code, name, spec, unit, category string, isActive bool) error { return c.post(ctx, "/api/internal/product-types", map[string]any{ - "code": code, "name": name, "category": category, "remark": remark, "isActive": isActive, + "code": code, "name": name, "spec": spec, "unit": unit, "category": category, "isActive": isActive, }) } // UpdateProductType 修改产品型号(编码不可改) -func (c *Client) UpdateProductType(ctx context.Context, id int, name, category, remark string, isActive bool) error { +func (c *Client) UpdateProductType(ctx context.Context, id int, name, spec, unit, category string, isActive bool) error { return c.putJSON(ctx, "/api/internal/product-types", map[string]any{ - "id": id, "name": name, "category": category, "remark": remark, "isActive": isActive, + "id": id, "name": name, "spec": spec, "unit": unit, "category": category, "isActive": isActive, }) } diff --git a/bj_power_mes/main.go b/bj_power_mes/main.go index efafe48..b066f60 100644 --- a/bj_power_mes/main.go +++ b/bj_power_mes/main.go @@ -178,6 +178,9 @@ func main() { handler.RegisterRoutes(server, svcCtx) handler.RegisterProductionRoutes(server, svcCtx) + // 附件磁盘空间监控:每天 07:00 检测一次(剩余 <20% 告警、<10% 提示清理) + handler.StartDiskMonitor(svcCtx) + // 可生产数量 / 未来5天需求:不做定时推送。WMS 打开「可生产数量」时经内部接口 // /api/internal/producible 向 MES 实时拉取,两系统之间不存在周期同步任务。 diff --git a/bj_power_mes/schema/attachment.go b/bj_power_mes/schema/attachment.go index 5eaf1e7..dc5765c 100644 --- a/bj_power_mes/schema/attachment.go +++ b/bj_power_mes/schema/attachment.go @@ -10,7 +10,9 @@ import ( "entgo.io/ent/schema/index" ) -// Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据 +// Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据。 +// 存储落地约定(2026-09-19 统一方案):/年/月/日/<文件类型大写枚举>/., +// 库内 filePath 只存相对路径(如 2026/09/19/INSPECTION_PHOTO/xxx.jpg),不存绝对路径。 type Attachment struct { ent.Schema } @@ -29,6 +31,17 @@ func (Attachment) Fields() []ent.Field { field.Int("fileSize").Default(0).Comment("字节数"), field.String("uploader").Default("").MaxLen(64).Comment("上传人"), field.Time("createdAt").Default(time.Now).Immutable(), + // 文件类型(大写枚举):决定存储目录分层,与 bizType(业务对象)正交 + field.String("fileType").Default("OTHER").MaxLen(32).Comment("文件类型 大写枚举 PROCESS_PDF/INSPECTION_PHOTO/..."), + field.String("fileExt").Default("").MaxLen(16).Comment("扩展名(小写,不含点)"), + field.String("fileMd5").Default("").MaxLen(64).Comment("文件MD5(秒传/去重)"), + field.String("mimeType").Default("").MaxLen(128).Comment("MIME类型"), + // 归档 / 逻辑删除:物理文件由归档任务统一处理,库内保留索引可追溯 + field.Bool("archived").Default(false).Comment("是否已归档"), + field.Int64("archivedAt").Default(0).Comment("归档时间(unix秒)"), + field.Bool("deleted").Default(false).Comment("逻辑删除"), + field.Int64("deletedAt").Default(0).Comment("删除时间(unix秒)"), + field.String("deletedBy").Default("").MaxLen(64).Comment("删除人"), } } @@ -36,5 +49,7 @@ func (Attachment) Indexes() []ent.Index { return []ent.Index{ index.Fields("bizType", "bizId"), index.Fields("createdAt"), + index.Fields("fileType"), + index.Fields("fileMd5"), } } diff --git a/bj_power_mes/schema/product_type.go b/bj_power_mes/schema/product_type.go index 80cf95f..0d0b0d5 100644 --- a/bj_power_mes/schema/product_type.go +++ b/bj_power_mes/schema/product_type.go @@ -25,7 +25,10 @@ func (ProductType) Fields() []ent.Field { field.String("name").MaxLen(50).Comment("产品名称"), field.String("code").MaxLen(20).Comment("产品代号"), field.String("category").Default("").MaxLen(30).Comment("产品分类"), - field.String("remark").Default("").MaxLen(255), + // 原 remark(备注)随 WMS 物料档案「简称」一并删除(2026-09-19); + // 改存「规格 / 单位」,与 WMS 物料档案必填口径保持一致(离线兜底缓存)。 + field.String("spec").Default("").MaxLen(128).Comment("规格型号"), + field.String("unit").Default("").MaxLen(32).Comment("单位"), field.Bool("isActive").Default(true), field.Time("createdAt").Default(time.Now).Immutable(), field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(), diff --git a/bj_power_wms/bj_power_wms.go b/bj_power_wms/bj_power_wms.go index e72f347..092aa69 100644 --- a/bj_power_wms/bj_power_wms.go +++ b/bj_power_wms/bj_power_wms.go @@ -102,6 +102,9 @@ func main() { handler.RegisterHandlers(server, ctx) + // 磁盘空间监控:每天 07:00 检测附件根目录剩余空间(<20% 告警、<10% 提示清理) + handler.StartDiskMonitor(ctx) + fmt.Printf("Starting bj_power_wms server at %s:%d...\n", c.Host, c.Port) logx.Infof("Starting bj_power_wms server at %s:%d...", c.Host, c.Port) diff --git a/bj_power_wms/ent/attachment.go b/bj_power_wms/ent/attachment.go index 3757ad9..6483bb5 100644 --- a/bj_power_wms/ent/attachment.go +++ b/bj_power_wms/ent/attachment.go @@ -22,14 +22,30 @@ type Attachment struct { BizID string `json:"bizId,omitempty"` // 原始文件名(含扩展名) FileName string `json:"fileName,omitempty"` - // 磁盘相对文件名(uuid+ext) + // 磁盘相对路径(年/月/日/文件类型/uuid.ext) FilePath string `json:"filePath,omitempty"` + // 文件类型大写枚举 PROCESS_PDF/INSPECTION_PHOTO/... + FileType string `json:"fileType,omitempty"` + // 扩展名(小写,不含点) + FileExt string `json:"fileExt,omitempty"` + // 文件MD5(秒传/去重) + FileMd5 string `json:"fileMd5,omitempty"` // 文件大小(字节) FileSize int64 `json:"fileSize,omitempty"` // MIME 类型 MimeType string `json:"mimeType,omitempty"` // 上传人 UploadedBy string `json:"uploadedBy,omitempty"` + // 是否已归档(备份到外部存储) + Archived bool `json:"archived,omitempty"` + // 归档时间(unix秒) + ArchivedAt int64 `json:"archivedAt,omitempty"` + // 逻辑删除标记 + Deleted bool `json:"deleted,omitempty"` + // 删除时间(unix秒) + DeletedAt int64 `json:"deletedAt,omitempty"` + // 删除人 + DeletedBy string `json:"deletedBy,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt int64 `json:"createdAt,omitempty"` selectValues sql.SelectValues @@ -40,9 +56,11 @@ func (*Attachment) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case attachment.FieldID, attachment.FieldFileSize, attachment.FieldCreatedAt: + case attachment.FieldArchived, attachment.FieldDeleted: + values[i] = new(sql.NullBool) + case attachment.FieldID, attachment.FieldFileSize, attachment.FieldArchivedAt, attachment.FieldDeletedAt, attachment.FieldCreatedAt: values[i] = new(sql.NullInt64) - case attachment.FieldBizType, attachment.FieldBizID, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldMimeType, attachment.FieldUploadedBy: + case attachment.FieldBizType, attachment.FieldBizID, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldFileType, attachment.FieldFileExt, attachment.FieldFileMd5, attachment.FieldMimeType, attachment.FieldUploadedBy, attachment.FieldDeletedBy: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -89,6 +107,24 @@ func (_m *Attachment) assignValues(columns []string, values []any) error { } else if value.Valid { _m.FilePath = value.String } + case attachment.FieldFileType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_type", values[i]) + } else if value.Valid { + _m.FileType = value.String + } + case attachment.FieldFileExt: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_ext", values[i]) + } else if value.Valid { + _m.FileExt = value.String + } + case attachment.FieldFileMd5: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field file_md5", values[i]) + } else if value.Valid { + _m.FileMd5 = value.String + } case attachment.FieldFileSize: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field file_size", values[i]) @@ -107,6 +143,36 @@ func (_m *Attachment) assignValues(columns []string, values []any) error { } else if value.Valid { _m.UploadedBy = value.String } + case attachment.FieldArchived: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field archived", values[i]) + } else if value.Valid { + _m.Archived = value.Bool + } + case attachment.FieldArchivedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field archived_at", values[i]) + } else if value.Valid { + _m.ArchivedAt = value.Int64 + } + case attachment.FieldDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field deleted", values[i]) + } else if value.Valid { + _m.Deleted = value.Bool + } + case attachment.FieldDeletedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Int64 + } + case attachment.FieldDeletedBy: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field deleted_by", values[i]) + } else if value.Valid { + _m.DeletedBy = value.String + } case attachment.FieldCreatedAt: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) @@ -161,6 +227,15 @@ func (_m *Attachment) String() string { builder.WriteString("file_path=") builder.WriteString(_m.FilePath) builder.WriteString(", ") + builder.WriteString("file_type=") + builder.WriteString(_m.FileType) + builder.WriteString(", ") + builder.WriteString("file_ext=") + builder.WriteString(_m.FileExt) + builder.WriteString(", ") + builder.WriteString("file_md5=") + builder.WriteString(_m.FileMd5) + builder.WriteString(", ") builder.WriteString("file_size=") builder.WriteString(fmt.Sprintf("%v", _m.FileSize)) builder.WriteString(", ") @@ -170,6 +245,21 @@ func (_m *Attachment) String() string { builder.WriteString("uploaded_by=") builder.WriteString(_m.UploadedBy) builder.WriteString(", ") + builder.WriteString("archived=") + builder.WriteString(fmt.Sprintf("%v", _m.Archived)) + builder.WriteString(", ") + builder.WriteString("archived_at=") + builder.WriteString(fmt.Sprintf("%v", _m.ArchivedAt)) + builder.WriteString(", ") + builder.WriteString("deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.Deleted)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(fmt.Sprintf("%v", _m.DeletedAt)) + builder.WriteString(", ") + builder.WriteString("deleted_by=") + builder.WriteString(_m.DeletedBy) + builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt)) builder.WriteByte(')') diff --git a/bj_power_wms/ent/attachment/attachment.go b/bj_power_wms/ent/attachment/attachment.go index 57d461c..62a48d1 100644 --- a/bj_power_wms/ent/attachment/attachment.go +++ b/bj_power_wms/ent/attachment/attachment.go @@ -19,12 +19,28 @@ const ( FieldFileName = "file_name" // FieldFilePath holds the string denoting the file_path field in the database. FieldFilePath = "file_path" + // FieldFileType holds the string denoting the file_type field in the database. + FieldFileType = "file_type" + // FieldFileExt holds the string denoting the file_ext field in the database. + FieldFileExt = "file_ext" + // FieldFileMd5 holds the string denoting the file_md5 field in the database. + FieldFileMd5 = "file_md5" // FieldFileSize holds the string denoting the file_size field in the database. FieldFileSize = "file_size" // FieldMimeType holds the string denoting the mime_type field in the database. FieldMimeType = "mime_type" // FieldUploadedBy holds the string denoting the uploaded_by field in the database. FieldUploadedBy = "uploaded_by" + // FieldArchived holds the string denoting the archived field in the database. + FieldArchived = "archived" + // FieldArchivedAt holds the string denoting the archived_at field in the database. + FieldArchivedAt = "archived_at" + // FieldDeleted holds the string denoting the deleted field in the database. + FieldDeleted = "deleted" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldDeletedBy holds the string denoting the deleted_by field in the database. + FieldDeletedBy = "deleted_by" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // Table holds the table name of the attachment in the database. @@ -38,9 +54,17 @@ var Columns = []string{ FieldBizID, FieldFileName, FieldFilePath, + FieldFileType, + FieldFileExt, + FieldFileMd5, FieldFileSize, FieldMimeType, FieldUploadedBy, + FieldArchived, + FieldArchivedAt, + FieldDeleted, + FieldDeletedAt, + FieldDeletedBy, FieldCreatedAt, } @@ -57,6 +81,10 @@ func ValidColumn(column string) bool { var ( // DefaultFileSize holds the default value on creation for the "file_size" field. DefaultFileSize int64 + // DefaultArchived holds the default value on creation for the "archived" field. + DefaultArchived bool + // DefaultDeleted holds the default value on creation for the "deleted" field. + DefaultDeleted bool // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() int64 ) @@ -89,6 +117,21 @@ func ByFilePath(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldFilePath, opts...).ToFunc() } +// ByFileType orders the results by the file_type field. +func ByFileType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileType, opts...).ToFunc() +} + +// ByFileExt orders the results by the file_ext field. +func ByFileExt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileExt, opts...).ToFunc() +} + +// ByFileMd5 orders the results by the file_md5 field. +func ByFileMd5(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFileMd5, opts...).ToFunc() +} + // ByFileSize orders the results by the file_size field. func ByFileSize(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldFileSize, opts...).ToFunc() @@ -104,6 +147,31 @@ func ByUploadedBy(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUploadedBy, opts...).ToFunc() } +// ByArchived orders the results by the archived field. +func ByArchived(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArchived, opts...).ToFunc() +} + +// ByArchivedAt orders the results by the archived_at field. +func ByArchivedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldArchivedAt, opts...).ToFunc() +} + +// ByDeleted orders the results by the deleted field. +func ByDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleted, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByDeletedBy orders the results by the deleted_by field. +func ByDeletedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedBy, opts...).ToFunc() +} + // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() diff --git a/bj_power_wms/ent/attachment/where.go b/bj_power_wms/ent/attachment/where.go index 5a80991..2926462 100644 --- a/bj_power_wms/ent/attachment/where.go +++ b/bj_power_wms/ent/attachment/where.go @@ -73,6 +73,21 @@ func FilePath(v string) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldFilePath, v)) } +// FileType applies equality check predicate on the "file_type" field. It's identical to FileTypeEQ. +func FileType(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileType, v)) +} + +// FileExt applies equality check predicate on the "file_ext" field. It's identical to FileExtEQ. +func FileExt(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileExt, v)) +} + +// FileMd5 applies equality check predicate on the "file_md5" field. It's identical to FileMd5EQ. +func FileMd5(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileMd5, v)) +} + // FileSize applies equality check predicate on the "file_size" field. It's identical to FileSizeEQ. func FileSize(v int64) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldFileSize, v)) @@ -88,6 +103,31 @@ func UploadedBy(v string) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldUploadedBy, v)) } +// Archived applies equality check predicate on the "archived" field. It's identical to ArchivedEQ. +func Archived(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchived, v)) +} + +// ArchivedAt applies equality check predicate on the "archived_at" field. It's identical to ArchivedAtEQ. +func ArchivedAt(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchivedAt, v)) +} + +// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ. +func Deleted(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedBy applies equality check predicate on the "deleted_by" field. It's identical to DeletedByEQ. +func DeletedBy(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedBy, v)) +} + // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. func CreatedAt(v int64) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldCreatedAt, v)) @@ -353,6 +393,231 @@ func FilePathContainsFold(v string) predicate.Attachment { return predicate.Attachment(sql.FieldContainsFold(FieldFilePath, v)) } +// FileTypeEQ applies the EQ predicate on the "file_type" field. +func FileTypeEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileType, v)) +} + +// FileTypeNEQ applies the NEQ predicate on the "file_type" field. +func FileTypeNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileType, v)) +} + +// FileTypeIn applies the In predicate on the "file_type" field. +func FileTypeIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileType, vs...)) +} + +// FileTypeNotIn applies the NotIn predicate on the "file_type" field. +func FileTypeNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileType, vs...)) +} + +// FileTypeGT applies the GT predicate on the "file_type" field. +func FileTypeGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileType, v)) +} + +// FileTypeGTE applies the GTE predicate on the "file_type" field. +func FileTypeGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileType, v)) +} + +// FileTypeLT applies the LT predicate on the "file_type" field. +func FileTypeLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileType, v)) +} + +// FileTypeLTE applies the LTE predicate on the "file_type" field. +func FileTypeLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileType, v)) +} + +// FileTypeContains applies the Contains predicate on the "file_type" field. +func FileTypeContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileType, v)) +} + +// FileTypeHasPrefix applies the HasPrefix predicate on the "file_type" field. +func FileTypeHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileType, v)) +} + +// FileTypeHasSuffix applies the HasSuffix predicate on the "file_type" field. +func FileTypeHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileType, v)) +} + +// FileTypeIsNil applies the IsNil predicate on the "file_type" field. +func FileTypeIsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldFileType)) +} + +// FileTypeNotNil applies the NotNil predicate on the "file_type" field. +func FileTypeNotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldFileType)) +} + +// FileTypeEqualFold applies the EqualFold predicate on the "file_type" field. +func FileTypeEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileType, v)) +} + +// FileTypeContainsFold applies the ContainsFold predicate on the "file_type" field. +func FileTypeContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileType, v)) +} + +// FileExtEQ applies the EQ predicate on the "file_ext" field. +func FileExtEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileExt, v)) +} + +// FileExtNEQ applies the NEQ predicate on the "file_ext" field. +func FileExtNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileExt, v)) +} + +// FileExtIn applies the In predicate on the "file_ext" field. +func FileExtIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileExt, vs...)) +} + +// FileExtNotIn applies the NotIn predicate on the "file_ext" field. +func FileExtNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileExt, vs...)) +} + +// FileExtGT applies the GT predicate on the "file_ext" field. +func FileExtGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileExt, v)) +} + +// FileExtGTE applies the GTE predicate on the "file_ext" field. +func FileExtGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileExt, v)) +} + +// FileExtLT applies the LT predicate on the "file_ext" field. +func FileExtLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileExt, v)) +} + +// FileExtLTE applies the LTE predicate on the "file_ext" field. +func FileExtLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileExt, v)) +} + +// FileExtContains applies the Contains predicate on the "file_ext" field. +func FileExtContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileExt, v)) +} + +// FileExtHasPrefix applies the HasPrefix predicate on the "file_ext" field. +func FileExtHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileExt, v)) +} + +// FileExtHasSuffix applies the HasSuffix predicate on the "file_ext" field. +func FileExtHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileExt, v)) +} + +// FileExtIsNil applies the IsNil predicate on the "file_ext" field. +func FileExtIsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldFileExt)) +} + +// FileExtNotNil applies the NotNil predicate on the "file_ext" field. +func FileExtNotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldFileExt)) +} + +// FileExtEqualFold applies the EqualFold predicate on the "file_ext" field. +func FileExtEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileExt, v)) +} + +// FileExtContainsFold applies the ContainsFold predicate on the "file_ext" field. +func FileExtContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileExt, v)) +} + +// FileMd5EQ applies the EQ predicate on the "file_md5" field. +func FileMd5EQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldFileMd5, v)) +} + +// FileMd5NEQ applies the NEQ predicate on the "file_md5" field. +func FileMd5NEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldFileMd5, v)) +} + +// FileMd5In applies the In predicate on the "file_md5" field. +func FileMd5In(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldFileMd5, vs...)) +} + +// FileMd5NotIn applies the NotIn predicate on the "file_md5" field. +func FileMd5NotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldFileMd5, vs...)) +} + +// FileMd5GT applies the GT predicate on the "file_md5" field. +func FileMd5GT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldFileMd5, v)) +} + +// FileMd5GTE applies the GTE predicate on the "file_md5" field. +func FileMd5GTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldFileMd5, v)) +} + +// FileMd5LT applies the LT predicate on the "file_md5" field. +func FileMd5LT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldFileMd5, v)) +} + +// FileMd5LTE applies the LTE predicate on the "file_md5" field. +func FileMd5LTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldFileMd5, v)) +} + +// FileMd5Contains applies the Contains predicate on the "file_md5" field. +func FileMd5Contains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldFileMd5, v)) +} + +// FileMd5HasPrefix applies the HasPrefix predicate on the "file_md5" field. +func FileMd5HasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldFileMd5, v)) +} + +// FileMd5HasSuffix applies the HasSuffix predicate on the "file_md5" field. +func FileMd5HasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldFileMd5, v)) +} + +// FileMd5IsNil applies the IsNil predicate on the "file_md5" field. +func FileMd5IsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldFileMd5)) +} + +// FileMd5NotNil applies the NotNil predicate on the "file_md5" field. +func FileMd5NotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldFileMd5)) +} + +// FileMd5EqualFold applies the EqualFold predicate on the "file_md5" field. +func FileMd5EqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldFileMd5, v)) +} + +// FileMd5ContainsFold applies the ContainsFold predicate on the "file_md5" field. +func FileMd5ContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldFileMd5, v)) +} + // FileSizeEQ applies the EQ predicate on the "file_size" field. func FileSizeEQ(v int64) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldFileSize, v)) @@ -543,6 +808,201 @@ func UploadedByContainsFold(v string) predicate.Attachment { return predicate.Attachment(sql.FieldContainsFold(FieldUploadedBy, v)) } +// ArchivedEQ applies the EQ predicate on the "archived" field. +func ArchivedEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchived, v)) +} + +// ArchivedNEQ applies the NEQ predicate on the "archived" field. +func ArchivedNEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldArchived, v)) +} + +// ArchivedAtEQ applies the EQ predicate on the "archived_at" field. +func ArchivedAtEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldArchivedAt, v)) +} + +// ArchivedAtNEQ applies the NEQ predicate on the "archived_at" field. +func ArchivedAtNEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldArchivedAt, v)) +} + +// ArchivedAtIn applies the In predicate on the "archived_at" field. +func ArchivedAtIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldArchivedAt, vs...)) +} + +// ArchivedAtNotIn applies the NotIn predicate on the "archived_at" field. +func ArchivedAtNotIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldArchivedAt, vs...)) +} + +// ArchivedAtGT applies the GT predicate on the "archived_at" field. +func ArchivedAtGT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldArchivedAt, v)) +} + +// ArchivedAtGTE applies the GTE predicate on the "archived_at" field. +func ArchivedAtGTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldArchivedAt, v)) +} + +// ArchivedAtLT applies the LT predicate on the "archived_at" field. +func ArchivedAtLT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldArchivedAt, v)) +} + +// ArchivedAtLTE applies the LTE predicate on the "archived_at" field. +func ArchivedAtLTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldArchivedAt, v)) +} + +// ArchivedAtIsNil applies the IsNil predicate on the "archived_at" field. +func ArchivedAtIsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldArchivedAt)) +} + +// ArchivedAtNotNil applies the NotNil predicate on the "archived_at" field. +func ArchivedAtNotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldArchivedAt)) +} + +// DeletedEQ applies the EQ predicate on the "deleted" field. +func DeletedEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeleted, v)) +} + +// DeletedNEQ applies the NEQ predicate on the "deleted" field. +func DeletedNEQ(v bool) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeleted, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...int64) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v int64) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldDeletedAt)) +} + +// DeletedByEQ applies the EQ predicate on the "deleted_by" field. +func DeletedByEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEQ(FieldDeletedBy, v)) +} + +// DeletedByNEQ applies the NEQ predicate on the "deleted_by" field. +func DeletedByNEQ(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldNEQ(FieldDeletedBy, v)) +} + +// DeletedByIn applies the In predicate on the "deleted_by" field. +func DeletedByIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldIn(FieldDeletedBy, vs...)) +} + +// DeletedByNotIn applies the NotIn predicate on the "deleted_by" field. +func DeletedByNotIn(vs ...string) predicate.Attachment { + return predicate.Attachment(sql.FieldNotIn(FieldDeletedBy, vs...)) +} + +// DeletedByGT applies the GT predicate on the "deleted_by" field. +func DeletedByGT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGT(FieldDeletedBy, v)) +} + +// DeletedByGTE applies the GTE predicate on the "deleted_by" field. +func DeletedByGTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldGTE(FieldDeletedBy, v)) +} + +// DeletedByLT applies the LT predicate on the "deleted_by" field. +func DeletedByLT(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLT(FieldDeletedBy, v)) +} + +// DeletedByLTE applies the LTE predicate on the "deleted_by" field. +func DeletedByLTE(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldLTE(FieldDeletedBy, v)) +} + +// DeletedByContains applies the Contains predicate on the "deleted_by" field. +func DeletedByContains(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContains(FieldDeletedBy, v)) +} + +// DeletedByHasPrefix applies the HasPrefix predicate on the "deleted_by" field. +func DeletedByHasPrefix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasPrefix(FieldDeletedBy, v)) +} + +// DeletedByHasSuffix applies the HasSuffix predicate on the "deleted_by" field. +func DeletedByHasSuffix(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldHasSuffix(FieldDeletedBy, v)) +} + +// DeletedByIsNil applies the IsNil predicate on the "deleted_by" field. +func DeletedByIsNil() predicate.Attachment { + return predicate.Attachment(sql.FieldIsNull(FieldDeletedBy)) +} + +// DeletedByNotNil applies the NotNil predicate on the "deleted_by" field. +func DeletedByNotNil() predicate.Attachment { + return predicate.Attachment(sql.FieldNotNull(FieldDeletedBy)) +} + +// DeletedByEqualFold applies the EqualFold predicate on the "deleted_by" field. +func DeletedByEqualFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldEqualFold(FieldDeletedBy, v)) +} + +// DeletedByContainsFold applies the ContainsFold predicate on the "deleted_by" field. +func DeletedByContainsFold(v string) predicate.Attachment { + return predicate.Attachment(sql.FieldContainsFold(FieldDeletedBy, v)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v int64) predicate.Attachment { return predicate.Attachment(sql.FieldEQ(FieldCreatedAt, v)) diff --git a/bj_power_wms/ent/attachment_create.go b/bj_power_wms/ent/attachment_create.go index d5e6abb..b97b5d5 100644 --- a/bj_power_wms/ent/attachment_create.go +++ b/bj_power_wms/ent/attachment_create.go @@ -45,6 +45,48 @@ func (_c *AttachmentCreate) SetFilePath(v string) *AttachmentCreate { return _c } +// SetFileType sets the "file_type" field. +func (_c *AttachmentCreate) SetFileType(v string) *AttachmentCreate { + _c.mutation.SetFileType(v) + return _c +} + +// SetNillableFileType sets the "file_type" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileType(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileType(*v) + } + return _c +} + +// SetFileExt sets the "file_ext" field. +func (_c *AttachmentCreate) SetFileExt(v string) *AttachmentCreate { + _c.mutation.SetFileExt(v) + return _c +} + +// SetNillableFileExt sets the "file_ext" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileExt(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileExt(*v) + } + return _c +} + +// SetFileMd5 sets the "file_md5" field. +func (_c *AttachmentCreate) SetFileMd5(v string) *AttachmentCreate { + _c.mutation.SetFileMd5(v) + return _c +} + +// SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableFileMd5(v *string) *AttachmentCreate { + if v != nil { + _c.SetFileMd5(*v) + } + return _c +} + // SetFileSize sets the "file_size" field. func (_c *AttachmentCreate) SetFileSize(v int64) *AttachmentCreate { _c.mutation.SetFileSize(v) @@ -87,6 +129,76 @@ func (_c *AttachmentCreate) SetNillableUploadedBy(v *string) *AttachmentCreate { return _c } +// SetArchived sets the "archived" field. +func (_c *AttachmentCreate) SetArchived(v bool) *AttachmentCreate { + _c.mutation.SetArchived(v) + return _c +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableArchived(v *bool) *AttachmentCreate { + if v != nil { + _c.SetArchived(*v) + } + return _c +} + +// SetArchivedAt sets the "archived_at" field. +func (_c *AttachmentCreate) SetArchivedAt(v int64) *AttachmentCreate { + _c.mutation.SetArchivedAt(v) + return _c +} + +// SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableArchivedAt(v *int64) *AttachmentCreate { + if v != nil { + _c.SetArchivedAt(*v) + } + return _c +} + +// SetDeleted sets the "deleted" field. +func (_c *AttachmentCreate) SetDeleted(v bool) *AttachmentCreate { + _c.mutation.SetDeleted(v) + return _c +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeleted(v *bool) *AttachmentCreate { + if v != nil { + _c.SetDeleted(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *AttachmentCreate) SetDeletedAt(v int64) *AttachmentCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeletedAt(v *int64) *AttachmentCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetDeletedBy sets the "deleted_by" field. +func (_c *AttachmentCreate) SetDeletedBy(v string) *AttachmentCreate { + _c.mutation.SetDeletedBy(v) + return _c +} + +// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. +func (_c *AttachmentCreate) SetNillableDeletedBy(v *string) *AttachmentCreate { + if v != nil { + _c.SetDeletedBy(*v) + } + return _c +} + // SetCreatedAt sets the "created_at" field. func (_c *AttachmentCreate) SetCreatedAt(v int64) *AttachmentCreate { _c.mutation.SetCreatedAt(v) @@ -140,6 +252,14 @@ func (_c *AttachmentCreate) defaults() { v := attachment.DefaultFileSize _c.mutation.SetFileSize(v) } + if _, ok := _c.mutation.Archived(); !ok { + v := attachment.DefaultArchived + _c.mutation.SetArchived(v) + } + if _, ok := _c.mutation.Deleted(); !ok { + v := attachment.DefaultDeleted + _c.mutation.SetDeleted(v) + } if _, ok := _c.mutation.CreatedAt(); !ok { v := attachment.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) @@ -163,6 +283,12 @@ func (_c *AttachmentCreate) check() error { if _, ok := _c.mutation.FileSize(); !ok { return &ValidationError{Name: "file_size", err: errors.New(`ent: missing required field "Attachment.file_size"`)} } + if _, ok := _c.mutation.Archived(); !ok { + return &ValidationError{Name: "archived", err: errors.New(`ent: missing required field "Attachment.archived"`)} + } + if _, ok := _c.mutation.Deleted(); !ok { + return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "Attachment.deleted"`)} + } if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Attachment.created_at"`)} } @@ -209,6 +335,18 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) _node.FilePath = value } + if value, ok := _c.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + _node.FileType = value + } + if value, ok := _c.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + _node.FileExt = value + } + if value, ok := _c.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + _node.FileMd5 = value + } if value, ok := _c.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) _node.FileSize = value @@ -221,6 +359,26 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { _spec.SetField(attachment.FieldUploadedBy, field.TypeString, value) _node.UploadedBy = value } + if value, ok := _c.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + _node.Archived = value + } + if value, ok := _c.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + _node.ArchivedAt = value + } + if value, ok := _c.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + _node.Deleted = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + _node.DeletedBy = value + } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) _node.CreatedAt = value @@ -325,6 +483,60 @@ func (u *AttachmentUpsert) UpdateFilePath() *AttachmentUpsert { return u } +// SetFileType sets the "file_type" field. +func (u *AttachmentUpsert) SetFileType(v string) *AttachmentUpsert { + u.Set(attachment.FieldFileType, v) + return u +} + +// UpdateFileType sets the "file_type" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateFileType() *AttachmentUpsert { + u.SetExcluded(attachment.FieldFileType) + return u +} + +// ClearFileType clears the value of the "file_type" field. +func (u *AttachmentUpsert) ClearFileType() *AttachmentUpsert { + u.SetNull(attachment.FieldFileType) + return u +} + +// SetFileExt sets the "file_ext" field. +func (u *AttachmentUpsert) SetFileExt(v string) *AttachmentUpsert { + u.Set(attachment.FieldFileExt, v) + return u +} + +// UpdateFileExt sets the "file_ext" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateFileExt() *AttachmentUpsert { + u.SetExcluded(attachment.FieldFileExt) + return u +} + +// ClearFileExt clears the value of the "file_ext" field. +func (u *AttachmentUpsert) ClearFileExt() *AttachmentUpsert { + u.SetNull(attachment.FieldFileExt) + return u +} + +// SetFileMd5 sets the "file_md5" field. +func (u *AttachmentUpsert) SetFileMd5(v string) *AttachmentUpsert { + u.Set(attachment.FieldFileMd5, v) + return u +} + +// UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateFileMd5() *AttachmentUpsert { + u.SetExcluded(attachment.FieldFileMd5) + return u +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (u *AttachmentUpsert) ClearFileMd5() *AttachmentUpsert { + u.SetNull(attachment.FieldFileMd5) + return u +} + // SetFileSize sets the "file_size" field. func (u *AttachmentUpsert) SetFileSize(v int64) *AttachmentUpsert { u.Set(attachment.FieldFileSize, v) @@ -379,6 +591,96 @@ func (u *AttachmentUpsert) ClearUploadedBy() *AttachmentUpsert { return u } +// SetArchived sets the "archived" field. +func (u *AttachmentUpsert) SetArchived(v bool) *AttachmentUpsert { + u.Set(attachment.FieldArchived, v) + return u +} + +// UpdateArchived sets the "archived" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateArchived() *AttachmentUpsert { + u.SetExcluded(attachment.FieldArchived) + return u +} + +// SetArchivedAt sets the "archived_at" field. +func (u *AttachmentUpsert) SetArchivedAt(v int64) *AttachmentUpsert { + u.Set(attachment.FieldArchivedAt, v) + return u +} + +// UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateArchivedAt() *AttachmentUpsert { + u.SetExcluded(attachment.FieldArchivedAt) + return u +} + +// AddArchivedAt adds v to the "archived_at" field. +func (u *AttachmentUpsert) AddArchivedAt(v int64) *AttachmentUpsert { + u.Add(attachment.FieldArchivedAt, v) + return u +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (u *AttachmentUpsert) ClearArchivedAt() *AttachmentUpsert { + u.SetNull(attachment.FieldArchivedAt) + return u +} + +// SetDeleted sets the "deleted" field. +func (u *AttachmentUpsert) SetDeleted(v bool) *AttachmentUpsert { + u.Set(attachment.FieldDeleted, v) + return u +} + +// UpdateDeleted sets the "deleted" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateDeleted() *AttachmentUpsert { + u.SetExcluded(attachment.FieldDeleted) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AttachmentUpsert) SetDeletedAt(v int64) *AttachmentUpsert { + u.Set(attachment.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateDeletedAt() *AttachmentUpsert { + u.SetExcluded(attachment.FieldDeletedAt) + return u +} + +// AddDeletedAt adds v to the "deleted_at" field. +func (u *AttachmentUpsert) AddDeletedAt(v int64) *AttachmentUpsert { + u.Add(attachment.FieldDeletedAt, v) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AttachmentUpsert) ClearDeletedAt() *AttachmentUpsert { + u.SetNull(attachment.FieldDeletedAt) + return u +} + +// SetDeletedBy sets the "deleted_by" field. +func (u *AttachmentUpsert) SetDeletedBy(v string) *AttachmentUpsert { + u.Set(attachment.FieldDeletedBy, v) + return u +} + +// UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. +func (u *AttachmentUpsert) UpdateDeletedBy() *AttachmentUpsert { + u.SetExcluded(attachment.FieldDeletedBy) + return u +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (u *AttachmentUpsert) ClearDeletedBy() *AttachmentUpsert { + u.SetNull(attachment.FieldDeletedBy) + return u +} + // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsert) SetCreatedAt(v int64) *AttachmentUpsert { u.Set(attachment.FieldCreatedAt, v) @@ -493,6 +795,69 @@ func (u *AttachmentUpsertOne) UpdateFilePath() *AttachmentUpsertOne { }) } +// SetFileType sets the "file_type" field. +func (u *AttachmentUpsertOne) SetFileType(v string) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileType(v) + }) +} + +// UpdateFileType sets the "file_type" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateFileType() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileType() + }) +} + +// ClearFileType clears the value of the "file_type" field. +func (u *AttachmentUpsertOne) ClearFileType() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileType() + }) +} + +// SetFileExt sets the "file_ext" field. +func (u *AttachmentUpsertOne) SetFileExt(v string) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileExt(v) + }) +} + +// UpdateFileExt sets the "file_ext" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateFileExt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileExt() + }) +} + +// ClearFileExt clears the value of the "file_ext" field. +func (u *AttachmentUpsertOne) ClearFileExt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileExt() + }) +} + +// SetFileMd5 sets the "file_md5" field. +func (u *AttachmentUpsertOne) SetFileMd5(v string) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileMd5(v) + }) +} + +// UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateFileMd5() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileMd5() + }) +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (u *AttachmentUpsertOne) ClearFileMd5() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileMd5() + }) +} + // SetFileSize sets the "file_size" field. func (u *AttachmentUpsertOne) SetFileSize(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { @@ -556,6 +921,111 @@ func (u *AttachmentUpsertOne) ClearUploadedBy() *AttachmentUpsertOne { }) } +// SetArchived sets the "archived" field. +func (u *AttachmentUpsertOne) SetArchived(v bool) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetArchived(v) + }) +} + +// UpdateArchived sets the "archived" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateArchived() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateArchived() + }) +} + +// SetArchivedAt sets the "archived_at" field. +func (u *AttachmentUpsertOne) SetArchivedAt(v int64) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetArchivedAt(v) + }) +} + +// AddArchivedAt adds v to the "archived_at" field. +func (u *AttachmentUpsertOne) AddArchivedAt(v int64) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.AddArchivedAt(v) + }) +} + +// UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateArchivedAt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateArchivedAt() + }) +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (u *AttachmentUpsertOne) ClearArchivedAt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearArchivedAt() + }) +} + +// SetDeleted sets the "deleted" field. +func (u *AttachmentUpsertOne) SetDeleted(v bool) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeleted(v) + }) +} + +// UpdateDeleted sets the "deleted" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateDeleted() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeleted() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AttachmentUpsertOne) SetDeletedAt(v int64) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeletedAt(v) + }) +} + +// AddDeletedAt adds v to the "deleted_at" field. +func (u *AttachmentUpsertOne) AddDeletedAt(v int64) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.AddDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateDeletedAt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AttachmentUpsertOne) ClearDeletedAt() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearDeletedAt() + }) +} + +// SetDeletedBy sets the "deleted_by" field. +func (u *AttachmentUpsertOne) SetDeletedBy(v string) *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeletedBy(v) + }) +} + +// UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. +func (u *AttachmentUpsertOne) UpdateDeletedBy() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeletedBy() + }) +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (u *AttachmentUpsertOne) ClearDeletedBy() *AttachmentUpsertOne { + return u.Update(func(s *AttachmentUpsert) { + s.ClearDeletedBy() + }) +} + // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsertOne) SetCreatedAt(v int64) *AttachmentUpsertOne { return u.Update(func(s *AttachmentUpsert) { @@ -837,6 +1307,69 @@ func (u *AttachmentUpsertBulk) UpdateFilePath() *AttachmentUpsertBulk { }) } +// SetFileType sets the "file_type" field. +func (u *AttachmentUpsertBulk) SetFileType(v string) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileType(v) + }) +} + +// UpdateFileType sets the "file_type" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateFileType() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileType() + }) +} + +// ClearFileType clears the value of the "file_type" field. +func (u *AttachmentUpsertBulk) ClearFileType() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileType() + }) +} + +// SetFileExt sets the "file_ext" field. +func (u *AttachmentUpsertBulk) SetFileExt(v string) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileExt(v) + }) +} + +// UpdateFileExt sets the "file_ext" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateFileExt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileExt() + }) +} + +// ClearFileExt clears the value of the "file_ext" field. +func (u *AttachmentUpsertBulk) ClearFileExt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileExt() + }) +} + +// SetFileMd5 sets the "file_md5" field. +func (u *AttachmentUpsertBulk) SetFileMd5(v string) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetFileMd5(v) + }) +} + +// UpdateFileMd5 sets the "file_md5" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateFileMd5() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateFileMd5() + }) +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (u *AttachmentUpsertBulk) ClearFileMd5() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearFileMd5() + }) +} + // SetFileSize sets the "file_size" field. func (u *AttachmentUpsertBulk) SetFileSize(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { @@ -900,6 +1433,111 @@ func (u *AttachmentUpsertBulk) ClearUploadedBy() *AttachmentUpsertBulk { }) } +// SetArchived sets the "archived" field. +func (u *AttachmentUpsertBulk) SetArchived(v bool) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetArchived(v) + }) +} + +// UpdateArchived sets the "archived" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateArchived() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateArchived() + }) +} + +// SetArchivedAt sets the "archived_at" field. +func (u *AttachmentUpsertBulk) SetArchivedAt(v int64) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetArchivedAt(v) + }) +} + +// AddArchivedAt adds v to the "archived_at" field. +func (u *AttachmentUpsertBulk) AddArchivedAt(v int64) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.AddArchivedAt(v) + }) +} + +// UpdateArchivedAt sets the "archived_at" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateArchivedAt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateArchivedAt() + }) +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (u *AttachmentUpsertBulk) ClearArchivedAt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearArchivedAt() + }) +} + +// SetDeleted sets the "deleted" field. +func (u *AttachmentUpsertBulk) SetDeleted(v bool) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeleted(v) + }) +} + +// UpdateDeleted sets the "deleted" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateDeleted() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeleted() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *AttachmentUpsertBulk) SetDeletedAt(v int64) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeletedAt(v) + }) +} + +// AddDeletedAt adds v to the "deleted_at" field. +func (u *AttachmentUpsertBulk) AddDeletedAt(v int64) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.AddDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateDeletedAt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *AttachmentUpsertBulk) ClearDeletedAt() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearDeletedAt() + }) +} + +// SetDeletedBy sets the "deleted_by" field. +func (u *AttachmentUpsertBulk) SetDeletedBy(v string) *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.SetDeletedBy(v) + }) +} + +// UpdateDeletedBy sets the "deleted_by" field to the value that was provided on create. +func (u *AttachmentUpsertBulk) UpdateDeletedBy() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.UpdateDeletedBy() + }) +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (u *AttachmentUpsertBulk) ClearDeletedBy() *AttachmentUpsertBulk { + return u.Update(func(s *AttachmentUpsert) { + s.ClearDeletedBy() + }) +} + // SetCreatedAt sets the "created_at" field. func (u *AttachmentUpsertBulk) SetCreatedAt(v int64) *AttachmentUpsertBulk { return u.Update(func(s *AttachmentUpsert) { diff --git a/bj_power_wms/ent/attachment_update.go b/bj_power_wms/ent/attachment_update.go index 83eff27..b0c0c62 100644 --- a/bj_power_wms/ent/attachment_update.go +++ b/bj_power_wms/ent/attachment_update.go @@ -83,6 +83,66 @@ func (_u *AttachmentUpdate) SetNillableFilePath(v *string) *AttachmentUpdate { return _u } +// SetFileType sets the "file_type" field. +func (_u *AttachmentUpdate) SetFileType(v string) *AttachmentUpdate { + _u.mutation.SetFileType(v) + return _u +} + +// SetNillableFileType sets the "file_type" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileType(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileType(*v) + } + return _u +} + +// ClearFileType clears the value of the "file_type" field. +func (_u *AttachmentUpdate) ClearFileType() *AttachmentUpdate { + _u.mutation.ClearFileType() + return _u +} + +// SetFileExt sets the "file_ext" field. +func (_u *AttachmentUpdate) SetFileExt(v string) *AttachmentUpdate { + _u.mutation.SetFileExt(v) + return _u +} + +// SetNillableFileExt sets the "file_ext" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileExt(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileExt(*v) + } + return _u +} + +// ClearFileExt clears the value of the "file_ext" field. +func (_u *AttachmentUpdate) ClearFileExt() *AttachmentUpdate { + _u.mutation.ClearFileExt() + return _u +} + +// SetFileMd5 sets the "file_md5" field. +func (_u *AttachmentUpdate) SetFileMd5(v string) *AttachmentUpdate { + _u.mutation.SetFileMd5(v) + return _u +} + +// SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableFileMd5(v *string) *AttachmentUpdate { + if v != nil { + _u.SetFileMd5(*v) + } + return _u +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (_u *AttachmentUpdate) ClearFileMd5() *AttachmentUpdate { + _u.mutation.ClearFileMd5() + return _u +} + // SetFileSize sets the "file_size" field. func (_u *AttachmentUpdate) SetFileSize(v int64) *AttachmentUpdate { _u.mutation.ResetFileSize() @@ -144,6 +204,108 @@ func (_u *AttachmentUpdate) ClearUploadedBy() *AttachmentUpdate { return _u } +// SetArchived sets the "archived" field. +func (_u *AttachmentUpdate) SetArchived(v bool) *AttachmentUpdate { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableArchived(v *bool) *AttachmentUpdate { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetArchivedAt sets the "archived_at" field. +func (_u *AttachmentUpdate) SetArchivedAt(v int64) *AttachmentUpdate { + _u.mutation.ResetArchivedAt() + _u.mutation.SetArchivedAt(v) + return _u +} + +// SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableArchivedAt(v *int64) *AttachmentUpdate { + if v != nil { + _u.SetArchivedAt(*v) + } + return _u +} + +// AddArchivedAt adds value to the "archived_at" field. +func (_u *AttachmentUpdate) AddArchivedAt(v int64) *AttachmentUpdate { + _u.mutation.AddArchivedAt(v) + return _u +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (_u *AttachmentUpdate) ClearArchivedAt() *AttachmentUpdate { + _u.mutation.ClearArchivedAt() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *AttachmentUpdate) SetDeleted(v bool) *AttachmentUpdate { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeleted(v *bool) *AttachmentUpdate { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *AttachmentUpdate) SetDeletedAt(v int64) *AttachmentUpdate { + _u.mutation.ResetDeletedAt() + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeletedAt(v *int64) *AttachmentUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// AddDeletedAt adds value to the "deleted_at" field. +func (_u *AttachmentUpdate) AddDeletedAt(v int64) *AttachmentUpdate { + _u.mutation.AddDeletedAt(v) + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *AttachmentUpdate) ClearDeletedAt() *AttachmentUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetDeletedBy sets the "deleted_by" field. +func (_u *AttachmentUpdate) SetDeletedBy(v string) *AttachmentUpdate { + _u.mutation.SetDeletedBy(v) + return _u +} + +// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. +func (_u *AttachmentUpdate) SetNillableDeletedBy(v *string) *AttachmentUpdate { + if v != nil { + _u.SetDeletedBy(*v) + } + return _u +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (_u *AttachmentUpdate) ClearDeletedBy() *AttachmentUpdate { + _u.mutation.ClearDeletedBy() + return _u +} + // SetCreatedAt sets the "created_at" field. func (_u *AttachmentUpdate) SetCreatedAt(v int64) *AttachmentUpdate { _u.mutation.ResetCreatedAt() @@ -218,6 +380,24 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.FilePath(); ok { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) } + if value, ok := _u.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + } + if _u.mutation.FileTypeCleared() { + _spec.ClearField(attachment.FieldFileType, field.TypeString) + } + if value, ok := _u.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + } + if _u.mutation.FileExtCleared() { + _spec.ClearField(attachment.FieldFileExt, field.TypeString) + } + if value, ok := _u.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + } + if _u.mutation.FileMd5Cleared() { + _spec.ClearField(attachment.FieldFileMd5, field.TypeString) + } if value, ok := _u.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) } @@ -236,6 +416,36 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) if _u.mutation.UploadedByCleared() { _spec.ClearField(attachment.FieldUploadedBy, field.TypeString) } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedArchivedAt(); ok { + _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if _u.mutation.ArchivedAtCleared() { + _spec.ClearField(attachment.FieldArchivedAt, field.TypeInt64) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDeletedAt(); ok { + _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(attachment.FieldDeletedAt, field.TypeInt64) + } + if value, ok := _u.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + } + if _u.mutation.DeletedByCleared() { + _spec.ClearField(attachment.FieldDeletedBy, field.TypeString) + } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) } @@ -318,6 +528,66 @@ func (_u *AttachmentUpdateOne) SetNillableFilePath(v *string) *AttachmentUpdateO return _u } +// SetFileType sets the "file_type" field. +func (_u *AttachmentUpdateOne) SetFileType(v string) *AttachmentUpdateOne { + _u.mutation.SetFileType(v) + return _u +} + +// SetNillableFileType sets the "file_type" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileType(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileType(*v) + } + return _u +} + +// ClearFileType clears the value of the "file_type" field. +func (_u *AttachmentUpdateOne) ClearFileType() *AttachmentUpdateOne { + _u.mutation.ClearFileType() + return _u +} + +// SetFileExt sets the "file_ext" field. +func (_u *AttachmentUpdateOne) SetFileExt(v string) *AttachmentUpdateOne { + _u.mutation.SetFileExt(v) + return _u +} + +// SetNillableFileExt sets the "file_ext" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileExt(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileExt(*v) + } + return _u +} + +// ClearFileExt clears the value of the "file_ext" field. +func (_u *AttachmentUpdateOne) ClearFileExt() *AttachmentUpdateOne { + _u.mutation.ClearFileExt() + return _u +} + +// SetFileMd5 sets the "file_md5" field. +func (_u *AttachmentUpdateOne) SetFileMd5(v string) *AttachmentUpdateOne { + _u.mutation.SetFileMd5(v) + return _u +} + +// SetNillableFileMd5 sets the "file_md5" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableFileMd5(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetFileMd5(*v) + } + return _u +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (_u *AttachmentUpdateOne) ClearFileMd5() *AttachmentUpdateOne { + _u.mutation.ClearFileMd5() + return _u +} + // SetFileSize sets the "file_size" field. func (_u *AttachmentUpdateOne) SetFileSize(v int64) *AttachmentUpdateOne { _u.mutation.ResetFileSize() @@ -379,6 +649,108 @@ func (_u *AttachmentUpdateOne) ClearUploadedBy() *AttachmentUpdateOne { return _u } +// SetArchived sets the "archived" field. +func (_u *AttachmentUpdateOne) SetArchived(v bool) *AttachmentUpdateOne { + _u.mutation.SetArchived(v) + return _u +} + +// SetNillableArchived sets the "archived" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableArchived(v *bool) *AttachmentUpdateOne { + if v != nil { + _u.SetArchived(*v) + } + return _u +} + +// SetArchivedAt sets the "archived_at" field. +func (_u *AttachmentUpdateOne) SetArchivedAt(v int64) *AttachmentUpdateOne { + _u.mutation.ResetArchivedAt() + _u.mutation.SetArchivedAt(v) + return _u +} + +// SetNillableArchivedAt sets the "archived_at" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableArchivedAt(v *int64) *AttachmentUpdateOne { + if v != nil { + _u.SetArchivedAt(*v) + } + return _u +} + +// AddArchivedAt adds value to the "archived_at" field. +func (_u *AttachmentUpdateOne) AddArchivedAt(v int64) *AttachmentUpdateOne { + _u.mutation.AddArchivedAt(v) + return _u +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (_u *AttachmentUpdateOne) ClearArchivedAt() *AttachmentUpdateOne { + _u.mutation.ClearArchivedAt() + return _u +} + +// SetDeleted sets the "deleted" field. +func (_u *AttachmentUpdateOne) SetDeleted(v bool) *AttachmentUpdateOne { + _u.mutation.SetDeleted(v) + return _u +} + +// SetNillableDeleted sets the "deleted" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeleted(v *bool) *AttachmentUpdateOne { + if v != nil { + _u.SetDeleted(*v) + } + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *AttachmentUpdateOne) SetDeletedAt(v int64) *AttachmentUpdateOne { + _u.mutation.ResetDeletedAt() + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeletedAt(v *int64) *AttachmentUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// AddDeletedAt adds value to the "deleted_at" field. +func (_u *AttachmentUpdateOne) AddDeletedAt(v int64) *AttachmentUpdateOne { + _u.mutation.AddDeletedAt(v) + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *AttachmentUpdateOne) ClearDeletedAt() *AttachmentUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetDeletedBy sets the "deleted_by" field. +func (_u *AttachmentUpdateOne) SetDeletedBy(v string) *AttachmentUpdateOne { + _u.mutation.SetDeletedBy(v) + return _u +} + +// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil. +func (_u *AttachmentUpdateOne) SetNillableDeletedBy(v *string) *AttachmentUpdateOne { + if v != nil { + _u.SetDeletedBy(*v) + } + return _u +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (_u *AttachmentUpdateOne) ClearDeletedBy() *AttachmentUpdateOne { + _u.mutation.ClearDeletedBy() + return _u +} + // SetCreatedAt sets the "created_at" field. func (_u *AttachmentUpdateOne) SetCreatedAt(v int64) *AttachmentUpdateOne { _u.mutation.ResetCreatedAt() @@ -483,6 +855,24 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, if value, ok := _u.mutation.FilePath(); ok { _spec.SetField(attachment.FieldFilePath, field.TypeString, value) } + if value, ok := _u.mutation.FileType(); ok { + _spec.SetField(attachment.FieldFileType, field.TypeString, value) + } + if _u.mutation.FileTypeCleared() { + _spec.ClearField(attachment.FieldFileType, field.TypeString) + } + if value, ok := _u.mutation.FileExt(); ok { + _spec.SetField(attachment.FieldFileExt, field.TypeString, value) + } + if _u.mutation.FileExtCleared() { + _spec.ClearField(attachment.FieldFileExt, field.TypeString) + } + if value, ok := _u.mutation.FileMd5(); ok { + _spec.SetField(attachment.FieldFileMd5, field.TypeString, value) + } + if _u.mutation.FileMd5Cleared() { + _spec.ClearField(attachment.FieldFileMd5, field.TypeString) + } if value, ok := _u.mutation.FileSize(); ok { _spec.SetField(attachment.FieldFileSize, field.TypeInt64, value) } @@ -501,6 +891,36 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, if _u.mutation.UploadedByCleared() { _spec.ClearField(attachment.FieldUploadedBy, field.TypeString) } + if value, ok := _u.mutation.Archived(); ok { + _spec.SetField(attachment.FieldArchived, field.TypeBool, value) + } + if value, ok := _u.mutation.ArchivedAt(); ok { + _spec.SetField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedArchivedAt(); ok { + _spec.AddField(attachment.FieldArchivedAt, field.TypeInt64, value) + } + if _u.mutation.ArchivedAtCleared() { + _spec.ClearField(attachment.FieldArchivedAt, field.TypeInt64) + } + if value, ok := _u.mutation.Deleted(); ok { + _spec.SetField(attachment.FieldDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedDeletedAt(); ok { + _spec.AddField(attachment.FieldDeletedAt, field.TypeInt64, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(attachment.FieldDeletedAt, field.TypeInt64) + } + if value, ok := _u.mutation.DeletedBy(); ok { + _spec.SetField(attachment.FieldDeletedBy, field.TypeString, value) + } + if _u.mutation.DeletedByCleared() { + _spec.ClearField(attachment.FieldDeletedBy, field.TypeString) + } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(attachment.FieldCreatedAt, field.TypeInt64, value) } diff --git a/bj_power_wms/ent/dock.go b/bj_power_wms/ent/dock.go index 317da1c..8d9a357 100644 --- a/bj_power_wms/ent/dock.go +++ b/bj_power_wms/ent/dock.go @@ -20,9 +20,9 @@ type Dock struct { DockCode string `json:"dockCode,omitempty"` // 接驳台名称 Name string `json:"name,omitempty"` - // 类型 line产线/store库房 + // 类型 line产线/store库房/other其他 DockType string `json:"dockType,omitempty"` - // 关联工位号(产线 1..12),库房 0 + // 关联工位号(与工位1:1,非产线为0) StationNo int `json:"stationNo,omitempty"` // 当前是否有托盘 HasPallet bool `json:"hasPallet,omitempty"` diff --git a/bj_power_wms/ent/inboundorder.go b/bj_power_wms/ent/inboundorder.go index 4c489a0..53a465e 100644 --- a/bj_power_wms/ent/inboundorder.go +++ b/bj_power_wms/ent/inboundorder.go @@ -50,6 +50,14 @@ type InboundOrder struct { OwnershipNo string `json:"ownershipNo,omitempty"` // 质量状态 合格/不合格/部分(空=未关联检验) QualityStatus string `json:"qualityStatus,omitempty"` + // 是否已作废 + Voided bool `json:"voided,omitempty"` + // 作废原因 + VoidReason string `json:"voidReason,omitempty"` + // 作废人 + VoidedBy string `json:"voidedBy,omitempty"` + // 作废时间(unix秒) + VoidedAt int64 `json:"voidedAt,omitempty"` // 创建时间 CreatedAt int64 `json:"createdAt,omitempty"` selectValues sql.SelectValues @@ -60,9 +68,11 @@ func (*InboundOrder) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case inboundorder.FieldID, inboundorder.FieldManageMode, inboundorder.FieldQuantity, inboundorder.FieldCreatedAt: + case inboundorder.FieldVoided: + values[i] = new(sql.NullBool) + case inboundorder.FieldID, inboundorder.FieldManageMode, inboundorder.FieldQuantity, inboundorder.FieldVoidedAt, inboundorder.FieldCreatedAt: values[i] = new(sql.NullInt64) - case inboundorder.FieldInboundNo, inboundorder.FieldInboundType, inboundorder.FieldMaterialCode, inboundorder.FieldMaterialName, inboundorder.FieldBatchNo, inboundorder.FieldZoneCode, inboundorder.FieldShelfNo, inboundorder.FieldLayerNo, inboundorder.FieldPositionNo, inboundorder.FieldOperator, inboundorder.FieldRemark, inboundorder.FieldInspectionNo, inboundorder.FieldOwnershipType, inboundorder.FieldOwnershipNo, inboundorder.FieldQualityStatus: + case inboundorder.FieldInboundNo, inboundorder.FieldInboundType, inboundorder.FieldMaterialCode, inboundorder.FieldMaterialName, inboundorder.FieldBatchNo, inboundorder.FieldZoneCode, inboundorder.FieldShelfNo, inboundorder.FieldLayerNo, inboundorder.FieldPositionNo, inboundorder.FieldOperator, inboundorder.FieldRemark, inboundorder.FieldInspectionNo, inboundorder.FieldOwnershipType, inboundorder.FieldOwnershipNo, inboundorder.FieldQualityStatus, inboundorder.FieldVoidReason, inboundorder.FieldVoidedBy: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -187,6 +197,30 @@ func (_m *InboundOrder) assignValues(columns []string, values []any) error { } else if value.Valid { _m.QualityStatus = value.String } + case inboundorder.FieldVoided: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field voided", values[i]) + } else if value.Valid { + _m.Voided = value.Bool + } + case inboundorder.FieldVoidReason: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field void_reason", values[i]) + } else if value.Valid { + _m.VoidReason = value.String + } + case inboundorder.FieldVoidedBy: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field voided_by", values[i]) + } else if value.Valid { + _m.VoidedBy = value.String + } + case inboundorder.FieldVoidedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field voided_at", values[i]) + } else if value.Valid { + _m.VoidedAt = value.Int64 + } case inboundorder.FieldCreatedAt: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) @@ -280,6 +314,18 @@ func (_m *InboundOrder) String() string { builder.WriteString("quality_status=") builder.WriteString(_m.QualityStatus) builder.WriteString(", ") + builder.WriteString("voided=") + builder.WriteString(fmt.Sprintf("%v", _m.Voided)) + builder.WriteString(", ") + builder.WriteString("void_reason=") + builder.WriteString(_m.VoidReason) + builder.WriteString(", ") + builder.WriteString("voided_by=") + builder.WriteString(_m.VoidedBy) + builder.WriteString(", ") + builder.WriteString("voided_at=") + builder.WriteString(fmt.Sprintf("%v", _m.VoidedAt)) + builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt)) builder.WriteByte(')') diff --git a/bj_power_wms/ent/inboundorder/inboundorder.go b/bj_power_wms/ent/inboundorder/inboundorder.go index 2b93636..25f0dff 100644 --- a/bj_power_wms/ent/inboundorder/inboundorder.go +++ b/bj_power_wms/ent/inboundorder/inboundorder.go @@ -45,6 +45,14 @@ const ( FieldOwnershipNo = "ownership_no" // FieldQualityStatus holds the string denoting the quality_status field in the database. FieldQualityStatus = "quality_status" + // FieldVoided holds the string denoting the voided field in the database. + FieldVoided = "voided" + // FieldVoidReason holds the string denoting the void_reason field in the database. + FieldVoidReason = "void_reason" + // FieldVoidedBy holds the string denoting the voided_by field in the database. + FieldVoidedBy = "voided_by" + // FieldVoidedAt holds the string denoting the voided_at field in the database. + FieldVoidedAt = "voided_at" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // Table holds the table name of the inboundorder in the database. @@ -71,6 +79,10 @@ var Columns = []string{ FieldOwnershipType, FieldOwnershipNo, FieldQualityStatus, + FieldVoided, + FieldVoidReason, + FieldVoidedBy, + FieldVoidedAt, FieldCreatedAt, } @@ -93,6 +105,8 @@ var ( DefaultQuantity int // DefaultOwnershipType holds the default value on creation for the "ownership_type" field. DefaultOwnershipType string + // DefaultVoided holds the default value on creation for the "voided" field. + DefaultVoided bool // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() int64 ) @@ -190,6 +204,26 @@ func ByQualityStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldQualityStatus, opts...).ToFunc() } +// ByVoided orders the results by the voided field. +func ByVoided(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVoided, opts...).ToFunc() +} + +// ByVoidReason orders the results by the void_reason field. +func ByVoidReason(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVoidReason, opts...).ToFunc() +} + +// ByVoidedBy orders the results by the voided_by field. +func ByVoidedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVoidedBy, opts...).ToFunc() +} + +// ByVoidedAt orders the results by the voided_at field. +func ByVoidedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVoidedAt, opts...).ToFunc() +} + // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() diff --git a/bj_power_wms/ent/inboundorder/where.go b/bj_power_wms/ent/inboundorder/where.go index e589e62..8f9c298 100644 --- a/bj_power_wms/ent/inboundorder/where.go +++ b/bj_power_wms/ent/inboundorder/where.go @@ -138,6 +138,26 @@ func QualityStatus(v string) predicate.InboundOrder { return predicate.InboundOrder(sql.FieldEQ(FieldQualityStatus, v)) } +// Voided applies equality check predicate on the "voided" field. It's identical to VoidedEQ. +func Voided(v bool) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoided, v)) +} + +// VoidReason applies equality check predicate on the "void_reason" field. It's identical to VoidReasonEQ. +func VoidReason(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidReason, v)) +} + +// VoidedBy applies equality check predicate on the "voided_by" field. It's identical to VoidedByEQ. +func VoidedBy(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidedBy, v)) +} + +// VoidedAt applies equality check predicate on the "voided_at" field. It's identical to VoidedAtEQ. +func VoidedAt(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidedAt, v)) +} + // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. func CreatedAt(v int64) predicate.InboundOrder { return predicate.InboundOrder(sql.FieldEQ(FieldCreatedAt, v)) @@ -1298,6 +1318,216 @@ func QualityStatusContainsFold(v string) predicate.InboundOrder { return predicate.InboundOrder(sql.FieldContainsFold(FieldQualityStatus, v)) } +// VoidedEQ applies the EQ predicate on the "voided" field. +func VoidedEQ(v bool) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoided, v)) +} + +// VoidedNEQ applies the NEQ predicate on the "voided" field. +func VoidedNEQ(v bool) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNEQ(FieldVoided, v)) +} + +// VoidReasonEQ applies the EQ predicate on the "void_reason" field. +func VoidReasonEQ(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidReason, v)) +} + +// VoidReasonNEQ applies the NEQ predicate on the "void_reason" field. +func VoidReasonNEQ(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNEQ(FieldVoidReason, v)) +} + +// VoidReasonIn applies the In predicate on the "void_reason" field. +func VoidReasonIn(vs ...string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIn(FieldVoidReason, vs...)) +} + +// VoidReasonNotIn applies the NotIn predicate on the "void_reason" field. +func VoidReasonNotIn(vs ...string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotIn(FieldVoidReason, vs...)) +} + +// VoidReasonGT applies the GT predicate on the "void_reason" field. +func VoidReasonGT(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGT(FieldVoidReason, v)) +} + +// VoidReasonGTE applies the GTE predicate on the "void_reason" field. +func VoidReasonGTE(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGTE(FieldVoidReason, v)) +} + +// VoidReasonLT applies the LT predicate on the "void_reason" field. +func VoidReasonLT(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLT(FieldVoidReason, v)) +} + +// VoidReasonLTE applies the LTE predicate on the "void_reason" field. +func VoidReasonLTE(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLTE(FieldVoidReason, v)) +} + +// VoidReasonContains applies the Contains predicate on the "void_reason" field. +func VoidReasonContains(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldContains(FieldVoidReason, v)) +} + +// VoidReasonHasPrefix applies the HasPrefix predicate on the "void_reason" field. +func VoidReasonHasPrefix(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldHasPrefix(FieldVoidReason, v)) +} + +// VoidReasonHasSuffix applies the HasSuffix predicate on the "void_reason" field. +func VoidReasonHasSuffix(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldHasSuffix(FieldVoidReason, v)) +} + +// VoidReasonIsNil applies the IsNil predicate on the "void_reason" field. +func VoidReasonIsNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIsNull(FieldVoidReason)) +} + +// VoidReasonNotNil applies the NotNil predicate on the "void_reason" field. +func VoidReasonNotNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotNull(FieldVoidReason)) +} + +// VoidReasonEqualFold applies the EqualFold predicate on the "void_reason" field. +func VoidReasonEqualFold(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEqualFold(FieldVoidReason, v)) +} + +// VoidReasonContainsFold applies the ContainsFold predicate on the "void_reason" field. +func VoidReasonContainsFold(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldContainsFold(FieldVoidReason, v)) +} + +// VoidedByEQ applies the EQ predicate on the "voided_by" field. +func VoidedByEQ(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidedBy, v)) +} + +// VoidedByNEQ applies the NEQ predicate on the "voided_by" field. +func VoidedByNEQ(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNEQ(FieldVoidedBy, v)) +} + +// VoidedByIn applies the In predicate on the "voided_by" field. +func VoidedByIn(vs ...string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIn(FieldVoidedBy, vs...)) +} + +// VoidedByNotIn applies the NotIn predicate on the "voided_by" field. +func VoidedByNotIn(vs ...string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotIn(FieldVoidedBy, vs...)) +} + +// VoidedByGT applies the GT predicate on the "voided_by" field. +func VoidedByGT(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGT(FieldVoidedBy, v)) +} + +// VoidedByGTE applies the GTE predicate on the "voided_by" field. +func VoidedByGTE(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGTE(FieldVoidedBy, v)) +} + +// VoidedByLT applies the LT predicate on the "voided_by" field. +func VoidedByLT(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLT(FieldVoidedBy, v)) +} + +// VoidedByLTE applies the LTE predicate on the "voided_by" field. +func VoidedByLTE(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLTE(FieldVoidedBy, v)) +} + +// VoidedByContains applies the Contains predicate on the "voided_by" field. +func VoidedByContains(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldContains(FieldVoidedBy, v)) +} + +// VoidedByHasPrefix applies the HasPrefix predicate on the "voided_by" field. +func VoidedByHasPrefix(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldHasPrefix(FieldVoidedBy, v)) +} + +// VoidedByHasSuffix applies the HasSuffix predicate on the "voided_by" field. +func VoidedByHasSuffix(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldHasSuffix(FieldVoidedBy, v)) +} + +// VoidedByIsNil applies the IsNil predicate on the "voided_by" field. +func VoidedByIsNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIsNull(FieldVoidedBy)) +} + +// VoidedByNotNil applies the NotNil predicate on the "voided_by" field. +func VoidedByNotNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotNull(FieldVoidedBy)) +} + +// VoidedByEqualFold applies the EqualFold predicate on the "voided_by" field. +func VoidedByEqualFold(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEqualFold(FieldVoidedBy, v)) +} + +// VoidedByContainsFold applies the ContainsFold predicate on the "voided_by" field. +func VoidedByContainsFold(v string) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldContainsFold(FieldVoidedBy, v)) +} + +// VoidedAtEQ applies the EQ predicate on the "voided_at" field. +func VoidedAtEQ(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldEQ(FieldVoidedAt, v)) +} + +// VoidedAtNEQ applies the NEQ predicate on the "voided_at" field. +func VoidedAtNEQ(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNEQ(FieldVoidedAt, v)) +} + +// VoidedAtIn applies the In predicate on the "voided_at" field. +func VoidedAtIn(vs ...int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIn(FieldVoidedAt, vs...)) +} + +// VoidedAtNotIn applies the NotIn predicate on the "voided_at" field. +func VoidedAtNotIn(vs ...int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotIn(FieldVoidedAt, vs...)) +} + +// VoidedAtGT applies the GT predicate on the "voided_at" field. +func VoidedAtGT(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGT(FieldVoidedAt, v)) +} + +// VoidedAtGTE applies the GTE predicate on the "voided_at" field. +func VoidedAtGTE(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldGTE(FieldVoidedAt, v)) +} + +// VoidedAtLT applies the LT predicate on the "voided_at" field. +func VoidedAtLT(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLT(FieldVoidedAt, v)) +} + +// VoidedAtLTE applies the LTE predicate on the "voided_at" field. +func VoidedAtLTE(v int64) predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldLTE(FieldVoidedAt, v)) +} + +// VoidedAtIsNil applies the IsNil predicate on the "voided_at" field. +func VoidedAtIsNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldIsNull(FieldVoidedAt)) +} + +// VoidedAtNotNil applies the NotNil predicate on the "voided_at" field. +func VoidedAtNotNil() predicate.InboundOrder { + return predicate.InboundOrder(sql.FieldNotNull(FieldVoidedAt)) +} + // CreatedAtEQ applies the EQ predicate on the "created_at" field. func CreatedAtEQ(v int64) predicate.InboundOrder { return predicate.InboundOrder(sql.FieldEQ(FieldCreatedAt, v)) diff --git a/bj_power_wms/ent/inboundorder_create.go b/bj_power_wms/ent/inboundorder_create.go index 3f8d3a2..feb7cae 100644 --- a/bj_power_wms/ent/inboundorder_create.go +++ b/bj_power_wms/ent/inboundorder_create.go @@ -235,6 +235,62 @@ func (_c *InboundOrderCreate) SetNillableQualityStatus(v *string) *InboundOrderC return _c } +// SetVoided sets the "voided" field. +func (_c *InboundOrderCreate) SetVoided(v bool) *InboundOrderCreate { + _c.mutation.SetVoided(v) + return _c +} + +// SetNillableVoided sets the "voided" field if the given value is not nil. +func (_c *InboundOrderCreate) SetNillableVoided(v *bool) *InboundOrderCreate { + if v != nil { + _c.SetVoided(*v) + } + return _c +} + +// SetVoidReason sets the "void_reason" field. +func (_c *InboundOrderCreate) SetVoidReason(v string) *InboundOrderCreate { + _c.mutation.SetVoidReason(v) + return _c +} + +// SetNillableVoidReason sets the "void_reason" field if the given value is not nil. +func (_c *InboundOrderCreate) SetNillableVoidReason(v *string) *InboundOrderCreate { + if v != nil { + _c.SetVoidReason(*v) + } + return _c +} + +// SetVoidedBy sets the "voided_by" field. +func (_c *InboundOrderCreate) SetVoidedBy(v string) *InboundOrderCreate { + _c.mutation.SetVoidedBy(v) + return _c +} + +// SetNillableVoidedBy sets the "voided_by" field if the given value is not nil. +func (_c *InboundOrderCreate) SetNillableVoidedBy(v *string) *InboundOrderCreate { + if v != nil { + _c.SetVoidedBy(*v) + } + return _c +} + +// SetVoidedAt sets the "voided_at" field. +func (_c *InboundOrderCreate) SetVoidedAt(v int64) *InboundOrderCreate { + _c.mutation.SetVoidedAt(v) + return _c +} + +// SetNillableVoidedAt sets the "voided_at" field if the given value is not nil. +func (_c *InboundOrderCreate) SetNillableVoidedAt(v *int64) *InboundOrderCreate { + if v != nil { + _c.SetVoidedAt(*v) + } + return _c +} + // SetCreatedAt sets the "created_at" field. func (_c *InboundOrderCreate) SetCreatedAt(v int64) *InboundOrderCreate { _c.mutation.SetCreatedAt(v) @@ -300,6 +356,10 @@ func (_c *InboundOrderCreate) defaults() { v := inboundorder.DefaultOwnershipType _c.mutation.SetOwnershipType(v) } + if _, ok := _c.mutation.Voided(); !ok { + v := inboundorder.DefaultVoided + _c.mutation.SetVoided(v) + } if _, ok := _c.mutation.CreatedAt(); !ok { v := inboundorder.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) @@ -329,6 +389,9 @@ func (_c *InboundOrderCreate) check() error { if _, ok := _c.mutation.OwnershipType(); !ok { return &ValidationError{Name: "ownership_type", err: errors.New(`ent: missing required field "InboundOrder.ownership_type"`)} } + if _, ok := _c.mutation.Voided(); !ok { + return &ValidationError{Name: "voided", err: errors.New(`ent: missing required field "InboundOrder.voided"`)} + } if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "InboundOrder.created_at"`)} } @@ -427,6 +490,22 @@ func (_c *InboundOrderCreate) createSpec() (*InboundOrder, *sqlgraph.CreateSpec) _spec.SetField(inboundorder.FieldQualityStatus, field.TypeString, value) _node.QualityStatus = value } + if value, ok := _c.mutation.Voided(); ok { + _spec.SetField(inboundorder.FieldVoided, field.TypeBool, value) + _node.Voided = value + } + if value, ok := _c.mutation.VoidReason(); ok { + _spec.SetField(inboundorder.FieldVoidReason, field.TypeString, value) + _node.VoidReason = value + } + if value, ok := _c.mutation.VoidedBy(); ok { + _spec.SetField(inboundorder.FieldVoidedBy, field.TypeString, value) + _node.VoidedBy = value + } + if value, ok := _c.mutation.VoidedAt(); ok { + _spec.SetField(inboundorder.FieldVoidedAt, field.TypeInt64, value) + _node.VoidedAt = value + } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(inboundorder.FieldCreatedAt, field.TypeInt64, value) _node.CreatedAt = value @@ -759,6 +838,78 @@ func (u *InboundOrderUpsert) ClearQualityStatus() *InboundOrderUpsert { return u } +// SetVoided sets the "voided" field. +func (u *InboundOrderUpsert) SetVoided(v bool) *InboundOrderUpsert { + u.Set(inboundorder.FieldVoided, v) + return u +} + +// UpdateVoided sets the "voided" field to the value that was provided on create. +func (u *InboundOrderUpsert) UpdateVoided() *InboundOrderUpsert { + u.SetExcluded(inboundorder.FieldVoided) + return u +} + +// SetVoidReason sets the "void_reason" field. +func (u *InboundOrderUpsert) SetVoidReason(v string) *InboundOrderUpsert { + u.Set(inboundorder.FieldVoidReason, v) + return u +} + +// UpdateVoidReason sets the "void_reason" field to the value that was provided on create. +func (u *InboundOrderUpsert) UpdateVoidReason() *InboundOrderUpsert { + u.SetExcluded(inboundorder.FieldVoidReason) + return u +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (u *InboundOrderUpsert) ClearVoidReason() *InboundOrderUpsert { + u.SetNull(inboundorder.FieldVoidReason) + return u +} + +// SetVoidedBy sets the "voided_by" field. +func (u *InboundOrderUpsert) SetVoidedBy(v string) *InboundOrderUpsert { + u.Set(inboundorder.FieldVoidedBy, v) + return u +} + +// UpdateVoidedBy sets the "voided_by" field to the value that was provided on create. +func (u *InboundOrderUpsert) UpdateVoidedBy() *InboundOrderUpsert { + u.SetExcluded(inboundorder.FieldVoidedBy) + return u +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (u *InboundOrderUpsert) ClearVoidedBy() *InboundOrderUpsert { + u.SetNull(inboundorder.FieldVoidedBy) + return u +} + +// SetVoidedAt sets the "voided_at" field. +func (u *InboundOrderUpsert) SetVoidedAt(v int64) *InboundOrderUpsert { + u.Set(inboundorder.FieldVoidedAt, v) + return u +} + +// UpdateVoidedAt sets the "voided_at" field to the value that was provided on create. +func (u *InboundOrderUpsert) UpdateVoidedAt() *InboundOrderUpsert { + u.SetExcluded(inboundorder.FieldVoidedAt) + return u +} + +// AddVoidedAt adds v to the "voided_at" field. +func (u *InboundOrderUpsert) AddVoidedAt(v int64) *InboundOrderUpsert { + u.Add(inboundorder.FieldVoidedAt, v) + return u +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (u *InboundOrderUpsert) ClearVoidedAt() *InboundOrderUpsert { + u.SetNull(inboundorder.FieldVoidedAt) + return u +} + // SetCreatedAt sets the "created_at" field. func (u *InboundOrderUpsert) SetCreatedAt(v int64) *InboundOrderUpsert { u.Set(inboundorder.FieldCreatedAt, v) @@ -1139,6 +1290,90 @@ func (u *InboundOrderUpsertOne) ClearQualityStatus() *InboundOrderUpsertOne { }) } +// SetVoided sets the "voided" field. +func (u *InboundOrderUpsertOne) SetVoided(v bool) *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoided(v) + }) +} + +// UpdateVoided sets the "voided" field to the value that was provided on create. +func (u *InboundOrderUpsertOne) UpdateVoided() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoided() + }) +} + +// SetVoidReason sets the "void_reason" field. +func (u *InboundOrderUpsertOne) SetVoidReason(v string) *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidReason(v) + }) +} + +// UpdateVoidReason sets the "void_reason" field to the value that was provided on create. +func (u *InboundOrderUpsertOne) UpdateVoidReason() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidReason() + }) +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (u *InboundOrderUpsertOne) ClearVoidReason() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidReason() + }) +} + +// SetVoidedBy sets the "voided_by" field. +func (u *InboundOrderUpsertOne) SetVoidedBy(v string) *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidedBy(v) + }) +} + +// UpdateVoidedBy sets the "voided_by" field to the value that was provided on create. +func (u *InboundOrderUpsertOne) UpdateVoidedBy() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidedBy() + }) +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (u *InboundOrderUpsertOne) ClearVoidedBy() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidedBy() + }) +} + +// SetVoidedAt sets the "voided_at" field. +func (u *InboundOrderUpsertOne) SetVoidedAt(v int64) *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidedAt(v) + }) +} + +// AddVoidedAt adds v to the "voided_at" field. +func (u *InboundOrderUpsertOne) AddVoidedAt(v int64) *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.AddVoidedAt(v) + }) +} + +// UpdateVoidedAt sets the "voided_at" field to the value that was provided on create. +func (u *InboundOrderUpsertOne) UpdateVoidedAt() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidedAt() + }) +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (u *InboundOrderUpsertOne) ClearVoidedAt() *InboundOrderUpsertOne { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidedAt() + }) +} + // SetCreatedAt sets the "created_at" field. func (u *InboundOrderUpsertOne) SetCreatedAt(v int64) *InboundOrderUpsertOne { return u.Update(func(s *InboundOrderUpsert) { @@ -1686,6 +1921,90 @@ func (u *InboundOrderUpsertBulk) ClearQualityStatus() *InboundOrderUpsertBulk { }) } +// SetVoided sets the "voided" field. +func (u *InboundOrderUpsertBulk) SetVoided(v bool) *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoided(v) + }) +} + +// UpdateVoided sets the "voided" field to the value that was provided on create. +func (u *InboundOrderUpsertBulk) UpdateVoided() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoided() + }) +} + +// SetVoidReason sets the "void_reason" field. +func (u *InboundOrderUpsertBulk) SetVoidReason(v string) *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidReason(v) + }) +} + +// UpdateVoidReason sets the "void_reason" field to the value that was provided on create. +func (u *InboundOrderUpsertBulk) UpdateVoidReason() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidReason() + }) +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (u *InboundOrderUpsertBulk) ClearVoidReason() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidReason() + }) +} + +// SetVoidedBy sets the "voided_by" field. +func (u *InboundOrderUpsertBulk) SetVoidedBy(v string) *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidedBy(v) + }) +} + +// UpdateVoidedBy sets the "voided_by" field to the value that was provided on create. +func (u *InboundOrderUpsertBulk) UpdateVoidedBy() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidedBy() + }) +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (u *InboundOrderUpsertBulk) ClearVoidedBy() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidedBy() + }) +} + +// SetVoidedAt sets the "voided_at" field. +func (u *InboundOrderUpsertBulk) SetVoidedAt(v int64) *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.SetVoidedAt(v) + }) +} + +// AddVoidedAt adds v to the "voided_at" field. +func (u *InboundOrderUpsertBulk) AddVoidedAt(v int64) *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.AddVoidedAt(v) + }) +} + +// UpdateVoidedAt sets the "voided_at" field to the value that was provided on create. +func (u *InboundOrderUpsertBulk) UpdateVoidedAt() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.UpdateVoidedAt() + }) +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (u *InboundOrderUpsertBulk) ClearVoidedAt() *InboundOrderUpsertBulk { + return u.Update(func(s *InboundOrderUpsert) { + s.ClearVoidedAt() + }) +} + // SetCreatedAt sets the "created_at" field. func (u *InboundOrderUpsertBulk) SetCreatedAt(v int64) *InboundOrderUpsertBulk { return u.Update(func(s *InboundOrderUpsert) { diff --git a/bj_power_wms/ent/inboundorder_update.go b/bj_power_wms/ent/inboundorder_update.go index 5f6080f..ccaa49f 100644 --- a/bj_power_wms/ent/inboundorder_update.go +++ b/bj_power_wms/ent/inboundorder_update.go @@ -339,6 +339,87 @@ func (_u *InboundOrderUpdate) ClearQualityStatus() *InboundOrderUpdate { return _u } +// SetVoided sets the "voided" field. +func (_u *InboundOrderUpdate) SetVoided(v bool) *InboundOrderUpdate { + _u.mutation.SetVoided(v) + return _u +} + +// SetNillableVoided sets the "voided" field if the given value is not nil. +func (_u *InboundOrderUpdate) SetNillableVoided(v *bool) *InboundOrderUpdate { + if v != nil { + _u.SetVoided(*v) + } + return _u +} + +// SetVoidReason sets the "void_reason" field. +func (_u *InboundOrderUpdate) SetVoidReason(v string) *InboundOrderUpdate { + _u.mutation.SetVoidReason(v) + return _u +} + +// SetNillableVoidReason sets the "void_reason" field if the given value is not nil. +func (_u *InboundOrderUpdate) SetNillableVoidReason(v *string) *InboundOrderUpdate { + if v != nil { + _u.SetVoidReason(*v) + } + return _u +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (_u *InboundOrderUpdate) ClearVoidReason() *InboundOrderUpdate { + _u.mutation.ClearVoidReason() + return _u +} + +// SetVoidedBy sets the "voided_by" field. +func (_u *InboundOrderUpdate) SetVoidedBy(v string) *InboundOrderUpdate { + _u.mutation.SetVoidedBy(v) + return _u +} + +// SetNillableVoidedBy sets the "voided_by" field if the given value is not nil. +func (_u *InboundOrderUpdate) SetNillableVoidedBy(v *string) *InboundOrderUpdate { + if v != nil { + _u.SetVoidedBy(*v) + } + return _u +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (_u *InboundOrderUpdate) ClearVoidedBy() *InboundOrderUpdate { + _u.mutation.ClearVoidedBy() + return _u +} + +// SetVoidedAt sets the "voided_at" field. +func (_u *InboundOrderUpdate) SetVoidedAt(v int64) *InboundOrderUpdate { + _u.mutation.ResetVoidedAt() + _u.mutation.SetVoidedAt(v) + return _u +} + +// SetNillableVoidedAt sets the "voided_at" field if the given value is not nil. +func (_u *InboundOrderUpdate) SetNillableVoidedAt(v *int64) *InboundOrderUpdate { + if v != nil { + _u.SetVoidedAt(*v) + } + return _u +} + +// AddVoidedAt adds value to the "voided_at" field. +func (_u *InboundOrderUpdate) AddVoidedAt(v int64) *InboundOrderUpdate { + _u.mutation.AddVoidedAt(v) + return _u +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (_u *InboundOrderUpdate) ClearVoidedAt() *InboundOrderUpdate { + _u.mutation.ClearVoidedAt() + return _u +} + // SetCreatedAt sets the "created_at" field. func (_u *InboundOrderUpdate) SetCreatedAt(v int64) *InboundOrderUpdate { _u.mutation.ResetCreatedAt() @@ -488,6 +569,30 @@ func (_u *InboundOrderUpdate) sqlSave(ctx context.Context) (_node int, err error if _u.mutation.QualityStatusCleared() { _spec.ClearField(inboundorder.FieldQualityStatus, field.TypeString) } + if value, ok := _u.mutation.Voided(); ok { + _spec.SetField(inboundorder.FieldVoided, field.TypeBool, value) + } + if value, ok := _u.mutation.VoidReason(); ok { + _spec.SetField(inboundorder.FieldVoidReason, field.TypeString, value) + } + if _u.mutation.VoidReasonCleared() { + _spec.ClearField(inboundorder.FieldVoidReason, field.TypeString) + } + if value, ok := _u.mutation.VoidedBy(); ok { + _spec.SetField(inboundorder.FieldVoidedBy, field.TypeString, value) + } + if _u.mutation.VoidedByCleared() { + _spec.ClearField(inboundorder.FieldVoidedBy, field.TypeString) + } + if value, ok := _u.mutation.VoidedAt(); ok { + _spec.SetField(inboundorder.FieldVoidedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedVoidedAt(); ok { + _spec.AddField(inboundorder.FieldVoidedAt, field.TypeInt64, value) + } + if _u.mutation.VoidedAtCleared() { + _spec.ClearField(inboundorder.FieldVoidedAt, field.TypeInt64) + } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(inboundorder.FieldCreatedAt, field.TypeInt64, value) } @@ -826,6 +931,87 @@ func (_u *InboundOrderUpdateOne) ClearQualityStatus() *InboundOrderUpdateOne { return _u } +// SetVoided sets the "voided" field. +func (_u *InboundOrderUpdateOne) SetVoided(v bool) *InboundOrderUpdateOne { + _u.mutation.SetVoided(v) + return _u +} + +// SetNillableVoided sets the "voided" field if the given value is not nil. +func (_u *InboundOrderUpdateOne) SetNillableVoided(v *bool) *InboundOrderUpdateOne { + if v != nil { + _u.SetVoided(*v) + } + return _u +} + +// SetVoidReason sets the "void_reason" field. +func (_u *InboundOrderUpdateOne) SetVoidReason(v string) *InboundOrderUpdateOne { + _u.mutation.SetVoidReason(v) + return _u +} + +// SetNillableVoidReason sets the "void_reason" field if the given value is not nil. +func (_u *InboundOrderUpdateOne) SetNillableVoidReason(v *string) *InboundOrderUpdateOne { + if v != nil { + _u.SetVoidReason(*v) + } + return _u +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (_u *InboundOrderUpdateOne) ClearVoidReason() *InboundOrderUpdateOne { + _u.mutation.ClearVoidReason() + return _u +} + +// SetVoidedBy sets the "voided_by" field. +func (_u *InboundOrderUpdateOne) SetVoidedBy(v string) *InboundOrderUpdateOne { + _u.mutation.SetVoidedBy(v) + return _u +} + +// SetNillableVoidedBy sets the "voided_by" field if the given value is not nil. +func (_u *InboundOrderUpdateOne) SetNillableVoidedBy(v *string) *InboundOrderUpdateOne { + if v != nil { + _u.SetVoidedBy(*v) + } + return _u +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (_u *InboundOrderUpdateOne) ClearVoidedBy() *InboundOrderUpdateOne { + _u.mutation.ClearVoidedBy() + return _u +} + +// SetVoidedAt sets the "voided_at" field. +func (_u *InboundOrderUpdateOne) SetVoidedAt(v int64) *InboundOrderUpdateOne { + _u.mutation.ResetVoidedAt() + _u.mutation.SetVoidedAt(v) + return _u +} + +// SetNillableVoidedAt sets the "voided_at" field if the given value is not nil. +func (_u *InboundOrderUpdateOne) SetNillableVoidedAt(v *int64) *InboundOrderUpdateOne { + if v != nil { + _u.SetVoidedAt(*v) + } + return _u +} + +// AddVoidedAt adds value to the "voided_at" field. +func (_u *InboundOrderUpdateOne) AddVoidedAt(v int64) *InboundOrderUpdateOne { + _u.mutation.AddVoidedAt(v) + return _u +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (_u *InboundOrderUpdateOne) ClearVoidedAt() *InboundOrderUpdateOne { + _u.mutation.ClearVoidedAt() + return _u +} + // SetCreatedAt sets the "created_at" field. func (_u *InboundOrderUpdateOne) SetCreatedAt(v int64) *InboundOrderUpdateOne { _u.mutation.ResetCreatedAt() @@ -1005,6 +1191,30 @@ func (_u *InboundOrderUpdateOne) sqlSave(ctx context.Context) (_node *InboundOrd if _u.mutation.QualityStatusCleared() { _spec.ClearField(inboundorder.FieldQualityStatus, field.TypeString) } + if value, ok := _u.mutation.Voided(); ok { + _spec.SetField(inboundorder.FieldVoided, field.TypeBool, value) + } + if value, ok := _u.mutation.VoidReason(); ok { + _spec.SetField(inboundorder.FieldVoidReason, field.TypeString, value) + } + if _u.mutation.VoidReasonCleared() { + _spec.ClearField(inboundorder.FieldVoidReason, field.TypeString) + } + if value, ok := _u.mutation.VoidedBy(); ok { + _spec.SetField(inboundorder.FieldVoidedBy, field.TypeString, value) + } + if _u.mutation.VoidedByCleared() { + _spec.ClearField(inboundorder.FieldVoidedBy, field.TypeString) + } + if value, ok := _u.mutation.VoidedAt(); ok { + _spec.SetField(inboundorder.FieldVoidedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedVoidedAt(); ok { + _spec.AddField(inboundorder.FieldVoidedAt, field.TypeInt64, value) + } + if _u.mutation.VoidedAtCleared() { + _spec.ClearField(inboundorder.FieldVoidedAt, field.TypeInt64) + } if value, ok := _u.mutation.CreatedAt(); ok { _spec.SetField(inboundorder.FieldCreatedAt, field.TypeInt64, value) } diff --git a/bj_power_wms/ent/material.go b/bj_power_wms/ent/material.go index e196ee3..d177808 100644 --- a/bj_power_wms/ent/material.go +++ b/bj_power_wms/ent/material.go @@ -20,8 +20,6 @@ type Material struct { Code string `json:"code,omitempty"` // 物料真实名称 Name string `json:"name,omitempty"` - // 简称 - ShortName string `json:"shortName,omitempty"` // 规格型号 Spec string `json:"spec,omitempty"` // 单位 @@ -58,7 +56,7 @@ func (*Material) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case material.FieldID, material.FieldItemType, material.FieldManageMode, material.FieldSafetyStock, material.FieldCreatedAt, material.FieldUpdatedAt: values[i] = new(sql.NullInt64) - case material.FieldCode, material.FieldName, material.FieldShortName, material.FieldSpec, material.FieldUnit, material.FieldDescription, material.FieldTemplateCode: + case material.FieldCode, material.FieldName, material.FieldSpec, material.FieldUnit, material.FieldDescription, material.FieldTemplateCode: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -93,12 +91,6 @@ func (_m *Material) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Name = value.String } - case material.FieldShortName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field short_name", values[i]) - } else if value.Valid { - _m.ShortName = value.String - } case material.FieldSpec: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field spec", values[i]) @@ -213,9 +205,6 @@ func (_m *Material) String() string { builder.WriteString("name=") builder.WriteString(_m.Name) builder.WriteString(", ") - builder.WriteString("short_name=") - builder.WriteString(_m.ShortName) - builder.WriteString(", ") builder.WriteString("spec=") builder.WriteString(_m.Spec) builder.WriteString(", ") diff --git a/bj_power_wms/ent/material/material.go b/bj_power_wms/ent/material/material.go index 8f378f5..f990ce7 100644 --- a/bj_power_wms/ent/material/material.go +++ b/bj_power_wms/ent/material/material.go @@ -15,8 +15,6 @@ const ( FieldCode = "code" // FieldName holds the string denoting the name field in the database. FieldName = "name" - // FieldShortName holds the string denoting the short_name field in the database. - FieldShortName = "short_name" // FieldSpec holds the string denoting the spec field in the database. FieldSpec = "spec" // FieldUnit holds the string denoting the unit field in the database. @@ -50,7 +48,6 @@ var Columns = []string{ FieldID, FieldCode, FieldName, - FieldShortName, FieldSpec, FieldUnit, FieldDescription, @@ -112,11 +109,6 @@ func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() } -// ByShortName orders the results by the short_name field. -func ByShortName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldShortName, opts...).ToFunc() -} - // BySpec orders the results by the spec field. func BySpec(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSpec, opts...).ToFunc() diff --git a/bj_power_wms/ent/material/where.go b/bj_power_wms/ent/material/where.go index 4c608e1..9dcd3b0 100644 --- a/bj_power_wms/ent/material/where.go +++ b/bj_power_wms/ent/material/where.go @@ -63,11 +63,6 @@ func Name(v string) predicate.Material { return predicate.Material(sql.FieldEQ(FieldName, v)) } -// ShortName applies equality check predicate on the "short_name" field. It's identical to ShortNameEQ. -func ShortName(v string) predicate.Material { - return predicate.Material(sql.FieldEQ(FieldShortName, v)) -} - // Spec applies equality check predicate on the "spec" field. It's identical to SpecEQ. func Spec(v string) predicate.Material { return predicate.Material(sql.FieldEQ(FieldSpec, v)) @@ -258,81 +253,6 @@ func NameContainsFold(v string) predicate.Material { return predicate.Material(sql.FieldContainsFold(FieldName, v)) } -// ShortNameEQ applies the EQ predicate on the "short_name" field. -func ShortNameEQ(v string) predicate.Material { - return predicate.Material(sql.FieldEQ(FieldShortName, v)) -} - -// ShortNameNEQ applies the NEQ predicate on the "short_name" field. -func ShortNameNEQ(v string) predicate.Material { - return predicate.Material(sql.FieldNEQ(FieldShortName, v)) -} - -// ShortNameIn applies the In predicate on the "short_name" field. -func ShortNameIn(vs ...string) predicate.Material { - return predicate.Material(sql.FieldIn(FieldShortName, vs...)) -} - -// ShortNameNotIn applies the NotIn predicate on the "short_name" field. -func ShortNameNotIn(vs ...string) predicate.Material { - return predicate.Material(sql.FieldNotIn(FieldShortName, vs...)) -} - -// ShortNameGT applies the GT predicate on the "short_name" field. -func ShortNameGT(v string) predicate.Material { - return predicate.Material(sql.FieldGT(FieldShortName, v)) -} - -// ShortNameGTE applies the GTE predicate on the "short_name" field. -func ShortNameGTE(v string) predicate.Material { - return predicate.Material(sql.FieldGTE(FieldShortName, v)) -} - -// ShortNameLT applies the LT predicate on the "short_name" field. -func ShortNameLT(v string) predicate.Material { - return predicate.Material(sql.FieldLT(FieldShortName, v)) -} - -// ShortNameLTE applies the LTE predicate on the "short_name" field. -func ShortNameLTE(v string) predicate.Material { - return predicate.Material(sql.FieldLTE(FieldShortName, v)) -} - -// ShortNameContains applies the Contains predicate on the "short_name" field. -func ShortNameContains(v string) predicate.Material { - return predicate.Material(sql.FieldContains(FieldShortName, v)) -} - -// ShortNameHasPrefix applies the HasPrefix predicate on the "short_name" field. -func ShortNameHasPrefix(v string) predicate.Material { - return predicate.Material(sql.FieldHasPrefix(FieldShortName, v)) -} - -// ShortNameHasSuffix applies the HasSuffix predicate on the "short_name" field. -func ShortNameHasSuffix(v string) predicate.Material { - return predicate.Material(sql.FieldHasSuffix(FieldShortName, v)) -} - -// ShortNameIsNil applies the IsNil predicate on the "short_name" field. -func ShortNameIsNil() predicate.Material { - return predicate.Material(sql.FieldIsNull(FieldShortName)) -} - -// ShortNameNotNil applies the NotNil predicate on the "short_name" field. -func ShortNameNotNil() predicate.Material { - return predicate.Material(sql.FieldNotNull(FieldShortName)) -} - -// ShortNameEqualFold applies the EqualFold predicate on the "short_name" field. -func ShortNameEqualFold(v string) predicate.Material { - return predicate.Material(sql.FieldEqualFold(FieldShortName, v)) -} - -// ShortNameContainsFold applies the ContainsFold predicate on the "short_name" field. -func ShortNameContainsFold(v string) predicate.Material { - return predicate.Material(sql.FieldContainsFold(FieldShortName, v)) -} - // SpecEQ applies the EQ predicate on the "spec" field. func SpecEQ(v string) predicate.Material { return predicate.Material(sql.FieldEQ(FieldSpec, v)) diff --git a/bj_power_wms/ent/material_create.go b/bj_power_wms/ent/material_create.go index 599482c..1197d00 100644 --- a/bj_power_wms/ent/material_create.go +++ b/bj_power_wms/ent/material_create.go @@ -33,20 +33,6 @@ func (_c *MaterialCreate) SetName(v string) *MaterialCreate { return _c } -// SetShortName sets the "short_name" field. -func (_c *MaterialCreate) SetShortName(v string) *MaterialCreate { - _c.mutation.SetShortName(v) - return _c -} - -// SetNillableShortName sets the "short_name" field if the given value is not nil. -func (_c *MaterialCreate) SetNillableShortName(v *string) *MaterialCreate { - if v != nil { - _c.SetShortName(*v) - } - return _c -} - // SetSpec sets the "spec" field. func (_c *MaterialCreate) SetSpec(v string) *MaterialCreate { _c.mutation.SetSpec(v) @@ -351,10 +337,6 @@ func (_c *MaterialCreate) createSpec() (*Material, *sqlgraph.CreateSpec) { _spec.SetField(material.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := _c.mutation.ShortName(); ok { - _spec.SetField(material.FieldShortName, field.TypeString, value) - _node.ShortName = value - } if value, ok := _c.mutation.Spec(); ok { _spec.SetField(material.FieldSpec, field.TypeString, value) _node.Spec = value @@ -479,24 +461,6 @@ func (u *MaterialUpsert) UpdateName() *MaterialUpsert { return u } -// SetShortName sets the "short_name" field. -func (u *MaterialUpsert) SetShortName(v string) *MaterialUpsert { - u.Set(material.FieldShortName, v) - return u -} - -// UpdateShortName sets the "short_name" field to the value that was provided on create. -func (u *MaterialUpsert) UpdateShortName() *MaterialUpsert { - u.SetExcluded(material.FieldShortName) - return u -} - -// ClearShortName clears the value of the "short_name" field. -func (u *MaterialUpsert) ClearShortName() *MaterialUpsert { - u.SetNull(material.FieldShortName) - return u -} - // SetSpec sets the "spec" field. func (u *MaterialUpsert) SetSpec(v string) *MaterialUpsert { u.Set(material.FieldSpec, v) @@ -763,27 +727,6 @@ func (u *MaterialUpsertOne) UpdateName() *MaterialUpsertOne { }) } -// SetShortName sets the "short_name" field. -func (u *MaterialUpsertOne) SetShortName(v string) *MaterialUpsertOne { - return u.Update(func(s *MaterialUpsert) { - s.SetShortName(v) - }) -} - -// UpdateShortName sets the "short_name" field to the value that was provided on create. -func (u *MaterialUpsertOne) UpdateShortName() *MaterialUpsertOne { - return u.Update(func(s *MaterialUpsert) { - s.UpdateShortName() - }) -} - -// ClearShortName clears the value of the "short_name" field. -func (u *MaterialUpsertOne) ClearShortName() *MaterialUpsertOne { - return u.Update(func(s *MaterialUpsert) { - s.ClearShortName() - }) -} - // SetSpec sets the "spec" field. func (u *MaterialUpsertOne) SetSpec(v string) *MaterialUpsertOne { return u.Update(func(s *MaterialUpsert) { @@ -1247,27 +1190,6 @@ func (u *MaterialUpsertBulk) UpdateName() *MaterialUpsertBulk { }) } -// SetShortName sets the "short_name" field. -func (u *MaterialUpsertBulk) SetShortName(v string) *MaterialUpsertBulk { - return u.Update(func(s *MaterialUpsert) { - s.SetShortName(v) - }) -} - -// UpdateShortName sets the "short_name" field to the value that was provided on create. -func (u *MaterialUpsertBulk) UpdateShortName() *MaterialUpsertBulk { - return u.Update(func(s *MaterialUpsert) { - s.UpdateShortName() - }) -} - -// ClearShortName clears the value of the "short_name" field. -func (u *MaterialUpsertBulk) ClearShortName() *MaterialUpsertBulk { - return u.Update(func(s *MaterialUpsert) { - s.ClearShortName() - }) -} - // SetSpec sets the "spec" field. func (u *MaterialUpsertBulk) SetSpec(v string) *MaterialUpsertBulk { return u.Update(func(s *MaterialUpsert) { diff --git a/bj_power_wms/ent/material_update.go b/bj_power_wms/ent/material_update.go index 8eef95d..756af2e 100644 --- a/bj_power_wms/ent/material_update.go +++ b/bj_power_wms/ent/material_update.go @@ -55,26 +55,6 @@ func (_u *MaterialUpdate) SetNillableName(v *string) *MaterialUpdate { return _u } -// SetShortName sets the "short_name" field. -func (_u *MaterialUpdate) SetShortName(v string) *MaterialUpdate { - _u.mutation.SetShortName(v) - return _u -} - -// SetNillableShortName sets the "short_name" field if the given value is not nil. -func (_u *MaterialUpdate) SetNillableShortName(v *string) *MaterialUpdate { - if v != nil { - _u.SetShortName(*v) - } - return _u -} - -// ClearShortName clears the value of the "short_name" field. -func (_u *MaterialUpdate) ClearShortName() *MaterialUpdate { - _u.mutation.ClearShortName() - return _u -} - // SetSpec sets the "spec" field. func (_u *MaterialUpdate) SetSpec(v string) *MaterialUpdate { _u.mutation.SetSpec(v) @@ -349,12 +329,6 @@ func (_u *MaterialUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Name(); ok { _spec.SetField(material.FieldName, field.TypeString, value) } - if value, ok := _u.mutation.ShortName(); ok { - _spec.SetField(material.FieldShortName, field.TypeString, value) - } - if _u.mutation.ShortNameCleared() { - _spec.ClearField(material.FieldShortName, field.TypeString) - } if value, ok := _u.mutation.Spec(); ok { _spec.SetField(material.FieldSpec, field.TypeString, value) } @@ -466,26 +440,6 @@ func (_u *MaterialUpdateOne) SetNillableName(v *string) *MaterialUpdateOne { return _u } -// SetShortName sets the "short_name" field. -func (_u *MaterialUpdateOne) SetShortName(v string) *MaterialUpdateOne { - _u.mutation.SetShortName(v) - return _u -} - -// SetNillableShortName sets the "short_name" field if the given value is not nil. -func (_u *MaterialUpdateOne) SetNillableShortName(v *string) *MaterialUpdateOne { - if v != nil { - _u.SetShortName(*v) - } - return _u -} - -// ClearShortName clears the value of the "short_name" field. -func (_u *MaterialUpdateOne) ClearShortName() *MaterialUpdateOne { - _u.mutation.ClearShortName() - return _u -} - // SetSpec sets the "spec" field. func (_u *MaterialUpdateOne) SetSpec(v string) *MaterialUpdateOne { _u.mutation.SetSpec(v) @@ -790,12 +744,6 @@ func (_u *MaterialUpdateOne) sqlSave(ctx context.Context) (_node *Material, err if value, ok := _u.mutation.Name(); ok { _spec.SetField(material.FieldName, field.TypeString, value) } - if value, ok := _u.mutation.ShortName(); ok { - _spec.SetField(material.FieldShortName, field.TypeString, value) - } - if _u.mutation.ShortNameCleared() { - _spec.ClearField(material.FieldShortName, field.TypeString) - } if value, ok := _u.mutation.Spec(); ok { _spec.SetField(material.FieldSpec, field.TypeString, value) } diff --git a/bj_power_wms/ent/migrate/schema.go b/bj_power_wms/ent/migrate/schema.go index 4531a08..af710c1 100644 --- a/bj_power_wms/ent/migrate/schema.go +++ b/bj_power_wms/ent/migrate/schema.go @@ -60,9 +60,17 @@ var ( {Name: "biz_id", Type: field.TypeString}, {Name: "file_name", Type: field.TypeString}, {Name: "file_path", Type: field.TypeString}, + {Name: "file_type", Type: field.TypeString, Nullable: true}, + {Name: "file_ext", Type: field.TypeString, Nullable: true}, + {Name: "file_md5", Type: field.TypeString, Nullable: true}, {Name: "file_size", Type: field.TypeInt64, Default: 0}, {Name: "mime_type", Type: field.TypeString, Nullable: true}, {Name: "uploaded_by", Type: field.TypeString, Nullable: true}, + {Name: "archived", Type: field.TypeBool, Default: false}, + {Name: "archived_at", Type: field.TypeInt64, Nullable: true}, + {Name: "deleted", Type: field.TypeBool, Default: false}, + {Name: "deleted_at", Type: field.TypeInt64, Nullable: true}, + {Name: "deleted_by", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeInt64}, } // AttachmentsTable holds the schema information for the "attachments" table. @@ -76,6 +84,21 @@ var ( Unique: false, Columns: []*schema.Column{AttachmentsColumns[1], AttachmentsColumns[2]}, }, + { + Name: "attachment_file_type", + Unique: false, + Columns: []*schema.Column{AttachmentsColumns[5]}, + }, + { + Name: "attachment_file_md5", + Unique: false, + Columns: []*schema.Column{AttachmentsColumns[7]}, + }, + { + Name: "attachment_created_at", + Unique: false, + Columns: []*schema.Column{AttachmentsColumns[16]}, + }, }, } // DocksColumns holds the columns for the "docks" table. @@ -190,6 +213,10 @@ var ( {Name: "ownership_type", Type: field.TypeString, Default: "none"}, {Name: "ownership_no", Type: field.TypeString, Nullable: true}, {Name: "quality_status", Type: field.TypeString, Nullable: true}, + {Name: "voided", Type: field.TypeBool, Default: false}, + {Name: "void_reason", Type: field.TypeString, Nullable: true}, + {Name: "voided_by", Type: field.TypeString, Nullable: true}, + {Name: "voided_at", Type: field.TypeInt64, Nullable: true}, {Name: "created_at", Type: field.TypeInt64}, } // InboundOrdersTable holds the schema information for the "inbound_orders" table. @@ -389,7 +416,6 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "code", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, - {Name: "short_name", Type: field.TypeString, Nullable: true}, {Name: "spec", Type: field.TypeString, Nullable: true}, {Name: "unit", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, @@ -417,12 +443,12 @@ var ( { Name: "material_template_code", Unique: false, - Columns: []*schema.Column{MaterialsColumns[11]}, + Columns: []*schema.Column{MaterialsColumns[10]}, }, { Name: "material_item_type", Unique: false, - Columns: []*schema.Column{MaterialsColumns[7]}, + Columns: []*schema.Column{MaterialsColumns[6]}, }, }, } @@ -800,8 +826,12 @@ var ( // ZonesColumns holds the columns for the "zones" table. ZonesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "level", Type: field.TypeInt}, + {Name: "code", Type: field.TypeString}, + {Name: "name", Type: field.TypeString, Nullable: true}, + {Name: "parent_code", Type: field.TypeString, Nullable: true}, {Name: "zone_code", Type: field.TypeString}, - {Name: "zone_name", Type: field.TypeString}, + {Name: "zone_name", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "shelf_no", Type: field.TypeString, Nullable: true}, {Name: "layer_no", Type: field.TypeString, Nullable: true}, diff --git a/bj_power_wms/ent/mutation.go b/bj_power_wms/ent/mutation.go index 6c4bda2..c84e1e6 100644 --- a/bj_power_wms/ent/mutation.go +++ b/bj_power_wms/ent/mutation.go @@ -1136,23 +1136,33 @@ func (m *AgvTaskMutation) ResetEdge(name string) error { // AttachmentMutation represents an operation that mutates the Attachment nodes in the graph. type AttachmentMutation struct { config - op Op - typ string - id *int - biz_type *string - biz_id *string - file_name *string - file_path *string - file_size *int64 - addfile_size *int64 - mime_type *string - uploaded_by *string - created_at *int64 - addcreated_at *int64 - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*Attachment, error) - predicates []predicate.Attachment + op Op + typ string + id *int + biz_type *string + biz_id *string + file_name *string + file_path *string + file_type *string + file_ext *string + file_md5 *string + file_size *int64 + addfile_size *int64 + mime_type *string + uploaded_by *string + archived *bool + archived_at *int64 + addarchived_at *int64 + deleted *bool + deleted_at *int64 + adddeleted_at *int64 + deleted_by *string + created_at *int64 + addcreated_at *int64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Attachment, error) + predicates []predicate.Attachment } var _ ent.Mutation = (*AttachmentMutation)(nil) @@ -1397,6 +1407,153 @@ func (m *AttachmentMutation) ResetFilePath() { m.file_path = nil } +// SetFileType sets the "file_type" field. +func (m *AttachmentMutation) SetFileType(s string) { + m.file_type = &s +} + +// FileType returns the value of the "file_type" field in the mutation. +func (m *AttachmentMutation) FileType() (r string, exists bool) { + v := m.file_type + if v == nil { + return + } + return *v, true +} + +// OldFileType returns the old "file_type" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileType: %w", err) + } + return oldValue.FileType, nil +} + +// ClearFileType clears the value of the "file_type" field. +func (m *AttachmentMutation) ClearFileType() { + m.file_type = nil + m.clearedFields[attachment.FieldFileType] = struct{}{} +} + +// FileTypeCleared returns if the "file_type" field was cleared in this mutation. +func (m *AttachmentMutation) FileTypeCleared() bool { + _, ok := m.clearedFields[attachment.FieldFileType] + return ok +} + +// ResetFileType resets all changes to the "file_type" field. +func (m *AttachmentMutation) ResetFileType() { + m.file_type = nil + delete(m.clearedFields, attachment.FieldFileType) +} + +// SetFileExt sets the "file_ext" field. +func (m *AttachmentMutation) SetFileExt(s string) { + m.file_ext = &s +} + +// FileExt returns the value of the "file_ext" field in the mutation. +func (m *AttachmentMutation) FileExt() (r string, exists bool) { + v := m.file_ext + if v == nil { + return + } + return *v, true +} + +// OldFileExt returns the old "file_ext" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileExt(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileExt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileExt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileExt: %w", err) + } + return oldValue.FileExt, nil +} + +// ClearFileExt clears the value of the "file_ext" field. +func (m *AttachmentMutation) ClearFileExt() { + m.file_ext = nil + m.clearedFields[attachment.FieldFileExt] = struct{}{} +} + +// FileExtCleared returns if the "file_ext" field was cleared in this mutation. +func (m *AttachmentMutation) FileExtCleared() bool { + _, ok := m.clearedFields[attachment.FieldFileExt] + return ok +} + +// ResetFileExt resets all changes to the "file_ext" field. +func (m *AttachmentMutation) ResetFileExt() { + m.file_ext = nil + delete(m.clearedFields, attachment.FieldFileExt) +} + +// SetFileMd5 sets the "file_md5" field. +func (m *AttachmentMutation) SetFileMd5(s string) { + m.file_md5 = &s +} + +// FileMd5 returns the value of the "file_md5" field in the mutation. +func (m *AttachmentMutation) FileMd5() (r string, exists bool) { + v := m.file_md5 + if v == nil { + return + } + return *v, true +} + +// OldFileMd5 returns the old "file_md5" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldFileMd5(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileMd5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileMd5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileMd5: %w", err) + } + return oldValue.FileMd5, nil +} + +// ClearFileMd5 clears the value of the "file_md5" field. +func (m *AttachmentMutation) ClearFileMd5() { + m.file_md5 = nil + m.clearedFields[attachment.FieldFileMd5] = struct{}{} +} + +// FileMd5Cleared returns if the "file_md5" field was cleared in this mutation. +func (m *AttachmentMutation) FileMd5Cleared() bool { + _, ok := m.clearedFields[attachment.FieldFileMd5] + return ok +} + +// ResetFileMd5 resets all changes to the "file_md5" field. +func (m *AttachmentMutation) ResetFileMd5() { + m.file_md5 = nil + delete(m.clearedFields, attachment.FieldFileMd5) +} + // SetFileSize sets the "file_size" field. func (m *AttachmentMutation) SetFileSize(i int64) { m.file_size = &i @@ -1551,6 +1708,267 @@ func (m *AttachmentMutation) ResetUploadedBy() { delete(m.clearedFields, attachment.FieldUploadedBy) } +// SetArchived sets the "archived" field. +func (m *AttachmentMutation) SetArchived(b bool) { + m.archived = &b +} + +// Archived returns the value of the "archived" field in the mutation. +func (m *AttachmentMutation) Archived() (r bool, exists bool) { + v := m.archived + if v == nil { + return + } + return *v, true +} + +// OldArchived returns the old "archived" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldArchived(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchived is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchived requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchived: %w", err) + } + return oldValue.Archived, nil +} + +// ResetArchived resets all changes to the "archived" field. +func (m *AttachmentMutation) ResetArchived() { + m.archived = nil +} + +// SetArchivedAt sets the "archived_at" field. +func (m *AttachmentMutation) SetArchivedAt(i int64) { + m.archived_at = &i + m.addarchived_at = nil +} + +// ArchivedAt returns the value of the "archived_at" field in the mutation. +func (m *AttachmentMutation) ArchivedAt() (r int64, exists bool) { + v := m.archived_at + if v == nil { + return + } + return *v, true +} + +// OldArchivedAt returns the old "archived_at" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldArchivedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArchivedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArchivedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArchivedAt: %w", err) + } + return oldValue.ArchivedAt, nil +} + +// AddArchivedAt adds i to the "archived_at" field. +func (m *AttachmentMutation) AddArchivedAt(i int64) { + if m.addarchived_at != nil { + *m.addarchived_at += i + } else { + m.addarchived_at = &i + } +} + +// AddedArchivedAt returns the value that was added to the "archived_at" field in this mutation. +func (m *AttachmentMutation) AddedArchivedAt() (r int64, exists bool) { + v := m.addarchived_at + if v == nil { + return + } + return *v, true +} + +// ClearArchivedAt clears the value of the "archived_at" field. +func (m *AttachmentMutation) ClearArchivedAt() { + m.archived_at = nil + m.addarchived_at = nil + m.clearedFields[attachment.FieldArchivedAt] = struct{}{} +} + +// ArchivedAtCleared returns if the "archived_at" field was cleared in this mutation. +func (m *AttachmentMutation) ArchivedAtCleared() bool { + _, ok := m.clearedFields[attachment.FieldArchivedAt] + return ok +} + +// ResetArchivedAt resets all changes to the "archived_at" field. +func (m *AttachmentMutation) ResetArchivedAt() { + m.archived_at = nil + m.addarchived_at = nil + delete(m.clearedFields, attachment.FieldArchivedAt) +} + +// SetDeleted sets the "deleted" field. +func (m *AttachmentMutation) SetDeleted(b bool) { + m.deleted = &b +} + +// Deleted returns the value of the "deleted" field in the mutation. +func (m *AttachmentMutation) Deleted() (r bool, exists bool) { + v := m.deleted + if v == nil { + return + } + return *v, true +} + +// OldDeleted returns the old "deleted" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleted: %w", err) + } + return oldValue.Deleted, nil +} + +// ResetDeleted resets all changes to the "deleted" field. +func (m *AttachmentMutation) ResetDeleted() { + m.deleted = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *AttachmentMutation) SetDeletedAt(i int64) { + m.deleted_at = &i + m.adddeleted_at = nil +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *AttachmentMutation) DeletedAt() (r int64, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeletedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// AddDeletedAt adds i to the "deleted_at" field. +func (m *AttachmentMutation) AddDeletedAt(i int64) { + if m.adddeleted_at != nil { + *m.adddeleted_at += i + } else { + m.adddeleted_at = &i + } +} + +// AddedDeletedAt returns the value that was added to the "deleted_at" field in this mutation. +func (m *AttachmentMutation) AddedDeletedAt() (r int64, exists bool) { + v := m.adddeleted_at + if v == nil { + return + } + return *v, true +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *AttachmentMutation) ClearDeletedAt() { + m.deleted_at = nil + m.adddeleted_at = nil + m.clearedFields[attachment.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *AttachmentMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[attachment.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *AttachmentMutation) ResetDeletedAt() { + m.deleted_at = nil + m.adddeleted_at = nil + delete(m.clearedFields, attachment.FieldDeletedAt) +} + +// SetDeletedBy sets the "deleted_by" field. +func (m *AttachmentMutation) SetDeletedBy(s string) { + m.deleted_by = &s +} + +// DeletedBy returns the value of the "deleted_by" field in the mutation. +func (m *AttachmentMutation) DeletedBy() (r string, exists bool) { + v := m.deleted_by + if v == nil { + return + } + return *v, true +} + +// OldDeletedBy returns the old "deleted_by" field's value of the Attachment entity. +// If the Attachment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AttachmentMutation) OldDeletedBy(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedBy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedBy: %w", err) + } + return oldValue.DeletedBy, nil +} + +// ClearDeletedBy clears the value of the "deleted_by" field. +func (m *AttachmentMutation) ClearDeletedBy() { + m.deleted_by = nil + m.clearedFields[attachment.FieldDeletedBy] = struct{}{} +} + +// DeletedByCleared returns if the "deleted_by" field was cleared in this mutation. +func (m *AttachmentMutation) DeletedByCleared() bool { + _, ok := m.clearedFields[attachment.FieldDeletedBy] + return ok +} + +// ResetDeletedBy resets all changes to the "deleted_by" field. +func (m *AttachmentMutation) ResetDeletedBy() { + m.deleted_by = nil + delete(m.clearedFields, attachment.FieldDeletedBy) +} + // SetCreatedAt sets the "created_at" field. func (m *AttachmentMutation) SetCreatedAt(i int64) { m.created_at = &i @@ -1641,7 +2059,7 @@ func (m *AttachmentMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *AttachmentMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 16) if m.biz_type != nil { fields = append(fields, attachment.FieldBizType) } @@ -1654,6 +2072,15 @@ func (m *AttachmentMutation) Fields() []string { if m.file_path != nil { fields = append(fields, attachment.FieldFilePath) } + if m.file_type != nil { + fields = append(fields, attachment.FieldFileType) + } + if m.file_ext != nil { + fields = append(fields, attachment.FieldFileExt) + } + if m.file_md5 != nil { + fields = append(fields, attachment.FieldFileMd5) + } if m.file_size != nil { fields = append(fields, attachment.FieldFileSize) } @@ -1663,6 +2090,21 @@ func (m *AttachmentMutation) Fields() []string { if m.uploaded_by != nil { fields = append(fields, attachment.FieldUploadedBy) } + if m.archived != nil { + fields = append(fields, attachment.FieldArchived) + } + if m.archived_at != nil { + fields = append(fields, attachment.FieldArchivedAt) + } + if m.deleted != nil { + fields = append(fields, attachment.FieldDeleted) + } + if m.deleted_at != nil { + fields = append(fields, attachment.FieldDeletedAt) + } + if m.deleted_by != nil { + fields = append(fields, attachment.FieldDeletedBy) + } if m.created_at != nil { fields = append(fields, attachment.FieldCreatedAt) } @@ -1682,12 +2124,28 @@ func (m *AttachmentMutation) Field(name string) (ent.Value, bool) { return m.FileName() case attachment.FieldFilePath: return m.FilePath() + case attachment.FieldFileType: + return m.FileType() + case attachment.FieldFileExt: + return m.FileExt() + case attachment.FieldFileMd5: + return m.FileMd5() case attachment.FieldFileSize: return m.FileSize() case attachment.FieldMimeType: return m.MimeType() case attachment.FieldUploadedBy: return m.UploadedBy() + case attachment.FieldArchived: + return m.Archived() + case attachment.FieldArchivedAt: + return m.ArchivedAt() + case attachment.FieldDeleted: + return m.Deleted() + case attachment.FieldDeletedAt: + return m.DeletedAt() + case attachment.FieldDeletedBy: + return m.DeletedBy() case attachment.FieldCreatedAt: return m.CreatedAt() } @@ -1707,12 +2165,28 @@ func (m *AttachmentMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldFileName(ctx) case attachment.FieldFilePath: return m.OldFilePath(ctx) + case attachment.FieldFileType: + return m.OldFileType(ctx) + case attachment.FieldFileExt: + return m.OldFileExt(ctx) + case attachment.FieldFileMd5: + return m.OldFileMd5(ctx) case attachment.FieldFileSize: return m.OldFileSize(ctx) case attachment.FieldMimeType: return m.OldMimeType(ctx) case attachment.FieldUploadedBy: return m.OldUploadedBy(ctx) + case attachment.FieldArchived: + return m.OldArchived(ctx) + case attachment.FieldArchivedAt: + return m.OldArchivedAt(ctx) + case attachment.FieldDeleted: + return m.OldDeleted(ctx) + case attachment.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case attachment.FieldDeletedBy: + return m.OldDeletedBy(ctx) case attachment.FieldCreatedAt: return m.OldCreatedAt(ctx) } @@ -1752,6 +2226,27 @@ func (m *AttachmentMutation) SetField(name string, value ent.Value) error { } m.SetFilePath(v) return nil + case attachment.FieldFileType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileType(v) + return nil + case attachment.FieldFileExt: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileExt(v) + return nil + case attachment.FieldFileMd5: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFileMd5(v) + return nil case attachment.FieldFileSize: v, ok := value.(int64) if !ok { @@ -1773,6 +2268,41 @@ func (m *AttachmentMutation) SetField(name string, value ent.Value) error { } m.SetUploadedBy(v) return nil + case attachment.FieldArchived: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchived(v) + return nil + case attachment.FieldArchivedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArchivedAt(v) + return nil + case attachment.FieldDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeleted(v) + return nil + case attachment.FieldDeletedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case attachment.FieldDeletedBy: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedBy(v) + return nil case attachment.FieldCreatedAt: v, ok := value.(int64) if !ok { @@ -1791,6 +2321,12 @@ func (m *AttachmentMutation) AddedFields() []string { if m.addfile_size != nil { fields = append(fields, attachment.FieldFileSize) } + if m.addarchived_at != nil { + fields = append(fields, attachment.FieldArchivedAt) + } + if m.adddeleted_at != nil { + fields = append(fields, attachment.FieldDeletedAt) + } if m.addcreated_at != nil { fields = append(fields, attachment.FieldCreatedAt) } @@ -1804,6 +2340,10 @@ func (m *AttachmentMutation) AddedField(name string) (ent.Value, bool) { switch name { case attachment.FieldFileSize: return m.AddedFileSize() + case attachment.FieldArchivedAt: + return m.AddedArchivedAt() + case attachment.FieldDeletedAt: + return m.AddedDeletedAt() case attachment.FieldCreatedAt: return m.AddedCreatedAt() } @@ -1822,6 +2362,20 @@ func (m *AttachmentMutation) AddField(name string, value ent.Value) error { } m.AddFileSize(v) return nil + case attachment.FieldArchivedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddArchivedAt(v) + return nil + case attachment.FieldDeletedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDeletedAt(v) + return nil case attachment.FieldCreatedAt: v, ok := value.(int64) if !ok { @@ -1837,12 +2391,30 @@ func (m *AttachmentMutation) AddField(name string, value ent.Value) error { // mutation. func (m *AttachmentMutation) ClearedFields() []string { var fields []string + if m.FieldCleared(attachment.FieldFileType) { + fields = append(fields, attachment.FieldFileType) + } + if m.FieldCleared(attachment.FieldFileExt) { + fields = append(fields, attachment.FieldFileExt) + } + if m.FieldCleared(attachment.FieldFileMd5) { + fields = append(fields, attachment.FieldFileMd5) + } if m.FieldCleared(attachment.FieldMimeType) { fields = append(fields, attachment.FieldMimeType) } if m.FieldCleared(attachment.FieldUploadedBy) { fields = append(fields, attachment.FieldUploadedBy) } + if m.FieldCleared(attachment.FieldArchivedAt) { + fields = append(fields, attachment.FieldArchivedAt) + } + if m.FieldCleared(attachment.FieldDeletedAt) { + fields = append(fields, attachment.FieldDeletedAt) + } + if m.FieldCleared(attachment.FieldDeletedBy) { + fields = append(fields, attachment.FieldDeletedBy) + } return fields } @@ -1857,12 +2429,30 @@ func (m *AttachmentMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *AttachmentMutation) ClearField(name string) error { switch name { + case attachment.FieldFileType: + m.ClearFileType() + return nil + case attachment.FieldFileExt: + m.ClearFileExt() + return nil + case attachment.FieldFileMd5: + m.ClearFileMd5() + return nil case attachment.FieldMimeType: m.ClearMimeType() return nil case attachment.FieldUploadedBy: m.ClearUploadedBy() return nil + case attachment.FieldArchivedAt: + m.ClearArchivedAt() + return nil + case attachment.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case attachment.FieldDeletedBy: + m.ClearDeletedBy() + return nil } return fmt.Errorf("unknown Attachment nullable field %s", name) } @@ -1883,6 +2473,15 @@ func (m *AttachmentMutation) ResetField(name string) error { case attachment.FieldFilePath: m.ResetFilePath() return nil + case attachment.FieldFileType: + m.ResetFileType() + return nil + case attachment.FieldFileExt: + m.ResetFileExt() + return nil + case attachment.FieldFileMd5: + m.ResetFileMd5() + return nil case attachment.FieldFileSize: m.ResetFileSize() return nil @@ -1892,6 +2491,21 @@ func (m *AttachmentMutation) ResetField(name string) error { case attachment.FieldUploadedBy: m.ResetUploadedBy() return nil + case attachment.FieldArchived: + m.ResetArchived() + return nil + case attachment.FieldArchivedAt: + m.ResetArchivedAt() + return nil + case attachment.FieldDeleted: + m.ResetDeleted() + return nil + case attachment.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case attachment.FieldDeletedBy: + m.ResetDeletedBy() + return nil case attachment.FieldCreatedAt: m.ResetCreatedAt() return nil @@ -4181,6 +4795,11 @@ type InboundOrderMutation struct { ownership_type *string ownership_no *string quality_status *string + voided *bool + void_reason *string + voided_by *string + voided_at *int64 + addvoided_at *int64 created_at *int64 addcreated_at *int64 clearedFields map[string]struct{} @@ -5069,6 +5688,210 @@ func (m *InboundOrderMutation) ResetQualityStatus() { delete(m.clearedFields, inboundorder.FieldQualityStatus) } +// SetVoided sets the "voided" field. +func (m *InboundOrderMutation) SetVoided(b bool) { + m.voided = &b +} + +// Voided returns the value of the "voided" field in the mutation. +func (m *InboundOrderMutation) Voided() (r bool, exists bool) { + v := m.voided + if v == nil { + return + } + return *v, true +} + +// OldVoided returns the old "voided" field's value of the InboundOrder entity. +// If the InboundOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *InboundOrderMutation) OldVoided(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVoided is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVoided requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVoided: %w", err) + } + return oldValue.Voided, nil +} + +// ResetVoided resets all changes to the "voided" field. +func (m *InboundOrderMutation) ResetVoided() { + m.voided = nil +} + +// SetVoidReason sets the "void_reason" field. +func (m *InboundOrderMutation) SetVoidReason(s string) { + m.void_reason = &s +} + +// VoidReason returns the value of the "void_reason" field in the mutation. +func (m *InboundOrderMutation) VoidReason() (r string, exists bool) { + v := m.void_reason + if v == nil { + return + } + return *v, true +} + +// OldVoidReason returns the old "void_reason" field's value of the InboundOrder entity. +// If the InboundOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *InboundOrderMutation) OldVoidReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVoidReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVoidReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVoidReason: %w", err) + } + return oldValue.VoidReason, nil +} + +// ClearVoidReason clears the value of the "void_reason" field. +func (m *InboundOrderMutation) ClearVoidReason() { + m.void_reason = nil + m.clearedFields[inboundorder.FieldVoidReason] = struct{}{} +} + +// VoidReasonCleared returns if the "void_reason" field was cleared in this mutation. +func (m *InboundOrderMutation) VoidReasonCleared() bool { + _, ok := m.clearedFields[inboundorder.FieldVoidReason] + return ok +} + +// ResetVoidReason resets all changes to the "void_reason" field. +func (m *InboundOrderMutation) ResetVoidReason() { + m.void_reason = nil + delete(m.clearedFields, inboundorder.FieldVoidReason) +} + +// SetVoidedBy sets the "voided_by" field. +func (m *InboundOrderMutation) SetVoidedBy(s string) { + m.voided_by = &s +} + +// VoidedBy returns the value of the "voided_by" field in the mutation. +func (m *InboundOrderMutation) VoidedBy() (r string, exists bool) { + v := m.voided_by + if v == nil { + return + } + return *v, true +} + +// OldVoidedBy returns the old "voided_by" field's value of the InboundOrder entity. +// If the InboundOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *InboundOrderMutation) OldVoidedBy(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVoidedBy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVoidedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVoidedBy: %w", err) + } + return oldValue.VoidedBy, nil +} + +// ClearVoidedBy clears the value of the "voided_by" field. +func (m *InboundOrderMutation) ClearVoidedBy() { + m.voided_by = nil + m.clearedFields[inboundorder.FieldVoidedBy] = struct{}{} +} + +// VoidedByCleared returns if the "voided_by" field was cleared in this mutation. +func (m *InboundOrderMutation) VoidedByCleared() bool { + _, ok := m.clearedFields[inboundorder.FieldVoidedBy] + return ok +} + +// ResetVoidedBy resets all changes to the "voided_by" field. +func (m *InboundOrderMutation) ResetVoidedBy() { + m.voided_by = nil + delete(m.clearedFields, inboundorder.FieldVoidedBy) +} + +// SetVoidedAt sets the "voided_at" field. +func (m *InboundOrderMutation) SetVoidedAt(i int64) { + m.voided_at = &i + m.addvoided_at = nil +} + +// VoidedAt returns the value of the "voided_at" field in the mutation. +func (m *InboundOrderMutation) VoidedAt() (r int64, exists bool) { + v := m.voided_at + if v == nil { + return + } + return *v, true +} + +// OldVoidedAt returns the old "voided_at" field's value of the InboundOrder entity. +// If the InboundOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *InboundOrderMutation) OldVoidedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVoidedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVoidedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVoidedAt: %w", err) + } + return oldValue.VoidedAt, nil +} + +// AddVoidedAt adds i to the "voided_at" field. +func (m *InboundOrderMutation) AddVoidedAt(i int64) { + if m.addvoided_at != nil { + *m.addvoided_at += i + } else { + m.addvoided_at = &i + } +} + +// AddedVoidedAt returns the value that was added to the "voided_at" field in this mutation. +func (m *InboundOrderMutation) AddedVoidedAt() (r int64, exists bool) { + v := m.addvoided_at + if v == nil { + return + } + return *v, true +} + +// ClearVoidedAt clears the value of the "voided_at" field. +func (m *InboundOrderMutation) ClearVoidedAt() { + m.voided_at = nil + m.addvoided_at = nil + m.clearedFields[inboundorder.FieldVoidedAt] = struct{}{} +} + +// VoidedAtCleared returns if the "voided_at" field was cleared in this mutation. +func (m *InboundOrderMutation) VoidedAtCleared() bool { + _, ok := m.clearedFields[inboundorder.FieldVoidedAt] + return ok +} + +// ResetVoidedAt resets all changes to the "voided_at" field. +func (m *InboundOrderMutation) ResetVoidedAt() { + m.voided_at = nil + m.addvoided_at = nil + delete(m.clearedFields, inboundorder.FieldVoidedAt) +} + // SetCreatedAt sets the "created_at" field. func (m *InboundOrderMutation) SetCreatedAt(i int64) { m.created_at = &i @@ -5159,7 +5982,7 @@ func (m *InboundOrderMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *InboundOrderMutation) Fields() []string { - fields := make([]string, 0, 18) + fields := make([]string, 0, 22) if m.inbound_no != nil { fields = append(fields, inboundorder.FieldInboundNo) } @@ -5211,6 +6034,18 @@ func (m *InboundOrderMutation) Fields() []string { if m.quality_status != nil { fields = append(fields, inboundorder.FieldQualityStatus) } + if m.voided != nil { + fields = append(fields, inboundorder.FieldVoided) + } + if m.void_reason != nil { + fields = append(fields, inboundorder.FieldVoidReason) + } + if m.voided_by != nil { + fields = append(fields, inboundorder.FieldVoidedBy) + } + if m.voided_at != nil { + fields = append(fields, inboundorder.FieldVoidedAt) + } if m.created_at != nil { fields = append(fields, inboundorder.FieldCreatedAt) } @@ -5256,6 +6091,14 @@ func (m *InboundOrderMutation) Field(name string) (ent.Value, bool) { return m.OwnershipNo() case inboundorder.FieldQualityStatus: return m.QualityStatus() + case inboundorder.FieldVoided: + return m.Voided() + case inboundorder.FieldVoidReason: + return m.VoidReason() + case inboundorder.FieldVoidedBy: + return m.VoidedBy() + case inboundorder.FieldVoidedAt: + return m.VoidedAt() case inboundorder.FieldCreatedAt: return m.CreatedAt() } @@ -5301,6 +6144,14 @@ func (m *InboundOrderMutation) OldField(ctx context.Context, name string) (ent.V return m.OldOwnershipNo(ctx) case inboundorder.FieldQualityStatus: return m.OldQualityStatus(ctx) + case inboundorder.FieldVoided: + return m.OldVoided(ctx) + case inboundorder.FieldVoidReason: + return m.OldVoidReason(ctx) + case inboundorder.FieldVoidedBy: + return m.OldVoidedBy(ctx) + case inboundorder.FieldVoidedAt: + return m.OldVoidedAt(ctx) case inboundorder.FieldCreatedAt: return m.OldCreatedAt(ctx) } @@ -5431,6 +6282,34 @@ func (m *InboundOrderMutation) SetField(name string, value ent.Value) error { } m.SetQualityStatus(v) return nil + case inboundorder.FieldVoided: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVoided(v) + return nil + case inboundorder.FieldVoidReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVoidReason(v) + return nil + case inboundorder.FieldVoidedBy: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVoidedBy(v) + return nil + case inboundorder.FieldVoidedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVoidedAt(v) + return nil case inboundorder.FieldCreatedAt: v, ok := value.(int64) if !ok { @@ -5452,6 +6331,9 @@ func (m *InboundOrderMutation) AddedFields() []string { if m.addquantity != nil { fields = append(fields, inboundorder.FieldQuantity) } + if m.addvoided_at != nil { + fields = append(fields, inboundorder.FieldVoidedAt) + } if m.addcreated_at != nil { fields = append(fields, inboundorder.FieldCreatedAt) } @@ -5467,6 +6349,8 @@ func (m *InboundOrderMutation) AddedField(name string) (ent.Value, bool) { return m.AddedManageMode() case inboundorder.FieldQuantity: return m.AddedQuantity() + case inboundorder.FieldVoidedAt: + return m.AddedVoidedAt() case inboundorder.FieldCreatedAt: return m.AddedCreatedAt() } @@ -5492,6 +6376,13 @@ func (m *InboundOrderMutation) AddField(name string, value ent.Value) error { } m.AddQuantity(v) return nil + case inboundorder.FieldVoidedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVoidedAt(v) + return nil case inboundorder.FieldCreatedAt: v, ok := value.(int64) if !ok { @@ -5537,6 +6428,15 @@ func (m *InboundOrderMutation) ClearedFields() []string { if m.FieldCleared(inboundorder.FieldQualityStatus) { fields = append(fields, inboundorder.FieldQualityStatus) } + if m.FieldCleared(inboundorder.FieldVoidReason) { + fields = append(fields, inboundorder.FieldVoidReason) + } + if m.FieldCleared(inboundorder.FieldVoidedBy) { + fields = append(fields, inboundorder.FieldVoidedBy) + } + if m.FieldCleared(inboundorder.FieldVoidedAt) { + fields = append(fields, inboundorder.FieldVoidedAt) + } return fields } @@ -5581,6 +6481,15 @@ func (m *InboundOrderMutation) ClearField(name string) error { case inboundorder.FieldQualityStatus: m.ClearQualityStatus() return nil + case inboundorder.FieldVoidReason: + m.ClearVoidReason() + return nil + case inboundorder.FieldVoidedBy: + m.ClearVoidedBy() + return nil + case inboundorder.FieldVoidedAt: + m.ClearVoidedAt() + return nil } return fmt.Errorf("unknown InboundOrder nullable field %s", name) } @@ -5640,6 +6549,18 @@ func (m *InboundOrderMutation) ResetField(name string) error { case inboundorder.FieldQualityStatus: m.ResetQualityStatus() return nil + case inboundorder.FieldVoided: + m.ResetVoided() + return nil + case inboundorder.FieldVoidReason: + m.ResetVoidReason() + return nil + case inboundorder.FieldVoidedBy: + m.ResetVoidedBy() + return nil + case inboundorder.FieldVoidedAt: + m.ResetVoidedAt() + return nil case inboundorder.FieldCreatedAt: m.ResetCreatedAt() return nil @@ -11082,7 +12003,6 @@ type MaterialMutation struct { id *int code *string name *string - short_name *string spec *string unit *string description *string @@ -11276,55 +12196,6 @@ func (m *MaterialMutation) ResetName() { m.name = nil } -// SetShortName sets the "short_name" field. -func (m *MaterialMutation) SetShortName(s string) { - m.short_name = &s -} - -// ShortName returns the value of the "short_name" field in the mutation. -func (m *MaterialMutation) ShortName() (r string, exists bool) { - v := m.short_name - if v == nil { - return - } - return *v, true -} - -// OldShortName returns the old "short_name" field's value of the Material entity. -// If the Material object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MaterialMutation) OldShortName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldShortName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldShortName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldShortName: %w", err) - } - return oldValue.ShortName, nil -} - -// ClearShortName clears the value of the "short_name" field. -func (m *MaterialMutation) ClearShortName() { - m.short_name = nil - m.clearedFields[material.FieldShortName] = struct{}{} -} - -// ShortNameCleared returns if the "short_name" field was cleared in this mutation. -func (m *MaterialMutation) ShortNameCleared() bool { - _, ok := m.clearedFields[material.FieldShortName] - return ok -} - -// ResetShortName resets all changes to the "short_name" field. -func (m *MaterialMutation) ResetShortName() { - m.short_name = nil - delete(m.clearedFields, material.FieldShortName) -} - // SetSpec sets the "spec" field. func (m *MaterialMutation) SetSpec(s string) { m.spec = &s @@ -11943,16 +12814,13 @@ func (m *MaterialMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *MaterialMutation) Fields() []string { - fields := make([]string, 0, 15) + fields := make([]string, 0, 14) if m.code != nil { fields = append(fields, material.FieldCode) } if m.name != nil { fields = append(fields, material.FieldName) } - if m.short_name != nil { - fields = append(fields, material.FieldShortName) - } if m.spec != nil { fields = append(fields, material.FieldSpec) } @@ -12001,8 +12869,6 @@ func (m *MaterialMutation) Field(name string) (ent.Value, bool) { return m.Code() case material.FieldName: return m.Name() - case material.FieldShortName: - return m.ShortName() case material.FieldSpec: return m.Spec() case material.FieldUnit: @@ -12040,8 +12906,6 @@ func (m *MaterialMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldCode(ctx) case material.FieldName: return m.OldName(ctx) - case material.FieldShortName: - return m.OldShortName(ctx) case material.FieldSpec: return m.OldSpec(ctx) case material.FieldUnit: @@ -12089,13 +12953,6 @@ func (m *MaterialMutation) SetField(name string, value ent.Value) error { } m.SetName(v) return nil - case material.FieldShortName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetShortName(v) - return nil case material.FieldSpec: v, ok := value.(string) if !ok { @@ -12273,9 +13130,6 @@ func (m *MaterialMutation) AddField(name string, value ent.Value) error { // mutation. func (m *MaterialMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(material.FieldShortName) { - fields = append(fields, material.FieldShortName) - } if m.FieldCleared(material.FieldSpec) { fields = append(fields, material.FieldSpec) } @@ -12302,9 +13156,6 @@ func (m *MaterialMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *MaterialMutation) ClearField(name string) error { switch name { - case material.FieldShortName: - m.ClearShortName() - return nil case material.FieldSpec: m.ClearSpec() return nil @@ -12331,9 +13182,6 @@ func (m *MaterialMutation) ResetField(name string) error { case material.FieldName: m.ResetName() return nil - case material.FieldShortName: - m.ResetShortName() - return nil case material.FieldSpec: m.ResetSpec() return nil @@ -24394,6 +25242,11 @@ type ZoneMutation struct { op Op typ string id *int + level *int + addlevel *int + code *string + name *string + parent_code *string zone_code *string zone_name *string description *string @@ -24509,6 +25362,196 @@ func (m *ZoneMutation) IDs(ctx context.Context) ([]int, error) { } } +// SetLevel sets the "level" field. +func (m *ZoneMutation) SetLevel(i int) { + m.level = &i + m.addlevel = nil +} + +// Level returns the value of the "level" field in the mutation. +func (m *ZoneMutation) Level() (r int, exists bool) { + v := m.level + if v == nil { + return + } + return *v, true +} + +// OldLevel returns the old "level" field's value of the Zone entity. +// If the Zone object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ZoneMutation) OldLevel(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLevel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLevel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLevel: %w", err) + } + return oldValue.Level, nil +} + +// AddLevel adds i to the "level" field. +func (m *ZoneMutation) AddLevel(i int) { + if m.addlevel != nil { + *m.addlevel += i + } else { + m.addlevel = &i + } +} + +// AddedLevel returns the value that was added to the "level" field in this mutation. +func (m *ZoneMutation) AddedLevel() (r int, exists bool) { + v := m.addlevel + if v == nil { + return + } + return *v, true +} + +// ResetLevel resets all changes to the "level" field. +func (m *ZoneMutation) ResetLevel() { + m.level = nil + m.addlevel = nil +} + +// SetCode sets the "code" field. +func (m *ZoneMutation) SetCode(s string) { + m.code = &s +} + +// Code returns the value of the "code" field in the mutation. +func (m *ZoneMutation) Code() (r string, exists bool) { + v := m.code + if v == nil { + return + } + return *v, true +} + +// OldCode returns the old "code" field's value of the Zone entity. +// If the Zone object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ZoneMutation) OldCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCode: %w", err) + } + return oldValue.Code, nil +} + +// ResetCode resets all changes to the "code" field. +func (m *ZoneMutation) ResetCode() { + m.code = nil +} + +// SetName sets the "name" field. +func (m *ZoneMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ZoneMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Zone entity. +// If the Zone object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ZoneMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ClearName clears the value of the "name" field. +func (m *ZoneMutation) ClearName() { + m.name = nil + m.clearedFields[zone.FieldName] = struct{}{} +} + +// NameCleared returns if the "name" field was cleared in this mutation. +func (m *ZoneMutation) NameCleared() bool { + _, ok := m.clearedFields[zone.FieldName] + return ok +} + +// ResetName resets all changes to the "name" field. +func (m *ZoneMutation) ResetName() { + m.name = nil + delete(m.clearedFields, zone.FieldName) +} + +// SetParentCode sets the "parent_code" field. +func (m *ZoneMutation) SetParentCode(s string) { + m.parent_code = &s +} + +// ParentCode returns the value of the "parent_code" field in the mutation. +func (m *ZoneMutation) ParentCode() (r string, exists bool) { + v := m.parent_code + if v == nil { + return + } + return *v, true +} + +// OldParentCode returns the old "parent_code" field's value of the Zone entity. +// If the Zone object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ZoneMutation) OldParentCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentCode: %w", err) + } + return oldValue.ParentCode, nil +} + +// ClearParentCode clears the value of the "parent_code" field. +func (m *ZoneMutation) ClearParentCode() { + m.parent_code = nil + m.clearedFields[zone.FieldParentCode] = struct{}{} +} + +// ParentCodeCleared returns if the "parent_code" field was cleared in this mutation. +func (m *ZoneMutation) ParentCodeCleared() bool { + _, ok := m.clearedFields[zone.FieldParentCode] + return ok +} + +// ResetParentCode resets all changes to the "parent_code" field. +func (m *ZoneMutation) ResetParentCode() { + m.parent_code = nil + delete(m.clearedFields, zone.FieldParentCode) +} + // SetZoneCode sets the "zone_code" field. func (m *ZoneMutation) SetZoneCode(s string) { m.zone_code = &s @@ -24576,9 +25619,22 @@ func (m *ZoneMutation) OldZoneName(ctx context.Context) (v string, err error) { return oldValue.ZoneName, nil } +// ClearZoneName clears the value of the "zone_name" field. +func (m *ZoneMutation) ClearZoneName() { + m.zone_name = nil + m.clearedFields[zone.FieldZoneName] = struct{}{} +} + +// ZoneNameCleared returns if the "zone_name" field was cleared in this mutation. +func (m *ZoneMutation) ZoneNameCleared() bool { + _, ok := m.clearedFields[zone.FieldZoneName] + return ok +} + // ResetZoneName resets all changes to the "zone_name" field. func (m *ZoneMutation) ResetZoneName() { m.zone_name = nil + delete(m.clearedFields, zone.FieldZoneName) } // SetDescription sets the "description" field. @@ -24973,7 +26029,19 @@ func (m *ZoneMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ZoneMutation) Fields() []string { - fields := make([]string, 0, 9) + fields := make([]string, 0, 13) + if m.level != nil { + fields = append(fields, zone.FieldLevel) + } + if m.code != nil { + fields = append(fields, zone.FieldCode) + } + if m.name != nil { + fields = append(fields, zone.FieldName) + } + if m.parent_code != nil { + fields = append(fields, zone.FieldParentCode) + } if m.zone_code != nil { fields = append(fields, zone.FieldZoneCode) } @@ -25009,6 +26077,14 @@ func (m *ZoneMutation) Fields() []string { // schema. func (m *ZoneMutation) Field(name string) (ent.Value, bool) { switch name { + case zone.FieldLevel: + return m.Level() + case zone.FieldCode: + return m.Code() + case zone.FieldName: + return m.Name() + case zone.FieldParentCode: + return m.ParentCode() case zone.FieldZoneCode: return m.ZoneCode() case zone.FieldZoneName: @@ -25036,6 +26112,14 @@ func (m *ZoneMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *ZoneMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case zone.FieldLevel: + return m.OldLevel(ctx) + case zone.FieldCode: + return m.OldCode(ctx) + case zone.FieldName: + return m.OldName(ctx) + case zone.FieldParentCode: + return m.OldParentCode(ctx) case zone.FieldZoneCode: return m.OldZoneCode(ctx) case zone.FieldZoneName: @@ -25063,6 +26147,34 @@ func (m *ZoneMutation) OldField(ctx context.Context, name string) (ent.Value, er // type. func (m *ZoneMutation) SetField(name string, value ent.Value) error { switch name { + case zone.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLevel(v) + return nil + case zone.FieldCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCode(v) + return nil + case zone.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case zone.FieldParentCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentCode(v) + return nil case zone.FieldZoneCode: v, ok := value.(string) if !ok { @@ -25134,6 +26246,9 @@ func (m *ZoneMutation) SetField(name string, value ent.Value) error { // this mutation. func (m *ZoneMutation) AddedFields() []string { var fields []string + if m.addlevel != nil { + fields = append(fields, zone.FieldLevel) + } if m.addcreated_at != nil { fields = append(fields, zone.FieldCreatedAt) } @@ -25148,6 +26263,8 @@ func (m *ZoneMutation) AddedFields() []string { // was not set, or was not defined in the schema. func (m *ZoneMutation) AddedField(name string) (ent.Value, bool) { switch name { + case zone.FieldLevel: + return m.AddedLevel() case zone.FieldCreatedAt: return m.AddedCreatedAt() case zone.FieldUpdatedAt: @@ -25161,6 +26278,13 @@ func (m *ZoneMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *ZoneMutation) AddField(name string, value ent.Value) error { switch name { + case zone.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLevel(v) + return nil case zone.FieldCreatedAt: v, ok := value.(int64) if !ok { @@ -25183,6 +26307,15 @@ func (m *ZoneMutation) AddField(name string, value ent.Value) error { // mutation. func (m *ZoneMutation) ClearedFields() []string { var fields []string + if m.FieldCleared(zone.FieldName) { + fields = append(fields, zone.FieldName) + } + if m.FieldCleared(zone.FieldParentCode) { + fields = append(fields, zone.FieldParentCode) + } + if m.FieldCleared(zone.FieldZoneName) { + fields = append(fields, zone.FieldZoneName) + } if m.FieldCleared(zone.FieldDescription) { fields = append(fields, zone.FieldDescription) } @@ -25212,6 +26345,15 @@ func (m *ZoneMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *ZoneMutation) ClearField(name string) error { switch name { + case zone.FieldName: + m.ClearName() + return nil + case zone.FieldParentCode: + m.ClearParentCode() + return nil + case zone.FieldZoneName: + m.ClearZoneName() + return nil case zone.FieldDescription: m.ClearDescription() return nil @@ -25235,6 +26377,18 @@ func (m *ZoneMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *ZoneMutation) ResetField(name string) error { switch name { + case zone.FieldLevel: + m.ResetLevel() + return nil + case zone.FieldCode: + m.ResetCode() + return nil + case zone.FieldName: + m.ResetName() + return nil + case zone.FieldParentCode: + m.ResetParentCode() + return nil case zone.FieldZoneCode: m.ResetZoneCode() return nil diff --git a/bj_power_wms/ent/runtime.go b/bj_power_wms/ent/runtime.go index 1590495..3cefd81 100644 --- a/bj_power_wms/ent/runtime.go +++ b/bj_power_wms/ent/runtime.go @@ -102,11 +102,19 @@ func init() { attachmentFields := schema.Attachment{}.Fields() _ = attachmentFields // attachmentDescFileSize is the schema descriptor for file_size field. - attachmentDescFileSize := attachmentFields[4].Descriptor() + attachmentDescFileSize := attachmentFields[7].Descriptor() // attachment.DefaultFileSize holds the default value on creation for the file_size field. attachment.DefaultFileSize = attachmentDescFileSize.Default.(int64) + // attachmentDescArchived is the schema descriptor for archived field. + attachmentDescArchived := attachmentFields[10].Descriptor() + // attachment.DefaultArchived holds the default value on creation for the archived field. + attachment.DefaultArchived = attachmentDescArchived.Default.(bool) + // attachmentDescDeleted is the schema descriptor for deleted field. + attachmentDescDeleted := attachmentFields[12].Descriptor() + // attachment.DefaultDeleted holds the default value on creation for the deleted field. + attachment.DefaultDeleted = attachmentDescDeleted.Default.(bool) // attachmentDescCreatedAt is the schema descriptor for created_at field. - attachmentDescCreatedAt := attachmentFields[7].Descriptor() + attachmentDescCreatedAt := attachmentFields[15].Descriptor() // attachment.DefaultCreatedAt holds the default value on creation for the created_at field. attachment.DefaultCreatedAt = attachmentDescCreatedAt.Default.(func() int64) dockFields := schema.Dock{}.Fields() @@ -211,8 +219,12 @@ func init() { inboundorderDescOwnershipType := inboundorderFields[14].Descriptor() // inboundorder.DefaultOwnershipType holds the default value on creation for the ownership_type field. inboundorder.DefaultOwnershipType = inboundorderDescOwnershipType.Default.(string) + // inboundorderDescVoided is the schema descriptor for voided field. + inboundorderDescVoided := inboundorderFields[17].Descriptor() + // inboundorder.DefaultVoided holds the default value on creation for the voided field. + inboundorder.DefaultVoided = inboundorderDescVoided.Default.(bool) // inboundorderDescCreatedAt is the schema descriptor for created_at field. - inboundorderDescCreatedAt := inboundorderFields[17].Descriptor() + inboundorderDescCreatedAt := inboundorderFields[21].Descriptor() // inboundorder.DefaultCreatedAt holds the default value on creation for the created_at field. inboundorder.DefaultCreatedAt = inboundorderDescCreatedAt.Default.(func() int64) inspectionrecordFields := schema.InspectionRecord{}.Fields() @@ -308,35 +320,35 @@ func init() { materialFields := schema.Material{}.Fields() _ = materialFields // materialDescItemType is the schema descriptor for item_type field. - materialDescItemType := materialFields[6].Descriptor() + materialDescItemType := materialFields[5].Descriptor() // material.DefaultItemType holds the default value on creation for the item_type field. material.DefaultItemType = materialDescItemType.Default.(int) // materialDescManageMode is the schema descriptor for manage_mode field. - materialDescManageMode := materialFields[7].Descriptor() + materialDescManageMode := materialFields[6].Descriptor() // material.DefaultManageMode holds the default value on creation for the manage_mode field. material.DefaultManageMode = materialDescManageMode.Default.(int) // materialDescIsBatchManaged is the schema descriptor for is_batch_managed field. - materialDescIsBatchManaged := materialFields[8].Descriptor() + materialDescIsBatchManaged := materialFields[7].Descriptor() // material.DefaultIsBatchManaged holds the default value on creation for the is_batch_managed field. material.DefaultIsBatchManaged = materialDescIsBatchManaged.Default.(bool) // materialDescIsSerialManaged is the schema descriptor for is_serial_managed field. - materialDescIsSerialManaged := materialFields[9].Descriptor() + materialDescIsSerialManaged := materialFields[8].Descriptor() // material.DefaultIsSerialManaged holds the default value on creation for the is_serial_managed field. material.DefaultIsSerialManaged = materialDescIsSerialManaged.Default.(bool) // materialDescSafetyStock is the schema descriptor for safety_stock field. - materialDescSafetyStock := materialFields[11].Descriptor() + materialDescSafetyStock := materialFields[10].Descriptor() // material.DefaultSafetyStock holds the default value on creation for the safety_stock field. material.DefaultSafetyStock = materialDescSafetyStock.Default.(int) // materialDescIsActive is the schema descriptor for is_active field. - materialDescIsActive := materialFields[12].Descriptor() + materialDescIsActive := materialFields[11].Descriptor() // material.DefaultIsActive holds the default value on creation for the is_active field. material.DefaultIsActive = materialDescIsActive.Default.(bool) // materialDescCreatedAt is the schema descriptor for created_at field. - materialDescCreatedAt := materialFields[13].Descriptor() + materialDescCreatedAt := materialFields[12].Descriptor() // material.DefaultCreatedAt holds the default value on creation for the created_at field. material.DefaultCreatedAt = materialDescCreatedAt.Default.(func() int64) // materialDescUpdatedAt is the schema descriptor for updated_at field. - materialDescUpdatedAt := materialFields[14].Descriptor() + materialDescUpdatedAt := materialFields[13].Descriptor() // material.DefaultUpdatedAt holds the default value on creation for the updated_at field. material.DefaultUpdatedAt = materialDescUpdatedAt.Default.(func() int64) materialdemandFields := schema.MaterialDemand{}.Fields() @@ -614,15 +626,15 @@ func init() { zoneFields := schema.Zone{}.Fields() _ = zoneFields // zoneDescStatus is the schema descriptor for status field. - zoneDescStatus := zoneFields[6].Descriptor() + zoneDescStatus := zoneFields[10].Descriptor() // zone.DefaultStatus holds the default value on creation for the status field. zone.DefaultStatus = zoneDescStatus.Default.(string) // zoneDescCreatedAt is the schema descriptor for created_at field. - zoneDescCreatedAt := zoneFields[7].Descriptor() + zoneDescCreatedAt := zoneFields[11].Descriptor() // zone.DefaultCreatedAt holds the default value on creation for the created_at field. zone.DefaultCreatedAt = zoneDescCreatedAt.Default.(func() int64) // zoneDescUpdatedAt is the schema descriptor for updated_at field. - zoneDescUpdatedAt := zoneFields[8].Descriptor() + zoneDescUpdatedAt := zoneFields[12].Descriptor() // zone.DefaultUpdatedAt holds the default value on creation for the updated_at field. zone.DefaultUpdatedAt = zoneDescUpdatedAt.Default.(func() int64) } diff --git a/bj_power_wms/ent/zone.go b/bj_power_wms/ent/zone.go index 8cf1b69..2075091 100644 --- a/bj_power_wms/ent/zone.go +++ b/bj_power_wms/ent/zone.go @@ -16,17 +16,25 @@ type Zone struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` - // 区域编码(货位四级第一级;同区域可多货位,故不单列唯一) + // 层级 1区域/2货架/3层/4位置号 + Level int `json:"level,omitempty"` + // 本级编码(区域编码/货架号/层号/位置号) + Code string `json:"code,omitempty"` + // 显示名:区域名称(level1)或位置名称(level4,现场可读如'A架3层12位');其他级可空 + Name string `json:"name,omitempty"` + // 上级节点编码;根级(level1)为空 + ParentCode string `json:"parentCode,omitempty"` + // 区域编码(冗余:本节点所属区域;level1=自身code) ZoneCode string `json:"zoneCode,omitempty"` - // 区域名称 + // 区域名称(仅 level1 区域行有值) ZoneName string `json:"zoneName,omitempty"` - // 描述 + // 说明(区域级) Description string `json:"description,omitempty"` - // 货架号(手填) + // 货架号(冗余) ShelfNo string `json:"shelfNo,omitempty"` - // 第几层(手填) + // 第几层(冗余;默认位置为空) LayerNo string `json:"layerNo,omitempty"` - // 位置号(手填) + // 位置号(冗余;level4=自身code) PositionNo string `json:"positionNo,omitempty"` // 状态:启用/停用 Status string `json:"status,omitempty"` @@ -42,9 +50,9 @@ func (*Zone) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case zone.FieldID, zone.FieldCreatedAt, zone.FieldUpdatedAt: + case zone.FieldID, zone.FieldLevel, zone.FieldCreatedAt, zone.FieldUpdatedAt: values[i] = new(sql.NullInt64) - case zone.FieldZoneCode, zone.FieldZoneName, zone.FieldDescription, zone.FieldShelfNo, zone.FieldLayerNo, zone.FieldPositionNo, zone.FieldStatus: + case zone.FieldCode, zone.FieldName, zone.FieldParentCode, zone.FieldZoneCode, zone.FieldZoneName, zone.FieldDescription, zone.FieldShelfNo, zone.FieldLayerNo, zone.FieldPositionNo, zone.FieldStatus: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -67,6 +75,30 @@ func (_m *Zone) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int(value.Int64) + case zone.FieldLevel: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field level", values[i]) + } else if value.Valid { + _m.Level = int(value.Int64) + } + case zone.FieldCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field code", values[i]) + } else if value.Valid { + _m.Code = value.String + } + case zone.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case zone.FieldParentCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field parent_code", values[i]) + } else if value.Valid { + _m.ParentCode = value.String + } case zone.FieldZoneCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field zone_code", values[i]) @@ -157,6 +189,18 @@ func (_m *Zone) String() string { var builder strings.Builder builder.WriteString("Zone(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("level=") + builder.WriteString(fmt.Sprintf("%v", _m.Level)) + builder.WriteString(", ") + builder.WriteString("code=") + builder.WriteString(_m.Code) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("parent_code=") + builder.WriteString(_m.ParentCode) + builder.WriteString(", ") builder.WriteString("zone_code=") builder.WriteString(_m.ZoneCode) builder.WriteString(", ") diff --git a/bj_power_wms/ent/zone/where.go b/bj_power_wms/ent/zone/where.go index 972f80e..a66c916 100644 --- a/bj_power_wms/ent/zone/where.go +++ b/bj_power_wms/ent/zone/where.go @@ -53,6 +53,26 @@ func IDLTE(id int) predicate.Zone { return predicate.Zone(sql.FieldLTE(FieldID, id)) } +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldLevel, v)) +} + +// Code applies equality check predicate on the "code" field. It's identical to CodeEQ. +func Code(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldCode, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldName, v)) +} + +// ParentCode applies equality check predicate on the "parent_code" field. It's identical to ParentCodeEQ. +func ParentCode(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldParentCode, v)) +} + // ZoneCode applies equality check predicate on the "zone_code" field. It's identical to ZoneCodeEQ. func ZoneCode(v string) predicate.Zone { return predicate.Zone(sql.FieldEQ(FieldZoneCode, v)) @@ -98,6 +118,261 @@ func UpdatedAt(v int64) predicate.Zone { return predicate.Zone(sql.FieldEQ(FieldUpdatedAt, v)) } +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldLevel, v)) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int) predicate.Zone { + return predicate.Zone(sql.FieldNEQ(FieldLevel, v)) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int) predicate.Zone { + return predicate.Zone(sql.FieldIn(FieldLevel, vs...)) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int) predicate.Zone { + return predicate.Zone(sql.FieldNotIn(FieldLevel, vs...)) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int) predicate.Zone { + return predicate.Zone(sql.FieldGT(FieldLevel, v)) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int) predicate.Zone { + return predicate.Zone(sql.FieldGTE(FieldLevel, v)) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int) predicate.Zone { + return predicate.Zone(sql.FieldLT(FieldLevel, v)) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int) predicate.Zone { + return predicate.Zone(sql.FieldLTE(FieldLevel, v)) +} + +// CodeEQ applies the EQ predicate on the "code" field. +func CodeEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldCode, v)) +} + +// CodeNEQ applies the NEQ predicate on the "code" field. +func CodeNEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldNEQ(FieldCode, v)) +} + +// CodeIn applies the In predicate on the "code" field. +func CodeIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldIn(FieldCode, vs...)) +} + +// CodeNotIn applies the NotIn predicate on the "code" field. +func CodeNotIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldNotIn(FieldCode, vs...)) +} + +// CodeGT applies the GT predicate on the "code" field. +func CodeGT(v string) predicate.Zone { + return predicate.Zone(sql.FieldGT(FieldCode, v)) +} + +// CodeGTE applies the GTE predicate on the "code" field. +func CodeGTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldGTE(FieldCode, v)) +} + +// CodeLT applies the LT predicate on the "code" field. +func CodeLT(v string) predicate.Zone { + return predicate.Zone(sql.FieldLT(FieldCode, v)) +} + +// CodeLTE applies the LTE predicate on the "code" field. +func CodeLTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldLTE(FieldCode, v)) +} + +// CodeContains applies the Contains predicate on the "code" field. +func CodeContains(v string) predicate.Zone { + return predicate.Zone(sql.FieldContains(FieldCode, v)) +} + +// CodeHasPrefix applies the HasPrefix predicate on the "code" field. +func CodeHasPrefix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasPrefix(FieldCode, v)) +} + +// CodeHasSuffix applies the HasSuffix predicate on the "code" field. +func CodeHasSuffix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasSuffix(FieldCode, v)) +} + +// CodeEqualFold applies the EqualFold predicate on the "code" field. +func CodeEqualFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldEqualFold(FieldCode, v)) +} + +// CodeContainsFold applies the ContainsFold predicate on the "code" field. +func CodeContainsFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldContainsFold(FieldCode, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Zone { + return predicate.Zone(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Zone { + return predicate.Zone(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Zone { + return predicate.Zone(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasSuffix(FieldName, v)) +} + +// NameIsNil applies the IsNil predicate on the "name" field. +func NameIsNil() predicate.Zone { + return predicate.Zone(sql.FieldIsNull(FieldName)) +} + +// NameNotNil applies the NotNil predicate on the "name" field. +func NameNotNil() predicate.Zone { + return predicate.Zone(sql.FieldNotNull(FieldName)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldContainsFold(FieldName, v)) +} + +// ParentCodeEQ applies the EQ predicate on the "parent_code" field. +func ParentCodeEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldEQ(FieldParentCode, v)) +} + +// ParentCodeNEQ applies the NEQ predicate on the "parent_code" field. +func ParentCodeNEQ(v string) predicate.Zone { + return predicate.Zone(sql.FieldNEQ(FieldParentCode, v)) +} + +// ParentCodeIn applies the In predicate on the "parent_code" field. +func ParentCodeIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldIn(FieldParentCode, vs...)) +} + +// ParentCodeNotIn applies the NotIn predicate on the "parent_code" field. +func ParentCodeNotIn(vs ...string) predicate.Zone { + return predicate.Zone(sql.FieldNotIn(FieldParentCode, vs...)) +} + +// ParentCodeGT applies the GT predicate on the "parent_code" field. +func ParentCodeGT(v string) predicate.Zone { + return predicate.Zone(sql.FieldGT(FieldParentCode, v)) +} + +// ParentCodeGTE applies the GTE predicate on the "parent_code" field. +func ParentCodeGTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldGTE(FieldParentCode, v)) +} + +// ParentCodeLT applies the LT predicate on the "parent_code" field. +func ParentCodeLT(v string) predicate.Zone { + return predicate.Zone(sql.FieldLT(FieldParentCode, v)) +} + +// ParentCodeLTE applies the LTE predicate on the "parent_code" field. +func ParentCodeLTE(v string) predicate.Zone { + return predicate.Zone(sql.FieldLTE(FieldParentCode, v)) +} + +// ParentCodeContains applies the Contains predicate on the "parent_code" field. +func ParentCodeContains(v string) predicate.Zone { + return predicate.Zone(sql.FieldContains(FieldParentCode, v)) +} + +// ParentCodeHasPrefix applies the HasPrefix predicate on the "parent_code" field. +func ParentCodeHasPrefix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasPrefix(FieldParentCode, v)) +} + +// ParentCodeHasSuffix applies the HasSuffix predicate on the "parent_code" field. +func ParentCodeHasSuffix(v string) predicate.Zone { + return predicate.Zone(sql.FieldHasSuffix(FieldParentCode, v)) +} + +// ParentCodeIsNil applies the IsNil predicate on the "parent_code" field. +func ParentCodeIsNil() predicate.Zone { + return predicate.Zone(sql.FieldIsNull(FieldParentCode)) +} + +// ParentCodeNotNil applies the NotNil predicate on the "parent_code" field. +func ParentCodeNotNil() predicate.Zone { + return predicate.Zone(sql.FieldNotNull(FieldParentCode)) +} + +// ParentCodeEqualFold applies the EqualFold predicate on the "parent_code" field. +func ParentCodeEqualFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldEqualFold(FieldParentCode, v)) +} + +// ParentCodeContainsFold applies the ContainsFold predicate on the "parent_code" field. +func ParentCodeContainsFold(v string) predicate.Zone { + return predicate.Zone(sql.FieldContainsFold(FieldParentCode, v)) +} + // ZoneCodeEQ applies the EQ predicate on the "zone_code" field. func ZoneCodeEQ(v string) predicate.Zone { return predicate.Zone(sql.FieldEQ(FieldZoneCode, v)) @@ -218,6 +493,16 @@ func ZoneNameHasSuffix(v string) predicate.Zone { return predicate.Zone(sql.FieldHasSuffix(FieldZoneName, v)) } +// ZoneNameIsNil applies the IsNil predicate on the "zone_name" field. +func ZoneNameIsNil() predicate.Zone { + return predicate.Zone(sql.FieldIsNull(FieldZoneName)) +} + +// ZoneNameNotNil applies the NotNil predicate on the "zone_name" field. +func ZoneNameNotNil() predicate.Zone { + return predicate.Zone(sql.FieldNotNull(FieldZoneName)) +} + // ZoneNameEqualFold applies the EqualFold predicate on the "zone_name" field. func ZoneNameEqualFold(v string) predicate.Zone { return predicate.Zone(sql.FieldEqualFold(FieldZoneName, v)) diff --git a/bj_power_wms/ent/zone/zone.go b/bj_power_wms/ent/zone/zone.go index 28c3cfb..df8e4e8 100644 --- a/bj_power_wms/ent/zone/zone.go +++ b/bj_power_wms/ent/zone/zone.go @@ -11,6 +11,14 @@ const ( Label = "zone" // FieldID holds the string denoting the id field in the database. FieldID = "id" + // FieldLevel holds the string denoting the level field in the database. + FieldLevel = "level" + // FieldCode holds the string denoting the code field in the database. + FieldCode = "code" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldParentCode holds the string denoting the parent_code field in the database. + FieldParentCode = "parent_code" // FieldZoneCode holds the string denoting the zone_code field in the database. FieldZoneCode = "zone_code" // FieldZoneName holds the string denoting the zone_name field in the database. @@ -36,6 +44,10 @@ const ( // Columns holds all SQL columns for zone fields. var Columns = []string{ FieldID, + FieldLevel, + FieldCode, + FieldName, + FieldParentCode, FieldZoneCode, FieldZoneName, FieldDescription, @@ -74,6 +86,26 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByLevel orders the results by the level field. +func ByLevel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLevel, opts...).ToFunc() +} + +// ByCode orders the results by the code field. +func ByCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCode, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByParentCode orders the results by the parent_code field. +func ByParentCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentCode, opts...).ToFunc() +} + // ByZoneCode orders the results by the zone_code field. func ByZoneCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldZoneCode, opts...).ToFunc() diff --git a/bj_power_wms/ent/zone_create.go b/bj_power_wms/ent/zone_create.go index ff46804..e8ae59d 100644 --- a/bj_power_wms/ent/zone_create.go +++ b/bj_power_wms/ent/zone_create.go @@ -21,6 +21,46 @@ type ZoneCreate struct { conflict []sql.ConflictOption } +// SetLevel sets the "level" field. +func (_c *ZoneCreate) SetLevel(v int) *ZoneCreate { + _c.mutation.SetLevel(v) + return _c +} + +// SetCode sets the "code" field. +func (_c *ZoneCreate) SetCode(v string) *ZoneCreate { + _c.mutation.SetCode(v) + return _c +} + +// SetName sets the "name" field. +func (_c *ZoneCreate) SetName(v string) *ZoneCreate { + _c.mutation.SetName(v) + return _c +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *ZoneCreate) SetNillableName(v *string) *ZoneCreate { + if v != nil { + _c.SetName(*v) + } + return _c +} + +// SetParentCode sets the "parent_code" field. +func (_c *ZoneCreate) SetParentCode(v string) *ZoneCreate { + _c.mutation.SetParentCode(v) + return _c +} + +// SetNillableParentCode sets the "parent_code" field if the given value is not nil. +func (_c *ZoneCreate) SetNillableParentCode(v *string) *ZoneCreate { + if v != nil { + _c.SetParentCode(*v) + } + return _c +} + // SetZoneCode sets the "zone_code" field. func (_c *ZoneCreate) SetZoneCode(v string) *ZoneCreate { _c.mutation.SetZoneCode(v) @@ -33,6 +73,14 @@ func (_c *ZoneCreate) SetZoneName(v string) *ZoneCreate { return _c } +// SetNillableZoneName sets the "zone_name" field if the given value is not nil. +func (_c *ZoneCreate) SetNillableZoneName(v *string) *ZoneCreate { + if v != nil { + _c.SetZoneName(*v) + } + return _c +} + // SetDescription sets the "description" field. func (_c *ZoneCreate) SetDescription(v string) *ZoneCreate { _c.mutation.SetDescription(v) @@ -182,12 +230,15 @@ func (_c *ZoneCreate) defaults() { // check runs all checks and user-defined validators on the builder. func (_c *ZoneCreate) check() error { + if _, ok := _c.mutation.Level(); !ok { + return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Zone.level"`)} + } + if _, ok := _c.mutation.Code(); !ok { + return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "Zone.code"`)} + } if _, ok := _c.mutation.ZoneCode(); !ok { return &ValidationError{Name: "zone_code", err: errors.New(`ent: missing required field "Zone.zone_code"`)} } - if _, ok := _c.mutation.ZoneName(); !ok { - return &ValidationError{Name: "zone_name", err: errors.New(`ent: missing required field "Zone.zone_name"`)} - } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Zone.status"`)} } @@ -221,6 +272,22 @@ func (_c *ZoneCreate) createSpec() (*Zone, *sqlgraph.CreateSpec) { _spec = sqlgraph.NewCreateSpec(zone.Table, sqlgraph.NewFieldSpec(zone.FieldID, field.TypeInt)) ) _spec.OnConflict = _c.conflict + if value, ok := _c.mutation.Level(); ok { + _spec.SetField(zone.FieldLevel, field.TypeInt, value) + _node.Level = value + } + if value, ok := _c.mutation.Code(); ok { + _spec.SetField(zone.FieldCode, field.TypeString, value) + _node.Code = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(zone.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.ParentCode(); ok { + _spec.SetField(zone.FieldParentCode, field.TypeString, value) + _node.ParentCode = value + } if value, ok := _c.mutation.ZoneCode(); ok { _spec.SetField(zone.FieldZoneCode, field.TypeString, value) _node.ZoneCode = value @@ -264,7 +331,7 @@ func (_c *ZoneCreate) createSpec() (*Zone, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Zone.Create(). -// SetZoneCode(v). +// SetLevel(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -273,7 +340,7 @@ func (_c *ZoneCreate) createSpec() (*Zone, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.ZoneUpsert) { -// SetZoneCode(v+v). +// SetLevel(v+v). // }). // Exec(ctx) func (_c *ZoneCreate) OnConflict(opts ...sql.ConflictOption) *ZoneUpsertOne { @@ -309,6 +376,72 @@ type ( } ) +// SetLevel sets the "level" field. +func (u *ZoneUpsert) SetLevel(v int) *ZoneUpsert { + u.Set(zone.FieldLevel, v) + return u +} + +// UpdateLevel sets the "level" field to the value that was provided on create. +func (u *ZoneUpsert) UpdateLevel() *ZoneUpsert { + u.SetExcluded(zone.FieldLevel) + return u +} + +// AddLevel adds v to the "level" field. +func (u *ZoneUpsert) AddLevel(v int) *ZoneUpsert { + u.Add(zone.FieldLevel, v) + return u +} + +// SetCode sets the "code" field. +func (u *ZoneUpsert) SetCode(v string) *ZoneUpsert { + u.Set(zone.FieldCode, v) + return u +} + +// UpdateCode sets the "code" field to the value that was provided on create. +func (u *ZoneUpsert) UpdateCode() *ZoneUpsert { + u.SetExcluded(zone.FieldCode) + return u +} + +// SetName sets the "name" field. +func (u *ZoneUpsert) SetName(v string) *ZoneUpsert { + u.Set(zone.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ZoneUpsert) UpdateName() *ZoneUpsert { + u.SetExcluded(zone.FieldName) + return u +} + +// ClearName clears the value of the "name" field. +func (u *ZoneUpsert) ClearName() *ZoneUpsert { + u.SetNull(zone.FieldName) + return u +} + +// SetParentCode sets the "parent_code" field. +func (u *ZoneUpsert) SetParentCode(v string) *ZoneUpsert { + u.Set(zone.FieldParentCode, v) + return u +} + +// UpdateParentCode sets the "parent_code" field to the value that was provided on create. +func (u *ZoneUpsert) UpdateParentCode() *ZoneUpsert { + u.SetExcluded(zone.FieldParentCode) + return u +} + +// ClearParentCode clears the value of the "parent_code" field. +func (u *ZoneUpsert) ClearParentCode() *ZoneUpsert { + u.SetNull(zone.FieldParentCode) + return u +} + // SetZoneCode sets the "zone_code" field. func (u *ZoneUpsert) SetZoneCode(v string) *ZoneUpsert { u.Set(zone.FieldZoneCode, v) @@ -333,6 +466,12 @@ func (u *ZoneUpsert) UpdateZoneName() *ZoneUpsert { return u } +// ClearZoneName clears the value of the "zone_name" field. +func (u *ZoneUpsert) ClearZoneName() *ZoneUpsert { + u.SetNull(zone.FieldZoneName) + return u +} + // SetDescription sets the "description" field. func (u *ZoneUpsert) SetDescription(v string) *ZoneUpsert { u.Set(zone.FieldDescription, v) @@ -499,6 +638,83 @@ func (u *ZoneUpsertOne) Update(set func(*ZoneUpsert)) *ZoneUpsertOne { return u } +// SetLevel sets the "level" field. +func (u *ZoneUpsertOne) SetLevel(v int) *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.SetLevel(v) + }) +} + +// AddLevel adds v to the "level" field. +func (u *ZoneUpsertOne) AddLevel(v int) *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.AddLevel(v) + }) +} + +// UpdateLevel sets the "level" field to the value that was provided on create. +func (u *ZoneUpsertOne) UpdateLevel() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.UpdateLevel() + }) +} + +// SetCode sets the "code" field. +func (u *ZoneUpsertOne) SetCode(v string) *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.SetCode(v) + }) +} + +// UpdateCode sets the "code" field to the value that was provided on create. +func (u *ZoneUpsertOne) UpdateCode() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.UpdateCode() + }) +} + +// SetName sets the "name" field. +func (u *ZoneUpsertOne) SetName(v string) *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ZoneUpsertOne) UpdateName() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.UpdateName() + }) +} + +// ClearName clears the value of the "name" field. +func (u *ZoneUpsertOne) ClearName() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.ClearName() + }) +} + +// SetParentCode sets the "parent_code" field. +func (u *ZoneUpsertOne) SetParentCode(v string) *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.SetParentCode(v) + }) +} + +// UpdateParentCode sets the "parent_code" field to the value that was provided on create. +func (u *ZoneUpsertOne) UpdateParentCode() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.UpdateParentCode() + }) +} + +// ClearParentCode clears the value of the "parent_code" field. +func (u *ZoneUpsertOne) ClearParentCode() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.ClearParentCode() + }) +} + // SetZoneCode sets the "zone_code" field. func (u *ZoneUpsertOne) SetZoneCode(v string) *ZoneUpsertOne { return u.Update(func(s *ZoneUpsert) { @@ -527,6 +743,13 @@ func (u *ZoneUpsertOne) UpdateZoneName() *ZoneUpsertOne { }) } +// ClearZoneName clears the value of the "zone_name" field. +func (u *ZoneUpsertOne) ClearZoneName() *ZoneUpsertOne { + return u.Update(func(s *ZoneUpsert) { + s.ClearZoneName() + }) +} + // SetDescription sets the "description" field. func (u *ZoneUpsertOne) SetDescription(v string) *ZoneUpsertOne { return u.Update(func(s *ZoneUpsert) { @@ -809,7 +1032,7 @@ func (_c *ZoneCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.ZoneUpsert) { -// SetZoneCode(v+v). +// SetLevel(v+v). // }). // Exec(ctx) func (_c *ZoneCreateBulk) OnConflict(opts ...sql.ConflictOption) *ZoneUpsertBulk { @@ -878,6 +1101,83 @@ func (u *ZoneUpsertBulk) Update(set func(*ZoneUpsert)) *ZoneUpsertBulk { return u } +// SetLevel sets the "level" field. +func (u *ZoneUpsertBulk) SetLevel(v int) *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.SetLevel(v) + }) +} + +// AddLevel adds v to the "level" field. +func (u *ZoneUpsertBulk) AddLevel(v int) *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.AddLevel(v) + }) +} + +// UpdateLevel sets the "level" field to the value that was provided on create. +func (u *ZoneUpsertBulk) UpdateLevel() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.UpdateLevel() + }) +} + +// SetCode sets the "code" field. +func (u *ZoneUpsertBulk) SetCode(v string) *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.SetCode(v) + }) +} + +// UpdateCode sets the "code" field to the value that was provided on create. +func (u *ZoneUpsertBulk) UpdateCode() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.UpdateCode() + }) +} + +// SetName sets the "name" field. +func (u *ZoneUpsertBulk) SetName(v string) *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *ZoneUpsertBulk) UpdateName() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.UpdateName() + }) +} + +// ClearName clears the value of the "name" field. +func (u *ZoneUpsertBulk) ClearName() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.ClearName() + }) +} + +// SetParentCode sets the "parent_code" field. +func (u *ZoneUpsertBulk) SetParentCode(v string) *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.SetParentCode(v) + }) +} + +// UpdateParentCode sets the "parent_code" field to the value that was provided on create. +func (u *ZoneUpsertBulk) UpdateParentCode() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.UpdateParentCode() + }) +} + +// ClearParentCode clears the value of the "parent_code" field. +func (u *ZoneUpsertBulk) ClearParentCode() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.ClearParentCode() + }) +} + // SetZoneCode sets the "zone_code" field. func (u *ZoneUpsertBulk) SetZoneCode(v string) *ZoneUpsertBulk { return u.Update(func(s *ZoneUpsert) { @@ -906,6 +1206,13 @@ func (u *ZoneUpsertBulk) UpdateZoneName() *ZoneUpsertBulk { }) } +// ClearZoneName clears the value of the "zone_name" field. +func (u *ZoneUpsertBulk) ClearZoneName() *ZoneUpsertBulk { + return u.Update(func(s *ZoneUpsert) { + s.ClearZoneName() + }) +} + // SetDescription sets the "description" field. func (u *ZoneUpsertBulk) SetDescription(v string) *ZoneUpsertBulk { return u.Update(func(s *ZoneUpsert) { diff --git a/bj_power_wms/ent/zone_query.go b/bj_power_wms/ent/zone_query.go index 36439aa..c1e4f37 100644 --- a/bj_power_wms/ent/zone_query.go +++ b/bj_power_wms/ent/zone_query.go @@ -262,12 +262,12 @@ func (_q *ZoneQuery) Clone() *ZoneQuery { // Example: // // var v []struct { -// ZoneCode string `json:"zoneCode,omitempty"` +// Level int `json:"level,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Zone.Query(). -// GroupBy(zone.FieldZoneCode). +// GroupBy(zone.FieldLevel). // Aggregate(ent.Count()). // Scan(ctx, &v) func (_q *ZoneQuery) GroupBy(field string, fields ...string) *ZoneGroupBy { @@ -285,11 +285,11 @@ func (_q *ZoneQuery) GroupBy(field string, fields ...string) *ZoneGroupBy { // Example: // // var v []struct { -// ZoneCode string `json:"zoneCode,omitempty"` +// Level int `json:"level,omitempty"` // } // // client.Zone.Query(). -// Select(zone.FieldZoneCode). +// Select(zone.FieldLevel). // Scan(ctx, &v) func (_q *ZoneQuery) Select(fields ...string) *ZoneSelect { _q.ctx.Fields = append(_q.ctx.Fields, fields...) diff --git a/bj_power_wms/ent/zone_update.go b/bj_power_wms/ent/zone_update.go index 5d5a979..06dc2db 100644 --- a/bj_power_wms/ent/zone_update.go +++ b/bj_power_wms/ent/zone_update.go @@ -27,6 +27,81 @@ func (_u *ZoneUpdate) Where(ps ...predicate.Zone) *ZoneUpdate { return _u } +// SetLevel sets the "level" field. +func (_u *ZoneUpdate) SetLevel(v int) *ZoneUpdate { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *ZoneUpdate) SetNillableLevel(v *int) *ZoneUpdate { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *ZoneUpdate) AddLevel(v int) *ZoneUpdate { + _u.mutation.AddLevel(v) + return _u +} + +// SetCode sets the "code" field. +func (_u *ZoneUpdate) SetCode(v string) *ZoneUpdate { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *ZoneUpdate) SetNillableCode(v *string) *ZoneUpdate { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ZoneUpdate) SetName(v string) *ZoneUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ZoneUpdate) SetNillableName(v *string) *ZoneUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// ClearName clears the value of the "name" field. +func (_u *ZoneUpdate) ClearName() *ZoneUpdate { + _u.mutation.ClearName() + return _u +} + +// SetParentCode sets the "parent_code" field. +func (_u *ZoneUpdate) SetParentCode(v string) *ZoneUpdate { + _u.mutation.SetParentCode(v) + return _u +} + +// SetNillableParentCode sets the "parent_code" field if the given value is not nil. +func (_u *ZoneUpdate) SetNillableParentCode(v *string) *ZoneUpdate { + if v != nil { + _u.SetParentCode(*v) + } + return _u +} + +// ClearParentCode clears the value of the "parent_code" field. +func (_u *ZoneUpdate) ClearParentCode() *ZoneUpdate { + _u.mutation.ClearParentCode() + return _u +} + // SetZoneCode sets the "zone_code" field. func (_u *ZoneUpdate) SetZoneCode(v string) *ZoneUpdate { _u.mutation.SetZoneCode(v) @@ -55,6 +130,12 @@ func (_u *ZoneUpdate) SetNillableZoneName(v *string) *ZoneUpdate { return _u } +// ClearZoneName clears the value of the "zone_name" field. +func (_u *ZoneUpdate) ClearZoneName() *ZoneUpdate { + _u.mutation.ClearZoneName() + return _u +} + // SetDescription sets the "description" field. func (_u *ZoneUpdate) SetDescription(v string) *ZoneUpdate { _u.mutation.SetDescription(v) @@ -238,12 +319,36 @@ func (_u *ZoneUpdate) sqlSave(ctx context.Context) (_node int, err error) { } } } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(zone.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(zone.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(zone.FieldCode, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(zone.FieldName, field.TypeString, value) + } + if _u.mutation.NameCleared() { + _spec.ClearField(zone.FieldName, field.TypeString) + } + if value, ok := _u.mutation.ParentCode(); ok { + _spec.SetField(zone.FieldParentCode, field.TypeString, value) + } + if _u.mutation.ParentCodeCleared() { + _spec.ClearField(zone.FieldParentCode, field.TypeString) + } if value, ok := _u.mutation.ZoneCode(); ok { _spec.SetField(zone.FieldZoneCode, field.TypeString, value) } if value, ok := _u.mutation.ZoneName(); ok { _spec.SetField(zone.FieldZoneName, field.TypeString, value) } + if _u.mutation.ZoneNameCleared() { + _spec.ClearField(zone.FieldZoneName, field.TypeString) + } if value, ok := _u.mutation.Description(); ok { _spec.SetField(zone.FieldDescription, field.TypeString, value) } @@ -306,6 +411,81 @@ type ZoneUpdateOne struct { mutation *ZoneMutation } +// SetLevel sets the "level" field. +func (_u *ZoneUpdateOne) SetLevel(v int) *ZoneUpdateOne { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *ZoneUpdateOne) SetNillableLevel(v *int) *ZoneUpdateOne { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *ZoneUpdateOne) AddLevel(v int) *ZoneUpdateOne { + _u.mutation.AddLevel(v) + return _u +} + +// SetCode sets the "code" field. +func (_u *ZoneUpdateOne) SetCode(v string) *ZoneUpdateOne { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *ZoneUpdateOne) SetNillableCode(v *string) *ZoneUpdateOne { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ZoneUpdateOne) SetName(v string) *ZoneUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ZoneUpdateOne) SetNillableName(v *string) *ZoneUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// ClearName clears the value of the "name" field. +func (_u *ZoneUpdateOne) ClearName() *ZoneUpdateOne { + _u.mutation.ClearName() + return _u +} + +// SetParentCode sets the "parent_code" field. +func (_u *ZoneUpdateOne) SetParentCode(v string) *ZoneUpdateOne { + _u.mutation.SetParentCode(v) + return _u +} + +// SetNillableParentCode sets the "parent_code" field if the given value is not nil. +func (_u *ZoneUpdateOne) SetNillableParentCode(v *string) *ZoneUpdateOne { + if v != nil { + _u.SetParentCode(*v) + } + return _u +} + +// ClearParentCode clears the value of the "parent_code" field. +func (_u *ZoneUpdateOne) ClearParentCode() *ZoneUpdateOne { + _u.mutation.ClearParentCode() + return _u +} + // SetZoneCode sets the "zone_code" field. func (_u *ZoneUpdateOne) SetZoneCode(v string) *ZoneUpdateOne { _u.mutation.SetZoneCode(v) @@ -334,6 +514,12 @@ func (_u *ZoneUpdateOne) SetNillableZoneName(v *string) *ZoneUpdateOne { return _u } +// ClearZoneName clears the value of the "zone_name" field. +func (_u *ZoneUpdateOne) ClearZoneName() *ZoneUpdateOne { + _u.mutation.ClearZoneName() + return _u +} + // SetDescription sets the "description" field. func (_u *ZoneUpdateOne) SetDescription(v string) *ZoneUpdateOne { _u.mutation.SetDescription(v) @@ -547,12 +733,36 @@ func (_u *ZoneUpdateOne) sqlSave(ctx context.Context) (_node *Zone, err error) { } } } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(zone.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(zone.FieldLevel, field.TypeInt, value) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(zone.FieldCode, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(zone.FieldName, field.TypeString, value) + } + if _u.mutation.NameCleared() { + _spec.ClearField(zone.FieldName, field.TypeString) + } + if value, ok := _u.mutation.ParentCode(); ok { + _spec.SetField(zone.FieldParentCode, field.TypeString, value) + } + if _u.mutation.ParentCodeCleared() { + _spec.ClearField(zone.FieldParentCode, field.TypeString) + } if value, ok := _u.mutation.ZoneCode(); ok { _spec.SetField(zone.FieldZoneCode, field.TypeString, value) } if value, ok := _u.mutation.ZoneName(); ok { _spec.SetField(zone.FieldZoneName, field.TypeString, value) } + if _u.mutation.ZoneNameCleared() { + _spec.ClearField(zone.FieldZoneName, field.TypeString) + } if value, ok := _u.mutation.Description(); ok { _spec.SetField(zone.FieldDescription, field.TypeString, value) } diff --git a/bj_power_wms/etc/bj_power_wms-api-verify.yaml b/bj_power_wms/etc/bj_power_wms-api-verify.yaml index 4c246ab..7631a31 100644 --- a/bj_power_wms/etc/bj_power_wms-api-verify.yaml +++ b/bj_power_wms/etc/bj_power_wms-api-verify.yaml @@ -2,6 +2,7 @@ Name: bj_power_wms Host: 0.0.0.0 Port: 8902 Timeout: 10000 +MaxBytes: 52428800 # PostgreSQL Postgres: @@ -30,3 +31,12 @@ Redis: # 前端页面托管 Web: OpenBrowser: false + +# 附件存储(校验环境用临时目录,避免污染开发附件根目录) +Attachment: + RootDir: "D:/hardman/bj_power/attachments_verify" + DefaultMaxSize: 20971520 + LocalRetentionYears: 1 + DiskWarnPercent: 20 + DiskCriticalPercent: 10 + DiskCheckHour: 7 diff --git a/bj_power_wms/etc/bj_power_wms-api.yaml b/bj_power_wms/etc/bj_power_wms-api.yaml index 75c0097..b0cf006 100644 --- a/bj_power_wms/etc/bj_power_wms-api.yaml +++ b/bj_power_wms/etc/bj_power_wms-api.yaml @@ -2,6 +2,8 @@ Name: bj_power_wms Host: 0.0.0.0 Port: 8890 Timeout: 10000 +# 请求体上限:go-zero 默认仅 1MB,会拦住照片/PDF/Excel 上传;取各文件类型上限的最大值(50MB) +MaxBytes: 52428800 # PostgreSQL Postgres: @@ -46,3 +48,18 @@ Agv: # 前端页面托管(原库房客户端 8891 已合并进主服务) Web: OpenBrowser: true + +# 附件存储(年/月/日/文件类型/uuid.ext,库内只存相对路径,不存绝对路径) +# 生产环境改 RootDir: /data/bj_power/attachments +Attachment: + RootDir: "D:/hardman/bj_power/attachments" + DefaultMaxSize: 20971520 # 默认单文件 20MB + MaxSize: + PROCESS_PDF: 52428800 # 工艺流程作业指导书 50MB + INSPECTION_PHOTO: 20971520 # 检验照片 20MB + EXCEL_IMPORT: 10485760 # Excel 导入 10MB + LocalRetentionYears: 1 # 本地保留最近 1 年 + DiskWarnPercent: 20 # 剩余空间 <20% 告警 + DiskCriticalPercent: 10 # 剩余空间 <10% 提示清理/归档 + DiskCheckHour: 7 # 每天 07:00 检测 + ArchiveDir: "" # 外部备份目录(NAS/移动硬盘),留空则归档仅标记 diff --git a/bj_power_wms/frontend/src/help.js b/bj_power_wms/frontend/src/help.js index daeff47..04dda35 100644 --- a/bj_power_wms/frontend/src/help.js +++ b/bj_power_wms/frontend/src/help.js @@ -5,7 +5,7 @@ export const helpInbound = { title: '入库(来料入账)', overview: - '把到货的来料记入 WMS 库存。按管理类型分两种入库方式:\n· 结构件(螺丝/机加工件) → 按【批次】入库,一批多件;\n· 电气件(芯片/器件) → 按【SN 序列号】逐件扫码,可单件追溯。\n\n管理类型由 WMS 的"物料档案"决定(电气件/结构件),入库方式随之自动给出。\n入库是整个库存链路的第一环:入库(Held) → 质量检验(合格Z02) → 之后才能被出库锁定。\n\n本页四个页签(录入在前,记录在后点击才见),参照出库管理:\n· 结构件入库:按批次入库 + Excel 批量导入;\n· 电气件入库:逐件扫码 + Excel 批量导入;\n· 其他入库:辅料/螺栓/工装/试验设备等非结构件非电气件物料,规格型号强制;\n· 入库记录:分页列表(一单一行),点「明细」在右侧抽屉查看该单的行(懒加载+分页,不内嵌子表)。\n\n库位四级贯通:每笔入库除选「区域」外,还可录「货架/层/位置」三级货位,或点「推荐库位」由系统给出历史常用位+同区空位一键填入。', + '把到货的来料记入 WMS 库存。按管理类型分两种入库方式:\n· 结构件(螺丝/机加工件) → 按【批次】入库,一批多件;\n· 电气件(芯片/器件) → 按【SN 序列号】逐件扫码,可单件追溯。\n\n管理类型由 WMS 的"物料档案"决定(电气件/结构件),入库方式随之自动给出。\n入库是整个库存链路的第一环:入库(Held) → 质量检验(合格Z02) → 之后才能被出库锁定。\n\n本页四个页签(录入在前,记录在后点击才见),参照出库管理:\n· 结构件入库:按批次入库 + Excel 批量导入;\n· 电气件入库:逐件扫码 + Excel 批量导入;\n· 其他入库:辅料/螺栓/工装/试验设备等非结构件非电气件物料,规格型号强制;\n· 入库记录:分页列表(一单一行),点「明细」在右侧抽屉查看该单的行(懒加载+分页,不内嵌子表)。\n\n库位四级贯通:每笔入库除选「区域」外,还可录「货架/层/位置」三级货位;选物料后系统自动带入该物料最近一次入库的库位,可手动修改。', sections: [ { title: '结构件入库(页签1)', @@ -16,7 +16,7 @@ export const helpInbound = { { name: '数量', source: '手工填写整数。', purpose: '本批到货数量', fill: '整数 ≥1' }, { name: '区域', source: '下拉选择(必填)。数据来自"区域维护"。', purpose: '放到哪个库区(待检/合格/不合格…)', fill: '必填;新到货一般先放"待检"区,检验合格后再转"合格"区' }, { name: '货架/层/位', source: '手工填写(选填)。库位四级贯通的三级货位。', purpose: '精确到货位,便于拣配与盘点', fill: '如 货架A / 3层 / 12位;可留空只记区域' }, - { name: '推荐库位', source: '按钮 → 调 /zone/recommend。', purpose: '系统按该图号「历史常用位 + 同区空位」给候选,一键填入免手输', fill: '先选物料再点「推荐库位」,在弹窗点候选标签即回填区域+货架/层/位' }, + { name: '库位自动带入', source: '选物料后前端自动调 /inbound/last-location。', purpose: '回填该物料最近一次入库的库位(区域/货架/层/位置号),免手输', fill: '选物料即自动填入;可手动改到其他库位' }, { name: '生产日期', source: '手动选择日期。', purpose: '生产时间,用于时效和批次管理', fill: '选择日期' }, { name: '供应商', source: '手工填写。', purpose: '来料来源', fill: '供应商名称,可空' }, { name: '批量导入', source: '本页签下方。', purpose: '整表校验后一次性入库', fill: '模板(首行忽略表头):图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 备注。任一行错误则整体回退' } @@ -28,20 +28,20 @@ export const helpInbound = { fields: [ { name: '物料', source: '下拉选择(必填)。来自"物料档案"类型为"电气件"的物料。', purpose: '入库的电气件物料', fill: '选择图号' }, { name: '区域', source: '下拉选择(必填)。来自"区域维护"。', purpose: '放到哪个库区', fill: '必填;新到货一般先放"待检"区' }, - { name: '货架/层/位 · 推荐库位', source: '同结构件入库:三级货位手填 + 「推荐库位」一键填入。', purpose: '精确货位', fill: '选物料后点「推荐库位」取历史常用位/同区空位' }, + { name: '货架/层/位', source: '同结构件入库:三级货位手填,选物料后自动带入该物料最近一次入库库位。', purpose: '精确货位', fill: '选物料即自动填入,可手动改' }, { name: '扫码录入', source: '扫码枪连续扫码。来自每颗器件自带的 SN 条码。', purpose: '逐件登记 SN,实现单件追溯', fill: '扫入/粘贴 SN 后点【录入到列表】加入清单,可一次连续多条' }, { name: '批量导入', source: '本页签下方。', purpose: '整表校验后一次性入库', fill: '模板(首行忽略表头):图号 | SN | 区域 | 生产日期 | 供应商。任一行错误则整体回退' } ] }, { title: '其他入库(页签3)', - overview: '适用于辅料、螺栓、工装、试验设备等既非结构件也非电气件的物料;规格型号强制(在物料档案维护,为空则拒绝入库)。支持归属(无/工单号/科技项目号)与库位四级。', + overview: '适用于辅料、螺栓、工装、试验设备等既非结构件也非电气件的物料;规格型号强制(在物料档案维护,为空则拒绝入库)。支持归属(工单号/科技项目号/其他,必选)与库位四级。', fields: [ { name: '物料', source: '下拉选择。来自"物料档案"类型为"其他"的物料。', purpose: '入库的其他类物料', fill: '选择图号;规格型号由档案带出,缺失需先补档案' }, { name: '规格型号', source: '选物料后自动带出(只读)。', purpose: '其他类物料强制记录规格', fill: '只读;为空时无法提交,需先到物料档案补全' }, { name: '批次号/数量', source: '批次留空自动生成;数量手工整数。', purpose: '入账批次与数量', fill: '数量 ≥1' }, - { name: '区域 · 货架/层/位', source: '同结构件入库,含「推荐库位」。', purpose: '库位四级贯通', fill: '选区域,可录三级货位或用推荐' }, - { name: '归属', source: '下拉:无 / 工单号 / 科技项目号。', purpose: '标记该批其他物料归属哪个工单或科技项目', fill: '选"无"外的项须填归属编号' }, + { name: '区域 · 货架/层/位', source: '同结构件入库,选物料后自动带入最近库位。', purpose: '库位四级贯通', fill: '选区域,可录三级货位或自动带入' }, + { name: '归属', source: '下拉:工单号 / 科技项目号 / 其他(必选,不再有"无")。', purpose: '标记该批其他物料归属哪个工单或科技项目', fill: '必选一项;选"其他"可不填编号,选"工单号/科技项目号"须填归属编号' }, { name: '检测单号', source: '手工填写(必填)。', purpose: '与入库检报告关联,检验页跳转可自动带入', fill: '必填;从检验页「去入库」跳转时自动回填' } ] }, @@ -49,7 +49,8 @@ export const helpInbound = { title: '入库记录(页签4)', overview: '分页展示全部入库单,结构件/电气件/其他同表(用"类型"列区分)。支持按入库单号、图号、类型、物料名称、入库时间筛选(各字段独立,无关键字混搜);列表含「区域」「库位」「检测单号」「质量状态」「归属」列;可按当前条件导出 xlsx。点行「明细」在右侧抽屉查看该单的批次号/SN 行(懒加载+分页,避免电气件上万条 SN 撑爆前端)。', fields: [ - { name: '查询条件', source: '本页签顶部筛选区。', purpose: '缩小列表范围', fill: '可组合:入库单号(模糊)/图号(模糊)/类型(全部·结构件·电气件·其他)/物料名称(模糊)/入库时间区间' }, + { name: '查询条件', source: '本页签顶部筛选区。', purpose: '缩小列表范围', fill: '可组合:入库单号(模糊)/图号(模糊)/类型(全部·结构件·电气件·其他)/物料名称(模糊)/状态(全部·有效·已作废)/入库时间区间' }, + { name: '状态 / 作废', source: '行「状态」列 + 行末「作废」按钮(权限 inbound:void)。', purpose: '作废错误入库单并回滚库存', fill: '点「作废」填写作废原因→确认;结构件按批次回滚数量、电气件按 SN 精确回滚(不影响其它单);已锁定/已出库的批次或 SN 须先处理' }, { name: '明细', source: '行末「明细」按钮 → 右侧抽屉。', purpose: '查看该入库单的批次号/SN/数量明细', fill: '抽屉内分页展示,不回列表里嵌套子表' }, { name: '附件', source: '入库单行内附件(AttachmentPanel)。', purpose: '为入库单上传/查看随货单据、质检报告等附件', fill: '点行内附件按钮,在抽屉中上传或查看' }, { name: '导出', source: '按钮。后端 /inbound/export 按当前条件返回全部(不分页)。', purpose: '把筛选结果一次性导出为 xlsx', fill: '点【导出】下载"入库管理.xlsx"' } @@ -201,14 +202,15 @@ export const helpAgv = { export const helpZone = { title: '区域维护(库位四级)', overview: - '维护库区/库位字典,供入库/半成品/出库等所有页面的"区域"下拉框选择。\n库位按四级定位:区域编码 → 货架号 → 层 → 位置号(后三级手工填写,可空);区域编码是货品存放的物理库区(如待检、合格 Z02、不合格…),入库时必须指明放到哪个区,质量检验合格后再转移到合格区。\n\n库位推荐(拒绝全自动识别,人工一键确认或手改):入库选物料后可查该物料的推荐库位——系统给出「历史常用位」(该物料最近使用过的库位,按最近使用排序,最多 5 个)与「空闲库位」(启用且当前无在库/锁定库存引用的库位,最多 10 个;若该物料有历史常用区域,则同区域空位排在前面),由库房人员一键采用或手动改写。\n\n区域字典是库房的第一道地基:先建好区域,入库、检验、出库才能选到正确的存放位置。', + '维护库区/库位字典,供入库/半成品/出库等所有页面的"区域"下拉框选择。\n库位按四级结构组织:区域 → 货架 → 层 → 位置号,四个页签各自独立维护、独立分页、按上级筛选。上级字段用下拉选择(不重复录入)。\n\n· 区域:物理库区(如待检、合格 Z02、不合格…),入库时必须指明放到哪个区,质量检验合格后再转移到合格区;\n· 货架:挂在某个区域下;新建货架时会自动创建一个「默认位置」,物料可不细分到层时直接挂这里;\n· 层:挂在某个货架下;\n· 位置号:挂在某个层(或货架默认位置)下,可填「位置名称」(如"A架3层12位",可空)。\n\n位置号支持「批量生成」:选区域 → 货架 → 层范围 → 位置范围,先预览(标出已存在)再确认写入,已存在的位置自动跳过。\n\n区域字典是库房的第一道地基:先建好区域,入库、检验、出库才能选到正确的存放位置。', fields: [ - { name: '区域编码', source: '手工填写,仓库自定义(新增后不可改)。', purpose: '库区/库位唯一编号,入库/出库据此定位存放位置', fill: '如 Z02、Z05,建议字母+数字,唯一;新增后不可改' }, + { name: '区域编码', source: '手工填写,仓库自定义(新增后不可改)。', purpose: '库区唯一编号', fill: '如 Z02、Z05,建议字母+数字,唯一;新增后不可改' }, { name: '区域名称', source: '手工填写。', purpose: '库区中文名,便于识别', fill: '如 合格区、待检区、不合格区' }, - { name: '货架号', source: '手工填写(可空)。库位四级第二级。', purpose: '库位所在货架编号,细化存放位置', fill: '如 A、B;可空' }, - { name: '层', source: '手工填写(可空)。库位四级第三级。', purpose: '货架第几层', fill: '如 3;可空' }, - { name: '位置号', source: '手工填写(可空)。库位四级第四级。', purpose: '该层的具体位置', fill: '如 12;可空' }, - { name: '库位推荐', source: '入库选物料后系统计算(历史常用位 + 同区空位优先)。', purpose: '辅助库房快速定位应放库位,避免全自动误判', fill: '从推荐的历史位/空位中一键采用,或手动改写区域' }, + { name: '货架号', source: '新增货架时从「所属区域」下拉选,再填货架号。', purpose: '库位第二级,细化存放位置', fill: '如 A、B' }, + { name: '层号', source: '新增层时从「所属区域+货架」下拉选,再填层号。', purpose: '库位第三级', fill: '如 3' }, + { name: '位置号', source: '新增位置号时从「区域+货架+(层)」下拉选,再填位置号;层留空=该货架默认位置。', purpose: '库位第四级,最小存放单位', fill: '如 12' }, + { name: '位置名称', source: '手工填写(可空)。', purpose: '位置的中文说明', fill: '如 A架3层12位;可空' }, + { name: '批量生成', source: '位置号页签「批量生成」按钮。', purpose: '一次生成一批位置号(货架 × 层范围 × 位置范围)', fill: '选区域+货架+层范围+位置范围 → 预览 → 确认生成;已存在的自动跳过' }, { name: '说明', source: '手工填写(可空)。', purpose: '补充描述', fill: '可空' } ] } @@ -227,19 +229,33 @@ export const helpDock = { ] } +export const helpAttachment = { + title: '附件中心', + overview: + '统一查看全系统上传的附件(图纸/报告/照片/Excel 等)。附件按「业务类型」挂靠具体单据,磁盘按「年/月/日/文件类型/uuid.ext」分层存储,库内只存相对路径。\n\n本页只读查询 + 预览/下载/删除;删除为逻辑删除(索引标记,文件由「归档清理」统一处理)。顶部会显示附件磁盘剩余空间告警:低于 20% 提醒、低于 10% 提示立即归档清理。\n\n归档策略:本地保留最近 1 年(可在配置 Attachment.LocalRetentionYears 调整),早于此的附件可「归档清理」——备份到外部目录(Attachment.ArchiveDir)并标记已归档,索引保留可追溯。', + fields: [ + { name: '文件类型', source: '筛选条件。文件类型目录(大写),决定磁盘存放目录。', purpose: '按附件类别过滤', fill: '工艺流程/检验照片/检验报告/图纸/流程卡/包装照片/Excel导入/其他' }, + { name: '业务类型', source: '筛选条件。附件挂靠的业务对象。', purpose: '只看某类业务的附件', fill: '入库/物料档案/质量检验/半成品/出库' }, + { name: '业务标识', source: '筛选条件。', purpose: '按单号/编码/ID 定位某条业务记录的附件', fill: '如入库单号、物料编码、检验记录 ID' }, + { name: '查看 / 下载', source: '行末按钮。', purpose: '在线预览(PDF/图片)或下载原件', fill: '查看=新窗口内联预览;下载=带原文件名下载' }, + { name: '删除', source: '行末按钮(权限 attachment:manage)。', purpose: '逻辑删除附件索引(文件待归档任务清理)', fill: '确认后标记已删除;可勾选「含已删除」查看' }, + { name: '归档清理', source: '按钮(权限 attachment:manage)。', purpose: '把早于本地保留年数的附件备份到外部目录并标记归档,释放本地空间', fill: '点「归档清理」确认执行;结果给出移动/标记/失败条数' }, + { name: '磁盘告警', source: '系统每天早上 7:00 自动检测附件目录剩余空间。', purpose: '提前发现空间不足,避免写入失败', fill: '剩余 <20% 告警、<10% 提示立即归档清理;本页顶部同步展示' } + ] +} + export const helpMaterial = { title: '物料档案', overview: '定义每一种物料的字典:叫什么、什么规格、什么品类(原材料/半成品/成品/其他)、是【结构件(批次)】还是【电气件(SN)】。\n此处维护的物料会作为下拉选项出现在入库/出库/装箱等页面;其中"类型"直接决定后续入库方式——结构件走批次(一批多件)、电气件走 SN 逐件扫码(单件追溯)。\n\n品类来源:原材料=进货来的(外购);半成品、成品=自己生产的;其他=辅料/工装/试验设备等。成品还可以作为零部件,放进另一个成品的物料清单(BOM)里被再次加工成新的成品。\n\n品类说明:1=原材料(默认) / 2=半成品 / 3=成品 / 4=其他(辅料/工装/试验设备)。编码主数据单一来源在本表:MES 的「物料档案」页面即是本表中"成品"品类的视图(实时拉取本表,不双录)——两系统的「物料档案」指向同一份主数据,以本表为准。库存主表 inventories 的品类与其呼应。列表支持按品类筛选,导出含品类列。\n\n物料档案是库房的另一道地基:先建好物料,入库时才能选到;类型选错会导致入库方式与追溯粒度不符。\n\n命名说明:本档案维护的物料在出库/看板等页面统一以"图号"展示(客户口径)。安全库存在本档案维护,可用量低于它时会在「库房看板」首页触发缺货预警。', fields: [ { name: '图号', source: '手工填写,仓库自定义(新增后不可改)。在出库/看板等页面显示为"图号"。', purpose: '物料唯一编号(即图号)', fill: '如 SCREW-M3;新增后不可改编码' }, - { name: '名称', source: '手工填写。', purpose: '物料名称', fill: '如 螺丝 M3' }, - { name: '简称', source: '手工填写(可空)。', purpose: '简写', fill: '可空' }, - { name: '规格', source: '手工填写(可空)。', purpose: '规格型号', fill: '可空' }, - { name: '单位', source: '手工填写。', purpose: '计量单位', fill: '如 个/套' }, - { name: '品类', source: '创建时默认"原材料";成品品类也可在 MES 的「物料档案」页维护(两系统同一份主数据,以本表为准)。', purpose: '区分原材料/半成品/成品/其他,与统一库存主表品类对应;原材料为进货、半成品/成品为自产', fill: '查询区可选 原材料/半成品/成品/其他' }, - { name: '类型', source: '选择:1=结构件(批次管理) / 2=电气件(SN 管理)。语义由库房定:结构件按批次管理,电气件按 SN 逐件管理。', purpose: '决定入库方式:结构件走批次、电气件走 SN 逐件扫码', fill: '结构件(批次) / 电气件(SN)' }, - { name: '安全库存', source: '手工填写整数(默认0)。', purpose: '该物料的最低库存警戒线;可用量低于它会在「库房看板」首页触发缺货预警', fill: '如 100;0=不预警' }, + { name: '名称', source: '手工填写(必填)。', purpose: '物料名称', fill: '如 螺丝 M3' }, + { name: '规格', source: '手工填写(必填)。', purpose: '规格型号', fill: '如 M3×8' }, + { name: '单位', source: '手工填写(必填)。', purpose: '计量单位', fill: '如 个/套' }, + { name: '品类', source: '必填。创建时默认"原材料";成品品类也可在 MES 的「物料档案」页维护(两系统同一份主数据,以本表为准)。', purpose: '区分原材料/半成品/成品/其他,与统一库存主表品类对应;原材料为进货、半成品/成品为自产', fill: '查询区可选 原材料/半成品/成品/其他' }, + { name: '类型', source: '必填(「其他」类不做 SN,固定为结构件)。选择:1=结构件(批次管理) / 2=电气件(SN 管理)。语义由库房定:结构件按批次管理,电气件按 SN 逐件管理。', purpose: '决定入库方式:结构件走批次、电气件走 SN 逐件扫码', fill: '结构件(批次) / 电气件(SN)' }, + { name: '安全库存', source: '必填整数(默认0)。', purpose: '该物料的最低库存警戒线;可用量低于它会在「库房看板」首页触发缺货预警', fill: '如 100;0=不预警' }, { name: '说明', source: '手工填写(可空)。', purpose: '补充描述', fill: '可空' } ] } diff --git a/bj_power_wms/frontend/src/layouts/MainLayout.vue b/bj_power_wms/frontend/src/layouts/MainLayout.vue index cbd7195..bcf0dc7 100644 --- a/bj_power_wms/frontend/src/layouts/MainLayout.vue +++ b/bj_power_wms/frontend/src/layouts/MainLayout.vue @@ -4,7 +4,7 @@ import { useRoute, useRouter } from 'vue-router' import { ElMessage } from 'element-plus' import { HomeFilled, Download, Upload, Search, CircleCheck, List, - Box, Tickets, Monitor, EditPen, Fold, Expand, Location, Goods, Key, Operation, Van, Clock, RefreshLeft, Aim + Box, Tickets, Monitor, EditPen, Fold, Expand, Location, Goods, Key, Operation, Van, Clock, RefreshLeft, Aim, Folder } from '@element-plus/icons-vue' import { getUser, getToken, logout, setSession } from '../utils/auth' import request from '../utils/request' @@ -101,7 +101,8 @@ const menuGroups = [ title: '系统管理', icon: Key, children: [ { path: '/users', title: '账号管理', icon: EditPen, code: 'user:manage' }, { path: '/roles', title: '角色管理', icon: Key, code: 'role:manage' }, - { path: '/event-log', title: '操作日志', icon: Clock, code: 'eventlog:manage' } + { path: '/event-log', title: '操作日志', icon: Clock, code: 'eventlog:manage' }, + { path: '/attachment', title: '附件中心', icon: Folder, code: 'attachment:view' } ] } ] diff --git a/bj_power_wms/frontend/src/pages/AttachmentCenter.vue b/bj_power_wms/frontend/src/pages/AttachmentCenter.vue new file mode 100644 index 0000000..9e61e32 --- /dev/null +++ b/bj_power_wms/frontend/src/pages/AttachmentCenter.vue @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 含已删除 + + + 查询 + 重置 + 归档清理 + + + + + + + + {{ fileTypeText(row.fileType) }} + + + {{ bizTypeText(row.bizType) }} + + + + {{ sizeText(row.fileSize) }} + + + {{ row.uploadedBy || '-' }} + + + {{ fmtTime(row.createdAt) }} + + + + 已删除 + 已归档 + 正常 + + + + + 查看 + 下载 + 删除 + + + + + { page.current = p; load() }" + @size-change="(s) => { page.size = s; page.current = 1; load() }" /> + + + + + + + + diff --git a/bj_power_wms/frontend/src/pages/BaseData.vue b/bj_power_wms/frontend/src/pages/BaseData.vue index f6c8431..c34634c 100644 --- a/bj_power_wms/frontend/src/pages/BaseData.vue +++ b/bj_power_wms/frontend/src/pages/BaseData.vue @@ -29,169 +29,204 @@ function defaultStart() { return `${y}-${m}-${day}` } -/* ---------- 区域维护 ---------- */ -const zones = ref([]) -const zoneTotal = ref(0) -const zoneLoading = ref(false) -// 筛选拆分为独立条件(区域维护无需时间范围,已去除) -const zoneFilter = reactive({ - zoneCode: '', zoneName: '', status: '' +/* ---------- 区域维护(库位四级:区域/货架/层/位置号 4 个独立 Tab) ---------- */ +const zoneLevels = [ + { level: 1, name: '区域', codeLabel: '区域编码', nameLabel: '区域名称' }, + { level: 2, name: '货架', codeLabel: '货架号' }, + { level: 3, name: '层', codeLabel: '层号' }, + { level: 4, name: '位置号', codeLabel: '位置号', nameLabel: '位置名称' } +] +const activeZoneTab = ref(1) +const zoneTabLoaded = reactive({ 1: false, 2: false, 3: false, 4: false }) + +function makeNodeState() { + return reactive({ + list: [], total: 0, loading: false, + page: { current: 1, size: 10 }, + filter: { zoneCode: '', shelfNo: '', layerNo: '', keyword: '', status: '' } + }) +} +const nodeState = { 1: makeNodeState(), 2: makeNodeState(), 3: makeNodeState(), 4: makeNodeState() } + +// 父级下拉选项:区域选项全局共享;货架/层选项按 Tab 各自独立,避免联动互相污染 +const regionOptions = ref([]) +const f2Shelf = ref([]); const f3Shelf = ref([]); const f3Layer = ref([]) +const f4Shelf = ref([]); const f4Layer = ref([]) +const cShelf = ref([]); const cLayer = ref([]) +const bShelf = ref([]) + +async function picker(level, params) { + const data = await request.get('/zone/picker', { params: { level, ...params } }) + return data || [] +} +async function loadRegions() { + regionOptions.value = await picker(1, {}) +} +async function loadShelfOpts(target, zoneCode) { + target.value = zoneCode ? await picker(2, { zoneCode }) : [] +} +async function loadLayerOpts(target, zoneCode, shelfNo) { + target.value = (zoneCode && shelfNo) ? await picker(3, { zoneCode, shelfNo }) : [] +} + +async function loadNodes(level) { + const s = nodeState[level] + s.loading = true + try { + const params = { + level, + page: s.page.current, + pageSize: s.page.size, + keyword: (s.filter.keyword || '').trim(), + status: s.filter.status + } + if (level >= 2) params.zoneCode = (s.filter.zoneCode || '').trim().toUpperCase() + if (level >= 3) params.shelfNo = (s.filter.shelfNo || '').trim() + if (level >= 4) params.layerNo = (s.filter.layerNo || '').trim() + const data = await request.get('/zone/list', { params }) + s.list = data?.list || [] + s.total = data?.total || 0 + } finally { + s.loading = false + } +} + +// 进入某 Tab:首次加载列表,并确保上级下拉选项就绪 +async function onZoneTabChange(level) { + activeZoneTab.value = level + const f = nodeState[level].filter + if (level >= 2 && f.zoneCode) await loadShelfOpts(level === 2 ? f2Shelf : level === 3 ? f3Shelf : f4Shelf, f.zoneCode) + if ((level === 3 || level === 4) && f.zoneCode && f.shelfNo) { + await loadLayerOpts(level === 3 ? f3Layer : f4Layer, f.zoneCode, f.shelfNo) + } + if (!zoneTabLoaded[level]) { + await loadNodes(level) + zoneTabLoaded[level] = true + } +} + +function searchNodes(level) { + nodeState[level].page.current = 1 + loadNodes(level) +} + +// 筛选区:区域/货架/层 联动 +async function onFilterRegion(level) { + const zc = nodeState[level].filter.zoneCode + nodeState[level].filter.shelfNo = '' + nodeState[level].filter.layerNo = '' + const t = level === 2 ? f2Shelf : level === 3 ? f3Shelf : f4Shelf + await loadShelfOpts(t, zc) + if (level === 4) f4Layer.value = [] +} +async function onFilterShelf(level) { + const f = nodeState[level].filter + f.layerNo = '' + const t = level === 3 ? f3Layer : f4Layer + await loadLayerOpts(t, f.zoneCode, f.shelfNo) +} + +/* ---------- 区域维护:新增/编辑弹窗(按层级复用同一弹窗) ---------- */ +const nodeDialog = ref(false) +const nodeEditing = ref(false) +const nodeForm = reactive({ + level: 1, id: 0, code: '', name: '', remark: '', status: '启用', + regionCode: '', shelfCode: '', layerCode: '' }) -const zonePage = reactive({ current: 1, size: 10 }) +const nodeSaving = ref(false) -const zoneDialog = ref(false) -// 区域维护按「区域编码」分组:编辑键是 zoneCode(不是单行 id),一个区域可挂多个货位 -const zoneEditingCode = ref('') -// 区域库位:区域 → 货架号 → 第几层 → 位置号(客户诉求 问题记录 L32/L169,手填) -// 一个区域下可有多个货位,故 locations 为数组;新增时默认给一行 -const zoneForm = reactive({ zoneCode: '', zoneName: '', description: '', status: '启用', locations: [] }) -const zoneSaving = ref(false) - -// 批量生成货位(货架号 × 层区间 × 位置区间),解决「一个货架不止一层、每层不止一个位置号」的逐条录入 -const genForm = reactive({ shelfNo: '', layerFrom: 1, layerTo: 1, posFrom: 1, posTo: 1 }) - -function newZoneLocation() { - return { id: 0, shelfNo: '', layerNo: '', positionNo: '' } +function openNodeCreate(level) { + nodeEditing.value = false + Object.assign(nodeForm, { level, id: 0, code: '', name: '', remark: '', status: '启用', regionCode: '', shelfCode: '', layerCode: '' }) + nodeDialog.value = true +} +function openNodeEdit(row) { + nodeEditing.value = true + const f = { level: row.level, id: row.id, code: row.code, name: row.name || '', remark: row.description || '', status: row.status || '启用', regionCode: '', shelfCode: '', layerCode: '' } + if (row.level === 2) f.regionCode = row.zoneCode + if (row.level === 3) { f.regionCode = row.zoneCode; f.shelfCode = row.shelfNo } + if (row.level === 4) { f.regionCode = row.zoneCode; f.shelfCode = row.shelfNo; f.layerCode = row.layerNo } + Object.assign(nodeForm, f) + nodeDialog.value = true +} +function nodeParentCode() { + if (nodeForm.level === 1) return '' + if (nodeForm.level === 2) return nodeForm.regionCode + if (nodeForm.level === 3) return nodeForm.shelfCode + return nodeForm.layerCode || nodeForm.shelfCode +} +async function onNodeRegionChange() { + nodeForm.shelfCode = '' + nodeForm.layerCode = '' + await loadShelfOpts(cShelf, nodeForm.regionCode) +} +async function onNodeShelfChange() { + nodeForm.layerCode = '' + await loadLayerOpts(cLayer, nodeForm.regionCode, nodeForm.shelfCode) } -// 货位标签(区域-货架-层-位置),仅用于分组子表展示,口径与后端 locLabel 一致 -function zoneLocLabel(zoneCode, loc) { - const parts = [] - if (zoneCode) parts.push(zoneCode) - if (loc.shelfNo) parts.push(loc.shelfNo + '架') - if (loc.layerNo) parts.push(loc.layerNo + '层') - if (loc.positionNo) parts.push(loc.positionNo + '位') - return parts.length ? parts.join('-') : '(未填写货位)' -} - -async function loadZones() { - zoneLoading.value = true +async function saveNode() { + if (!nodeForm.code) { ElMessage.warning('编码必填'); return } + if (nodeForm.level === 1 && !nodeForm.name) { ElMessage.warning('区域名称必填'); return } + if (nodeForm.level === 2 && !nodeForm.regionCode) { ElMessage.warning('请选择所属区域'); return } + if (nodeForm.level === 3 && !nodeForm.shelfCode) { ElMessage.warning('请选择所属货架'); return } + if (nodeForm.level === 4 && !nodeForm.shelfCode) { ElMessage.warning('请选择所属货架'); return } + nodeSaving.value = true try { - const data = await request.get('/zone/grouped', { - params: { - zoneCode: zoneFilter.zoneCode.trim().toUpperCase(), - zoneName: zoneFilter.zoneName.trim(), - status: zoneFilter.status, - page: zonePage.current, - pageSize: zonePage.size - } - }) - zones.value = data?.list || [] - zoneTotal.value = data?.total || 0 - } finally { - zoneLoading.value = false - } -} - -function searchZones() { - zonePage.current = 1 - loadZones() -} - -function openZoneCreate() { - zoneEditingCode.value = '' - Object.assign(zoneForm, { - zoneCode: '', zoneName: '', description: '', status: '启用', - locations: [newZoneLocation()] - }) - Object.assign(genForm, { shelfNo: '', layerFrom: 1, layerTo: 1, posFrom: 1, posTo: 1 }) - zoneDialog.value = true -} - -function openZoneEdit(row) { - zoneEditingCode.value = row.zoneCode - Object.assign(zoneForm, { - zoneCode: row.zoneCode, - zoneName: row.zoneName, - description: row.description || '', - status: row.status || '启用', - locations: (row.locations || []).map((l) => ({ - id: l.id, shelfNo: l.shelfNo || '', layerNo: l.layerNo || '', positionNo: l.positionNo || '' - })) - }) - if (!zoneForm.locations.length) zoneForm.locations.push(newZoneLocation()) - Object.assign(genForm, { shelfNo: '', layerFrom: 1, layerTo: 1, posFrom: 1, posTo: 1 }) - zoneDialog.value = true -} - -function addZoneLocation() { - zoneForm.locations.push(newZoneLocation()) -} - -function removeZoneLocation(idx) { - if (zoneForm.locations.length <= 1) { - ElMessage.warning('至少保留一个货位') - return - } - zoneForm.locations.splice(idx, 1) -} - -// 按 货架号 × [层区间] × [位置区间] 笛卡尔积批量追加货位行 -function genZoneLocations() { - const shelf = (genForm.shelfNo || '').trim() - const lf = Number(genForm.layerFrom), lt = Number(genForm.layerTo) - const pf = Number(genForm.posFrom), pt = Number(genForm.posTo) - if (!Number.isInteger(lf) || !Number.isInteger(lt) || !Number.isInteger(pf) || !Number.isInteger(pt) || - lf < 0 || lt < lf || pf < 0 || pt < pf) { - ElMessage.warning('层/位置的起止值不合法(起始需 ≤ 结束)') - return - } - const count = (lt - lf + 1) * (pt - pf + 1) - if (count > 200) { - ElMessage.warning('一次最多生成 200 个货位,请缩小范围') - return - } - for (let l = lf; l <= lt; l++) { - for (let p = pf; p <= pt; p++) { - zoneForm.locations.push({ id: 0, shelfNo: shelf, layerNo: String(l), positionNo: String(p) }) - } - } - ElMessage.success(`已生成 ${count} 个货位行,可再手动微调`) -} - -async function saveZone() { - if (!zoneForm.zoneCode || !zoneForm.zoneName) { - ElMessage.warning('区域编码和区域名称必填') - return - } - if (!zoneForm.locations.length) { - ElMessage.warning('至少填写一个货位') - return - } - try { - await ElMessageBox.confirm('确认保存该区域信息吗?保存后将写入数据库。', '操作确认', { - confirmButtonText: '确认保存', - cancelButtonText: '取消', - type: 'warning' - }) - } catch { - return - } - zoneSaving.value = true - try { - const payload = { - zoneCode: zoneForm.zoneCode, - zoneName: zoneForm.zoneName, - description: zoneForm.description, - status: zoneForm.status, - locations: zoneForm.locations.map((l) => ({ - id: l.id || 0, - shelfNo: (l.shelfNo || '').trim(), - layerNo: (l.layerNo || '').trim(), - positionNo: (l.positionNo || '').trim() - })) - } - if (zoneEditingCode.value) { - await request.post('/zone/update', payload) - ElMessage.success('区域修改成功') + if (nodeEditing.value) { + await request.post('/zone/node/update', { id: nodeForm.id, name: nodeForm.name, remark: nodeForm.remark, status: nodeForm.status }) + ElMessage.success('修改成功') } else { - await request.post('/zone/create', payload) - ElMessage.success('区域新增成功') + await request.post('/zone/node/create', { + level: nodeForm.level, code: nodeForm.code, name: nodeForm.name, + parentCode: nodeParentCode(), remark: nodeForm.remark + }) + ElMessage.success('新增成功') } - zoneDialog.value = false - await loadZones() + nodeDialog.value = false + zoneTabLoaded[nodeForm.level] = false + await loadNodes(nodeForm.level) } finally { - zoneSaving.value = false + nodeSaving.value = false + } +} + +/* ---------- 区域维护:位置号批量生成 ---------- */ +const batchDialog = ref(false) +const batchForm = reactive({ zoneCode: '', shelfNo: '', layerStart: 1, layerEnd: 1, posStart: 1, posEnd: 1 }) +const batchPreview = ref([]) +const batchPreviewing = ref(false) +const batchSubmitting = ref(false) + +function openBatchGen() { + Object.assign(batchForm, { zoneCode: '', shelfNo: '', layerStart: 1, layerEnd: 1, posStart: 1, posEnd: 1 }) + batchPreview.value = [] + batchDialog.value = true +} +async function onBatchRegionChange() { + batchForm.shelfNo = '' + await loadShelfOpts(bShelf, batchForm.zoneCode) +} +async function previewBatch() { + if (!batchForm.zoneCode || !batchForm.shelfNo) { ElMessage.warning('请选择区域与货架'); return } + batchPreviewing.value = true + try { + const data = await request.post('/zone/batch-generate', { ...batchForm, preview: true }) + batchPreview.value = data?.list || [] + } finally { + batchPreviewing.value = false + } +} +async function submitBatch() { + batchSubmitting.value = true + try { + const data = await request.post('/zone/batch-generate', { ...batchForm, preview: false }) + ElMessage.success(`已生成 ${data?.created || 0} 个位置,跳过已存在 ${data?.skipped || 0} 个`) + batchDialog.value = false + zoneTabLoaded[4] = false + if (activeZoneTab.value === 4) await loadNodes(4) + } finally { + batchSubmitting.value = false } } @@ -207,7 +242,7 @@ const matPage = reactive({ current: 1, size: 10 }) const matDialog = ref(false) const mEditingId = ref(0) const mForm = reactive({ - code: '', name: '', shortName: '', spec: '', unit: '', + code: '', name: '', spec: '', unit: '', manageMode: 1, templateCode: '', description: '', itemType: 1, safetyStock: 0 }) @@ -244,7 +279,7 @@ function searchMaterials() { function resetMForm() { mEditingId.value = 0 Object.assign(mForm, { - code: '', name: '', shortName: '', spec: '', unit: '', + code: '', name: '', spec: '', unit: '', manageMode: 1, templateCode: '', description: '', itemType: 1, safetyStock: 0 }) @@ -258,7 +293,7 @@ function openMatCreate() { function openMatEdit(row) { mEditingId.value = row.id Object.assign(mForm, { - code: row.code, name: row.name, shortName: row.shortName || '', + code: row.code, name: row.name, spec: row.spec || '', unit: row.unit || '', manageMode: row.manageMode, templateCode: row.templateCode || '', itemType: row.itemType || 1, @@ -269,13 +304,29 @@ function openMatEdit(row) { } async function saveMaterial() { - if (!mForm.code || !mForm.name) { - ElMessage.warning('图号和名称必填') + // 必填口径(2026-09-19 用户裁决):除「说明」外全部必填。 + // 图号只在新增时必填(编辑不可改);「其他」类不做 SN,类型由后端收敛。 + if (!mEditingId.value && !String(mForm.code || '').trim()) { + ElMessage.warning('图号为必填项') return } - // 其他类物料规格强制(客户诉求 问题记录 L50) - if (Number(mForm.itemType) === 4 && !String(mForm.spec || '').trim()) { - ElMessage.warning('「其他」类物料必须填写规格型号') + const required = [ + ['name', mForm.name, '名称'], + ['spec', mForm.spec, '规格型号'], + ['unit', mForm.unit, '单位'] + ] + for (const [, val, label] of required) { + if (!String(val || '').trim()) { + ElMessage.warning(label + '为必填项') + return + } + } + if (!Number(mForm.itemType)) { + ElMessage.warning('品类为必填项') + return + } + if (Number(mForm.itemType) !== 4 && !Number(mForm.manageMode)) { + ElMessage.warning('类型为必填项') return } try { @@ -289,18 +340,23 @@ async function saveMaterial() { } mSaving.value = true try { + // 「其他」类(品类=4)不做 SN,管理粒度固定结构件(1),与后端收敛口径一致 + const manageMode = Number(mForm.itemType) === 4 ? 1 : Number(mForm.manageMode) + const base = { + name: String(mForm.name || '').trim(), + spec: String(mForm.spec || '').trim(), + unit: String(mForm.unit || '').trim(), + description: mForm.description, + itemType: Number(mForm.itemType), + manageMode, + safetyStock: Number(mForm.safetyStock) || 0 + } if (mEditingId.value) { - await request.post('/material/update', { - id: mEditingId.value, name: mForm.name, shortName: mForm.shortName, - spec: mForm.spec, unit: mForm.unit, description: mForm.description, - itemType: Number(mForm.itemType), - safetyStock: Number(mForm.safetyStock) || 0, - manageMode: mForm.manageMode - }) + await request.post('/material/update', { id: mEditingId.value, ...base }) ElMessage.success('物料修改成功') matDialog.value = false } else { - const created = await request.post('/material/create', { ...mForm, itemType: Number(mForm.itemType), safetyStock: Number(mForm.safetyStock) || 0 }) + const created = await request.post('/material/create', { code: String(mForm.code || '').trim(), ...base }) ElMessage.success('物料新增成功,可继续上传图纸/附件') // 创建成功后切到编辑态:保持弹窗打开,便于立即上传附件 mEditingId.value = created?.id || 0 @@ -333,7 +389,7 @@ function onItemTypeChange(v) { // 区域维护 / 物料档案共用同一组件:切换菜单时复用,watch(mode, immediate) 保证进入即加载 watch( () => props.mode, - (m) => { if (m === 'material') loadMaterials(); else loadZones() }, + (m) => { if (m === 'material') loadMaterials(); else { loadRegions(); onZoneTabChange(1) } }, { immediate: true } ) @@ -405,159 +461,278 @@ async function onMaterialFile(e) { - + - - - - - - - - - - - - - - - 查询 - 新增区域 - - - - - - - - - - - {{ loc.shelfNo || '-' }} - - - {{ loc.layerNo || '-' }} - - - {{ loc.positionNo || '-' }} - - - {{ zoneLocLabel(row.zoneCode, loc) }} - - - - - - - - - - {{ row.locationCount || 0 }} - - - - - - {{ row.status || '启用' }} - - - - - {{ row.description || '-' }} - - - {{ fmtTime(row.createdAt) }} - - - - 编辑 - - - - - { zonePage.current = p; loadZones() }" - @size-change="(s) => { zonePage.size = s; zonePage.current = 1; loadZones() }" /> - + onZoneTabChange(Number(n))"> + + + + + + + + + + + + + + 查询 + 新增区域 + + + + + + {{ row.zoneName || row.name || '-' }} + + + + {{ row.status || '启用' }} + + + + {{ row.description || '-' }} + + + {{ fmtTime(row.createdAt) }} + + + + 编辑 + + + + + { nodeState[1].page.current = p; loadNodes(1) }" + @size-change="(s) => { nodeState[1].page.size = s; nodeState[1].page.current = 1; loadNodes(1) }" /> + + - + + + + + + + + + + + + + + + + + + + 查询 + 新增货架 + + + + + {{ row.zoneName || row.zoneCode || '-' }} + + + + {{ row.status || '启用' }} + + + {{ fmtTime(row.createdAt) }} + + + 编辑 + + + + { nodeState[2].page.current = p; loadNodes(2) }" + @size-change="(s) => { nodeState[2].page.size = s; nodeState[2].page.current = 1; loadNodes(2) }" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询 + 新增层 + + + + {{ row.zoneName || row.zoneCode || '-' }} + {{ row.shelfNo || '-' }} + + {{ row.status || '启用' }} + {{ fmtTime(row.createdAt) }} + 编辑 + + + { nodeState[3].page.current = p; loadNodes(3) }" + @size-change="(s) => { nodeState[3].page.size = s; nodeState[3].page.current = 1; loadNodes(3) }" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询 + 新增位置号 + 批量生成 + + + + {{ row.zoneName || row.zoneCode || '-' }} + {{ row.shelfNo || '-' }} + {{ row.layerNo || '-' }} + + {{ row.name || '-' }} + {{ row.status || '启用' }} + {{ fmtTime(row.createdAt) }} + 编辑 + + + { nodeState[4].page.current = p; loadNodes(4) }" + @size-change="(s) => { nodeState[4].page.size = s; nodeState[4].page.current = 1; loadNodes(4) }" /> + + + + + + - - + + - - + + + + - - + + + + + + + + + + 留空则作为该货架的默认位置(无层) + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - 删除 - - - - - 添加一行 - - - - - 层 - - 至 - - 位置 - - 至 - - 生成货位 - - - 例:货架号 A、层 1 至 3、位置 1 至 4 → 一次生成 12 个货位(A架1层1位 … A架3层4位) - - - - 取消 - 保存 + 取消 + 保存 + + + + + + + + + + + + + + + + + 至 + + + + + 至 + + + + 预览 + 确认生成 + + + + + + + + {{ row.exists ? '已存在' : '新增' }} + + + + 共 {{ batchPreview.length }} 个位置,其中已存在 {{ batchPreview.filter(x=>x.exists).length }} 个(生成时自动跳过)。 + + @@ -601,7 +776,7 @@ async function onMaterialFile(e) { 新增物料 导入 导出 - + 导入说明 @@ -659,16 +834,13 @@ async function onMaterialFile(e) { - - + + - - + + - - - - + @@ -676,13 +848,13 @@ async function onMaterialFile(e) { - + - + 低于该值触发缺货预警(0=不预警) diff --git a/bj_power_wms/frontend/src/pages/Inbound.vue b/bj_power_wms/frontend/src/pages/Inbound.vue index 6878096..5fd4796 100644 --- a/bj_power_wms/frontend/src/pages/Inbound.vue +++ b/bj_power_wms/frontend/src/pages/Inbound.vue @@ -1,6 +1,6 @@