From 3bd1cc45f80bc83b100093ec6f577fb963ab9a2f Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 1 Feb 2024 15:06:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E5=88=A0=E9=99=A4=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=85=B3=E8=81=94=E8=A1=A8=EF=BC=8C=E5=B9=B6=E5=8A=A0=E4=BB=A5?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/domain/FileAssociation.java | 11 +- .../domain/FileAssociationExample.java | 130 ++++++++++++++++++ .../project/mapper/FileAssociationMapper.xml | 53 ++++++- .../ddl/V3.0.0_4__project_management.sql | 25 ++-- .../project/mapper/ExtFileMetadataMapper.xml | 4 +- .../service/FileAssociationService.java | 1 + .../service/FileManagementService.java | 13 +- .../project/service/FileMetadataService.java | 15 +- .../project/utils/FileMetadataUtils.java | 8 ++ .../main/resources/projectGeneratorConfig.xml | 10 +- .../FileManagementControllerTests.java | 36 +++-- .../system/dto/excel/ExcelValidateHelper.java | 12 +- .../resources/file/user_import_error_all.xlsx | Bin 9242 -> 9241 bytes 13 files changed, 255 insertions(+), 63 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociation.java b/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociation.java index 0a47694000..ae0f2f3746 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociation.java +++ b/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociation.java @@ -52,6 +52,13 @@ public class FileAssociation implements Serializable { @Schema(description = "创建人") private String createUser; + @Schema(description = "是否删除", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{file_association.deleted.not_blank}", groups = {Created.class}) + private Boolean deleted; + + @Schema(description = "删除时的文件名称") + private String deletedFileName; + private static final long serialVersionUID = 1L; public enum Column { @@ -64,7 +71,9 @@ public class FileAssociation implements Serializable { createTime("create_time", "createTime", "BIGINT", false), updateUser("update_user", "updateUser", "VARCHAR", false), updateTime("update_time", "updateTime", "BIGINT", false), - createUser("create_user", "createUser", "VARCHAR", false); + createUser("create_user", "createUser", "VARCHAR", false), + deleted("deleted", "deleted", "BIT", false), + deletedFileName("deleted_file_name", "deletedFileName", "VARCHAR", false); private static final String BEGINNING_DELIMITER = "`"; diff --git a/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociationExample.java b/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociationExample.java index 8745070ed2..1baa4a3274 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociationExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/project/domain/FileAssociationExample.java @@ -783,6 +783,136 @@ public class FileAssociationExample { addCriterion("create_user not between", value1, value2, "createUser"); return (Criteria) this; } + + public Criteria andDeletedIsNull() { + addCriterion("deleted is null"); + return (Criteria) this; + } + + public Criteria andDeletedIsNotNull() { + addCriterion("deleted is not null"); + return (Criteria) this; + } + + public Criteria andDeletedEqualTo(Boolean value) { + addCriterion("deleted =", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedNotEqualTo(Boolean value) { + addCriterion("deleted <>", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedGreaterThan(Boolean value) { + addCriterion("deleted >", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedGreaterThanOrEqualTo(Boolean value) { + addCriterion("deleted >=", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedLessThan(Boolean value) { + addCriterion("deleted <", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedLessThanOrEqualTo(Boolean value) { + addCriterion("deleted <=", value, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedIn(List values) { + addCriterion("deleted in", values, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedNotIn(List values) { + addCriterion("deleted not in", values, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedBetween(Boolean value1, Boolean value2) { + addCriterion("deleted between", value1, value2, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedNotBetween(Boolean value1, Boolean value2) { + addCriterion("deleted not between", value1, value2, "deleted"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameIsNull() { + addCriterion("deleted_file_name is null"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameIsNotNull() { + addCriterion("deleted_file_name is not null"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameEqualTo(String value) { + addCriterion("deleted_file_name =", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameNotEqualTo(String value) { + addCriterion("deleted_file_name <>", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameGreaterThan(String value) { + addCriterion("deleted_file_name >", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameGreaterThanOrEqualTo(String value) { + addCriterion("deleted_file_name >=", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameLessThan(String value) { + addCriterion("deleted_file_name <", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameLessThanOrEqualTo(String value) { + addCriterion("deleted_file_name <=", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameLike(String value) { + addCriterion("deleted_file_name like", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameNotLike(String value) { + addCriterion("deleted_file_name not like", value, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameIn(List values) { + addCriterion("deleted_file_name in", values, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameNotIn(List values) { + addCriterion("deleted_file_name not in", values, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameBetween(String value1, String value2) { + addCriterion("deleted_file_name between", value1, value2, "deletedFileName"); + return (Criteria) this; + } + + public Criteria andDeletedFileNameNotBetween(String value1, String value2) { + addCriterion("deleted_file_name not between", value1, value2, "deletedFileName"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/framework/domain/src/main/java/io/metersphere/project/mapper/FileAssociationMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/project/mapper/FileAssociationMapper.xml index 8cc9c4ba62..4ebe7490f0 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/project/mapper/FileAssociationMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/project/mapper/FileAssociationMapper.xml @@ -12,6 +12,8 @@ + + @@ -73,7 +75,7 @@ id, source_type, source_id, file_id, file_ref_id, file_version, create_time, update_user, - update_time, create_user + update_time, create_user, deleted, deleted_file_name @@ -221,6 +237,12 @@ create_user = #{record.createUser,jdbcType=VARCHAR}, + + deleted = #{record.deleted,jdbcType=BIT}, + + + deleted_file_name = #{record.deletedFileName,jdbcType=VARCHAR}, + @@ -237,7 +259,9 @@ create_time = #{record.createTime,jdbcType=BIGINT}, update_user = #{record.updateUser,jdbcType=VARCHAR}, update_time = #{record.updateTime,jdbcType=BIGINT}, - create_user = #{record.createUser,jdbcType=VARCHAR} + create_user = #{record.createUser,jdbcType=VARCHAR}, + deleted = #{record.deleted,jdbcType=BIT}, + deleted_file_name = #{record.deletedFileName,jdbcType=VARCHAR} @@ -272,6 +296,12 @@ create_user = #{createUser,jdbcType=VARCHAR}, + + deleted = #{deleted,jdbcType=BIT}, + + + deleted_file_name = #{deletedFileName,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -285,19 +315,22 @@ create_time = #{createTime,jdbcType=BIGINT}, update_user = #{updateUser,jdbcType=VARCHAR}, update_time = #{updateTime,jdbcType=BIGINT}, - create_user = #{createUser,jdbcType=VARCHAR} + create_user = #{createUser,jdbcType=VARCHAR}, + deleted = #{deleted,jdbcType=BIT}, + deleted_file_name = #{deletedFileName,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} insert into file_association (id, source_type, source_id, file_id, file_ref_id, file_version, create_time, update_user, - update_time, create_user) + update_time, create_user, deleted, deleted_file_name) values (#{item.id,jdbcType=VARCHAR}, #{item.sourceType,jdbcType=VARCHAR}, #{item.sourceId,jdbcType=VARCHAR}, #{item.fileId,jdbcType=VARCHAR}, #{item.fileRefId,jdbcType=VARCHAR}, #{item.fileVersion,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, - #{item.createUser,jdbcType=VARCHAR}) + #{item.createUser,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.deletedFileName,jdbcType=VARCHAR} + ) @@ -340,6 +373,12 @@ #{item.createUser,jdbcType=VARCHAR} + + #{item.deleted,jdbcType=BIT} + + + #{item.deletedFileName,jdbcType=VARCHAR} + ) diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_management.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_management.sql index 2cb69f66f8..207f5d1110 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_management.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_4__project_management.sql @@ -52,17 +52,19 @@ CREATE INDEX idx_name ON fake_error (name); CREATE TABLE IF NOT EXISTS file_association ( - `id` VARCHAR(50) NOT NULL COMMENT '', - `source_type` VARCHAR(50) NOT NULL COMMENT '资源类型', - `source_id` VARCHAR(50) NOT NULL COMMENT '资源ID', - `file_id` VARCHAR(50) NOT NULL COMMENT '文件ID', - `file_ref_id` VARCHAR(50) NOT NULL COMMENT '文件同版本ID', - `file_version` VARCHAR(50) NOT NULL COMMENT '文件版本', - `create_time` BIGINT NOT NULL COMMENT '创建时间', - `update_user` VARCHAR(50) NOT NULL COMMENT '修改人', - `update_time` BIGINT NOT NULL COMMENT '更新时间', - `create_user` VARCHAR(50) COMMENT '创建人', - PRIMARY KEY (id) + `id` VARCHAR(50) NOT NULL COMMENT '' , + `source_type` VARCHAR(50) NOT NULL COMMENT '资源类型' , + `source_id` VARCHAR(50) NOT NULL COMMENT '资源ID' , + `file_id` VARCHAR(50) NOT NULL COMMENT '文件ID' , + `file_ref_id` VARCHAR(50) NOT NULL COMMENT '文件同版本ID' , + `file_version` VARCHAR(50) NOT NULL COMMENT '文件版本' , + `create_time` BIGINT NOT NULL COMMENT '创建时间' , + `update_user` VARCHAR(50) NOT NULL COMMENT '修改人' , + `update_time` BIGINT NOT NULL COMMENT '更新时间' , + `create_user` VARCHAR(50) COMMENT '创建人' , + `deleted` BIT NOT NULL DEFAULT 0 COMMENT '是否删除' , + `deleted_file_name` VARCHAR(255) COMMENT '删除时的文件名称' , + PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci @@ -70,6 +72,7 @@ CREATE TABLE IF NOT EXISTS file_association + CREATE INDEX idx_file_metadata_id ON file_association (file_id); CREATE INDEX idx_source_type ON file_association (source_type); CREATE INDEX idx_source_id ON file_association (source_id); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml index 333fcb9a04..8a36c2601a 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml @@ -122,9 +122,7 @@