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 @@