diff --git a/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachment.java b/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachment.java similarity index 75% rename from backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachment.java rename to backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachment.java index af3589d0f3..c6ba450a48 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachment.java +++ b/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachment.java @@ -13,35 +13,31 @@ import java.util.ArrayList; import java.util.Arrays; @Data -public class BugAttachment implements Serializable { +public class BugLocalAttachment implements Serializable { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{bug_attachment.id.not_blank}", groups = {Updated.class}) - @Size(min = 1, max = 255, message = "{bug_attachment.id.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{bug_local_attachment.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 255, message = "{bug_local_attachment.id.length_range}", groups = {Created.class, Updated.class}) private String id; @Schema(description = "缺陷ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{bug_attachment.bug_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{bug_attachment.bug_id.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{bug_local_attachment.bug_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{bug_local_attachment.bug_id.length_range}", groups = {Created.class, Updated.class}) private String bugId; @Schema(description = "文件ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{bug_attachment.file_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{bug_attachment.file_id.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{bug_local_attachment.file_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{bug_local_attachment.file_id.length_range}", groups = {Created.class, Updated.class}) private String fileId; @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{bug_attachment.file_name.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 255, message = "{bug_attachment.file_name.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{bug_local_attachment.file_name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{bug_local_attachment.file_name.length_range}", groups = {Created.class, Updated.class}) private String fileName; @Schema(description = "文件大小", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "{bug_attachment.size.not_blank}", groups = {Created.class}) + @NotNull(message = "{bug_local_attachment.size.not_blank}", groups = {Created.class}) private Long size; - @Schema(description = "是否本地", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "{bug_attachment.local.not_blank}", groups = {Created.class}) - private Boolean local; - @Schema(description = "创建人") private String createUser; @@ -56,7 +52,6 @@ public class BugAttachment implements Serializable { fileId("file_id", "fileId", "VARCHAR", false), fileName("file_name", "fileName", "VARCHAR", false), size("size", "size", "BIGINT", true), - local("local", "local", "BIT", true), createUser("create_user", "createUser", "VARCHAR", false), createTime("create_time", "createTime", "BIGINT", false); diff --git a/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachmentExample.java b/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachmentExample.java similarity index 90% rename from backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachmentExample.java rename to backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachmentExample.java index 16e7844168..e8ee194d85 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugAttachmentExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/bug/domain/BugLocalAttachmentExample.java @@ -3,14 +3,14 @@ package io.metersphere.bug.domain; import java.util.ArrayList; import java.util.List; -public class BugAttachmentExample { +public class BugLocalAttachmentExample { protected String orderByClause; protected boolean distinct; protected List oredCriteria; - public BugAttachmentExample() { + public BugLocalAttachmentExample() { oredCriteria = new ArrayList(); } @@ -444,66 +444,6 @@ public class BugAttachmentExample { return (Criteria) this; } - public Criteria andLocalIsNull() { - addCriterion("`local` is null"); - return (Criteria) this; - } - - public Criteria andLocalIsNotNull() { - addCriterion("`local` is not null"); - return (Criteria) this; - } - - public Criteria andLocalEqualTo(Boolean value) { - addCriterion("`local` =", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalNotEqualTo(Boolean value) { - addCriterion("`local` <>", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalGreaterThan(Boolean value) { - addCriterion("`local` >", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalGreaterThanOrEqualTo(Boolean value) { - addCriterion("`local` >=", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalLessThan(Boolean value) { - addCriterion("`local` <", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalLessThanOrEqualTo(Boolean value) { - addCriterion("`local` <=", value, "local"); - return (Criteria) this; - } - - public Criteria andLocalIn(List values) { - addCriterion("`local` in", values, "local"); - return (Criteria) this; - } - - public Criteria andLocalNotIn(List values) { - addCriterion("`local` not in", values, "local"); - return (Criteria) this; - } - - public Criteria andLocalBetween(Boolean value1, Boolean value2) { - addCriterion("`local` between", value1, value2, "local"); - return (Criteria) this; - } - - public Criteria andLocalNotBetween(Boolean value1, Boolean value2) { - addCriterion("`local` not between", value1, value2, "local"); - return (Criteria) this; - } - public Criteria andCreateUserIsNull() { addCriterion("create_user is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.java b/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.java deleted file mode 100644 index ece0a4ebb0..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.metersphere.bug.mapper; - -import io.metersphere.bug.domain.BugAttachment; -import io.metersphere.bug.domain.BugAttachmentExample; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface BugAttachmentMapper { - long countByExample(BugAttachmentExample example); - - int deleteByExample(BugAttachmentExample example); - - int deleteByPrimaryKey(String id); - - int insert(BugAttachment record); - - int insertSelective(BugAttachment record); - - List selectByExample(BugAttachmentExample example); - - BugAttachment selectByPrimaryKey(String id); - - int updateByExampleSelective(@Param("record") BugAttachment record, @Param("example") BugAttachmentExample example); - - int updateByExample(@Param("record") BugAttachment record, @Param("example") BugAttachmentExample example); - - int updateByPrimaryKeySelective(BugAttachment record); - - int updateByPrimaryKey(BugAttachment record); - - int batchInsert(@Param("list") List list); - - int batchInsertSelective(@Param("list") List list, @Param("selective") BugAttachment.Column ... selective); -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.java b/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.java new file mode 100644 index 0000000000..55507b500b --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.java @@ -0,0 +1,35 @@ +package io.metersphere.bug.mapper; + +import io.metersphere.bug.domain.BugLocalAttachment; +import io.metersphere.bug.domain.BugLocalAttachmentExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface BugLocalAttachmentMapper { + long countByExample(BugLocalAttachmentExample example); + + int deleteByExample(BugLocalAttachmentExample example); + + int deleteByPrimaryKey(String id); + + int insert(BugLocalAttachment record); + + int insertSelective(BugLocalAttachment record); + + List selectByExample(BugLocalAttachmentExample example); + + BugLocalAttachment selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") BugLocalAttachment record, @Param("example") BugLocalAttachmentExample example); + + int updateByExample(@Param("record") BugLocalAttachment record, @Param("example") BugLocalAttachmentExample example); + + int updateByPrimaryKeySelective(BugLocalAttachment record); + + int updateByPrimaryKey(BugLocalAttachment record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") BugLocalAttachment.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.xml similarity index 84% rename from backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.xml rename to backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.xml index ac626d64d0..064f08a545 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugAttachmentMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/bug/mapper/BugLocalAttachmentMapper.xml @@ -1,13 +1,12 @@ - - + + - @@ -70,15 +69,15 @@ - id, bug_id, file_id, file_name, `size`, `local`, create_user, create_time + id, bug_id, file_id, file_name, `size`, create_user, create_time - select distinct - from bug_attachment + from bug_local_attachment @@ -89,29 +88,29 @@ - delete from bug_attachment + delete from bug_local_attachment where id = #{id,jdbcType=VARCHAR} - - delete from bug_attachment + + delete from bug_local_attachment - - insert into bug_attachment (id, bug_id, file_id, - file_name, `size`, `local`, create_user, + + insert into bug_local_attachment (id, bug_id, file_id, + file_name, `size`, create_user, create_time) values (#{id,jdbcType=VARCHAR}, #{bugId,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR}, - #{fileName,jdbcType=VARCHAR}, #{size,jdbcType=BIGINT}, #{local,jdbcType=BIT}, #{createUser,jdbcType=VARCHAR}, + #{fileName,jdbcType=VARCHAR}, #{size,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}) - - insert into bug_attachment + + insert into bug_local_attachment id, @@ -128,9 +127,6 @@ `size`, - - `local`, - create_user, @@ -154,9 +150,6 @@ #{size,jdbcType=BIGINT}, - - #{local,jdbcType=BIT}, - #{createUser,jdbcType=VARCHAR}, @@ -165,14 +158,14 @@ - + select count(*) from bug_local_attachment - update bug_attachment + update bug_local_attachment id = #{record.id,jdbcType=VARCHAR}, @@ -189,9 +182,6 @@ `size` = #{record.size,jdbcType=BIGINT}, - - `local` = #{record.local,jdbcType=BIT}, - create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -204,21 +194,20 @@ - update bug_attachment + update bug_local_attachment set id = #{record.id,jdbcType=VARCHAR}, bug_id = #{record.bugId,jdbcType=VARCHAR}, file_id = #{record.fileId,jdbcType=VARCHAR}, file_name = #{record.fileName,jdbcType=VARCHAR}, `size` = #{record.size,jdbcType=BIGINT}, - `local` = #{record.local,jdbcType=BIT}, create_user = #{record.createUser,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT} - - update bug_attachment + + update bug_local_attachment bug_id = #{bugId,jdbcType=VARCHAR}, @@ -232,9 +221,6 @@ `size` = #{size,jdbcType=BIGINT}, - - `local` = #{local,jdbcType=BIT}, - create_user = #{createUser,jdbcType=VARCHAR}, @@ -244,29 +230,28 @@ where id = #{id,jdbcType=VARCHAR} - - update bug_attachment + + update bug_local_attachment set bug_id = #{bugId,jdbcType=VARCHAR}, file_id = #{fileId,jdbcType=VARCHAR}, file_name = #{fileName,jdbcType=VARCHAR}, `size` = #{size,jdbcType=BIGINT}, - `local` = #{local,jdbcType=BIT}, create_user = #{createUser,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT} where id = #{id,jdbcType=VARCHAR} - insert into bug_attachment - (id, bug_id, file_id, file_name, `size`, `local`, create_user, create_time) + insert into bug_local_attachment + (id, bug_id, file_id, file_name, `size`, create_user, create_time) values (#{item.id,jdbcType=VARCHAR}, #{item.bugId,jdbcType=VARCHAR}, #{item.fileId,jdbcType=VARCHAR}, - #{item.fileName,jdbcType=VARCHAR}, #{item.size,jdbcType=BIGINT}, #{item.local,jdbcType=BIT}, - #{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}) + #{item.fileName,jdbcType=VARCHAR}, #{item.size,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, + #{item.createTime,jdbcType=BIGINT}) - insert into bug_attachment ( + insert into bug_local_attachment ( ${column.escapedColumnName} @@ -290,9 +275,6 @@ #{item.size,jdbcType=BIGINT} - - #{item.local,jdbcType=BIT} - #{item.createUser,jdbcType=VARCHAR} diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_7__bug_management.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_7__bug_management.sql index b371e1e13c..03969061e9 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_7__bug_management.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_7__bug_management.sql @@ -53,17 +53,16 @@ CREATE TABLE IF NOT EXISTS bug_follower( CREATE INDEX idx_follow_id ON bug_follower(user_id); -CREATE TABLE IF NOT EXISTS bug_attachment( - `id` VARCHAR(255) NOT NULL COMMENT 'ID' , - `bug_id` VARCHAR(50) NOT NULL COMMENT '缺陷ID' , - `file_id` VARCHAR(50) NOT NULL COMMENT '文件ID' , - `file_name` VARCHAR(255) NOT NULL COMMENT '文件名称' , - `size` BIGINT NOT NULL COMMENT '文件大小' , - `local` BIT(1) NOT NULL COMMENT '是否本地' , - `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , - `create_time` BIGINT NOT NULL COMMENT '创建时间' , - PRIMARY KEY (id) -) COMMENT = '缺陷附件'; +CREATE TABLE IF NOT EXISTS bug_local_attachment( + `id` VARCHAR(255) NOT NULL COMMENT 'ID' , + `bug_id` VARCHAR(50) NOT NULL COMMENT '缺陷ID' , + `file_id` VARCHAR(50) NOT NULL COMMENT '文件ID' , + `file_name` VARCHAR(255) NOT NULL COMMENT '文件名称' , + `size` BIGINT NOT NULL COMMENT '文件大小' , + `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , + `create_time` BIGINT NOT NULL COMMENT '创建时间' , + PRIMARY KEY (id) +) COMMENT = '缺陷本地附件'; CREATE TABLE IF NOT EXISTS bug_comment( `id` VARCHAR(50) NOT NULL COMMENT 'ID' , diff --git a/backend/framework/sdk/src/main/resources/i18n/bug.properties b/backend/framework/sdk/src/main/resources/i18n/bug.properties index b9c67c2c16..8654d64f21 100644 --- a/backend/framework/sdk/src/main/resources/i18n/bug.properties +++ b/backend/framework/sdk/src/main/resources/i18n/bug.properties @@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人长度必须在1-50之间 bug_comment.update_user.not_blank=更新人不能为空 bug_comment.update_user.length_range=更新人长度必须在1-50之间 -# bugAttachment -bug_attachment.id.not_blank=ID不能为空 -bug_attachment.id.length_range=ID长度必须在1-50之间 -bug_attachment.bug_id.not_blank=缺陷ID不能为空 -bug_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间 -bug_attachment.file_id.not_blank=文件ID不能为空 -bug_attachment.file_id.length_range=文件ID长度必须在1-50之间 -bug_attachment.file_name.not_blank=文件名称不能为空 -bug_attachment.file_name.length_range=文件名称长度必须在1-50之间 -bug_attachment.local.not_blank=是否本地上传不能为空 -bug_attachment.local.length_range=是否本地上传长度必须在1-50之间 -bug_attachment.create_user.not_blank=创建人不能为空 -bug_attachment.create_user.length_range=创建人长度必须在1-50之间 +# bugLocalAttachment +bug_local_attachment.id.not_blank=ID不能为空 +bug_local_attachment.id.length_range=ID长度必须在1-50之间 +bug_local_attachment.bug_id.not_blank=缺陷ID不能为空 +bug_local_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间 +bug_local_attachment.file_id.not_blank=文件ID不能为空 +bug_local_attachment.file_id.length_range=文件ID长度必须在1-50之间 +bug_local_attachment.file_name.not_blank=文件名称不能为空 +bug_local_attachment.file_name.length_range=文件名称长度必须在1-50之间 +bug_local_attachment.create_user.not_blank=创建人不能为空 +bug_local_attachment.create_user.length_range=创建人长度必须在1-50之间 # bugCustomField bug_custom_field.bug_id.not_blank=缺陷ID不能为空 diff --git a/backend/framework/sdk/src/main/resources/i18n/bug_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/bug_en_US.properties index 7113826f6d..c3ed86afcd 100644 --- a/backend/framework/sdk/src/main/resources/i18n/bug_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/bug_en_US.properties @@ -42,19 +42,17 @@ bug_comment.create_user.length_range=createUser length must be between 1-50 bug_comment.update_user.not_blank=updateUser cannot be empty bug_comment.update_user.length_range=updateUser length must be between 1-50 -# bugAttachment -bug_attachment.id.not_blank=id cannot be empty -bug_attachment.id.length_range=id length must be between 1-50 -bug_attachment.bug_id.not_blank=bugId cannot be empty -bug_attachment.bug_id.length_range=bugId length must be between 1-50 -bug_attachment.file_id.not_blank=fileId cannot be empty -bug_attachment.file_id.length_range=fileId length must be between 1-50 -bug_attachment.file_name.not_blank=fileName cannot be empty -bug_attachment.file_name.length_range=fileName length must be between 1-50 -bug_attachment.local.not_blank=local cannot be empty -bug_attachment.local.length_range=local length must be between 1-50 -bug_attachment.create_user.not_blank=createUser cannot be empty -bug_attachment.create_user.length_range=createUser length must be between 1-50 +# bugLocalAttachment +bug_local_attachment.id.not_blank=id cannot be empty +bug_local_attachment.id.length_range=id length must be between 1-50 +bug_local_attachment.bug_id.not_blank=bugId cannot be empty +bug_local_attachment.bug_id.length_range=bugId length must be between 1-50 +bug_local_attachment.file_id.not_blank=fileId cannot be empty +bug_local_attachment.file_id.length_range=fileId length must be between 1-50 +bug_local_attachment.file_name.not_blank=fileName cannot be empty +bug_local_attachment.file_name.length_range=fileName length must be between 1-50 +bug_local_attachment.create_user.not_blank=createUser cannot be empty +bug_local_attachment.create_user.length_range=createUser length must be between 1-50 # bugCustomField bug_custom_field.bug_id.not_blank=bugId cannot be empty diff --git a/backend/framework/sdk/src/main/resources/i18n/bug_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/bug_zh_CN.properties index c3d5e171c7..87cf8558b2 100644 --- a/backend/framework/sdk/src/main/resources/i18n/bug_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/bug_zh_CN.properties @@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人长度必须在1-50之间 bug_comment.update_user.not_blank=更新人不能为空 bug_comment.update_user.length_range=更新人长度必须在1-50之间 -# bugAttachment -bug_attachment.id.not_blank=ID不能为空 -bug_attachment.id.length_range=ID长度必须在1-50之间 -bug_attachment.bug_id.not_blank=缺陷ID不能为空 -bug_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间 -bug_attachment.file_id.not_blank=文件ID不能为空 -bug_attachment.file_id.length_range=文件ID长度必须在1-50之间 -bug_attachment.file_name.not_blank=文件名称不能为空 -bug_attachment.file_name.length_range=文件名称长度必须在1-50之间 -bug_attachment.local.not_blank=是否本地上传不能为空 -bug_attachment.local.length_range=是否本地上传长度必须在1-50之间 -bug_attachment.create_user.not_blank=创建人不能为空 -bug_attachment.create_user.length_range=创建人长度必须在1-50之间 +# bugLocalAttachment +bug_local_attachment.id.not_blank=ID不能为空 +bug_local_attachment.id.length_range=ID长度必须在1-50之间 +bug_local_attachment.bug_id.not_blank=缺陷ID不能为空 +bug_local_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间 +bug_local_attachment.file_id.not_blank=文件ID不能为空 +bug_local_attachment.file_id.length_range=文件ID长度必须在1-50之间 +bug_local_attachment.file_name.not_blank=文件名称不能为空 +bug_local_attachment.file_name.length_range=文件名称长度必须在1-50之间 +bug_local_attachment.create_user.not_blank=创建人不能为空 +bug_local_attachment.create_user.length_range=创建人长度必须在1-50之间 # bugCustomField bug_custom_field.bug_id.not_blank=缺陷ID不能为空 diff --git a/backend/framework/sdk/src/main/resources/i18n/bug_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/bug_zh_TW.properties index 084e8aa41a..fadefad20a 100644 --- a/backend/framework/sdk/src/main/resources/i18n/bug_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/bug_zh_TW.properties @@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人長度必須在1-50之間 bug_comment.update_user.not_blank=更新人不能為空 bug_comment.update_user.length_range=更新人長度必須在1-50之間 -# bugAttachment -bug_attachment.id.not_blank=ID不能為空 -bug_attachment.id.length_range=ID長度必須在1-50之間 -bug_attachment.bug_id.not_blank=缺陷ID不能為空 -bug_attachment.bug_id.length_range=缺陷ID長度必須在1-50之間 -bug_attachment.file_id.not_blank=文件ID不能為空 -bug_attachment.file_id.length_range=文件ID長度必須在1-50之間 -bug_attachment.file_name.not_blank=文件名称不能為空 -bug_attachment.file_name.length_range=文件名称長度必須在1-50之間 -bug_attachment.local.not_blank=是否本地上傳不能為空 -bug_attachment.local.length_range=是否本地上傳必須在1-50之間 -bug_attachment.create_user.not_blank=创建人不能為空 -bug_attachment.create_user.length_range=创建人長度必須在1-50之間 +# bugLocalAttachment +bug_local_attachment.id.not_blank=ID不能為空 +bug_local_attachment.id.length_range=ID長度必須在1-50之間 +bug_local_attachment.bug_id.not_blank=缺陷ID不能為空 +bug_local_attachment.bug_id.length_range=缺陷ID長度必須在1-50之間 +bug_local_attachment.file_id.not_blank=文件ID不能為空 +bug_local_attachment.file_id.length_range=文件ID長度必須在1-50之間 +bug_local_attachment.file_name.not_blank=文件名称不能為空 +bug_local_attachment.file_name.length_range=文件名称長度必須在1-50之間 +bug_local_attachment.create_user.not_blank=创建人不能為空 +bug_local_attachment.create_user.length_range=创建人長度必須在1-50之間 # bugCustomField bug_custom_field.bug_id.not_blank=缺陷ID不能為空 diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugEditRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugEditRequest.java index d975400168..a8a069b8e0 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugEditRequest.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugEditRequest.java @@ -60,8 +60,8 @@ public class BugEditRequest { @Schema(description = "删除的本地附件集合") private List deleteLocalFileIds; - @Schema(description = "取消关联附件集合") - private List unLinkFileIds; + @Schema(description = "取消关联附件关系ID集合") + private List unLinkRefIds; @Schema(description = "关联附件集合") private List linkFileIds; diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCasePageRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCasePageRequest.java deleted file mode 100644 index a042e3207f..0000000000 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCasePageRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.metersphere.bug.dto.request; - -import io.metersphere.system.dto.sdk.BasePageRequest; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -public class BugRelateCasePageRequest extends BasePageRequest { - - @Schema(description = "所属项目ID", requiredMode = Schema.RequiredMode.REQUIRED) - private String projectId; - - @Schema(description = "版本ID") - private String versionId; - - @Schema(description = "选中模块ID") - private String selectModuleId; -} diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCaseRequest.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCaseRequest.java deleted file mode 100644 index 145f55a067..0000000000 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/dto/request/BugRelateCaseRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.metersphere.bug.dto.request; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -@Data -@EqualsAndHashCode(callSuper = false) -public class BugRelateCaseRequest extends BugRelateCasePageRequest{ - - @Schema(description = "是否全选", requiredMode = Schema.RequiredMode.REQUIRED) - private boolean selectAll; - - @Schema(description = "用例ID勾选列表") - private List includeCaseIds; -} diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.java similarity index 54% rename from backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.java rename to backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.java index 69a3e323b7..e30a0a1da2 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.java @@ -1,15 +1,15 @@ package io.metersphere.bug.mapper; -import io.metersphere.bug.domain.BugAttachment; +import io.metersphere.bug.domain.BugLocalAttachment; import org.apache.ibatis.annotations.Param; import java.util.List; -public interface ExtBugAttachmentMapper { +public interface ExtBugLocalAttachmentMapper { /** * 批量插入缺陷附件关系 * @param attachments 缺陷附件集合 */ - void batchInsert(@Param("list") List attachments); + void batchInsert(@Param("list") List attachments); } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.xml similarity index 62% rename from backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.xml rename to backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.xml index 659bb39ad4..4923180242 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugAttachmentMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugLocalAttachmentMapper.xml @@ -1,11 +1,11 @@ - - - insert into bug_attachment values + + + insert into bug_local_attachment values (#{attachment.id}, #{attachment.bugId}, #{attachment.fileId}, #{attachment.fileName}, - #{attachment.size}, #{attachment.local}, #{attachment.createUser}, #{attachment.createTime}) + #{attachment.size}, #{attachment.createUser}, #{attachment.createTime}) \ No newline at end of file diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java index 6900663766..8b071205c9 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/BugService.java @@ -12,22 +12,23 @@ import io.metersphere.bug.dto.request.BugPageRequest; import io.metersphere.bug.enums.BugPlatform; import io.metersphere.bug.mapper.*; import io.metersphere.bug.utils.CustomFieldUtils; -import io.metersphere.project.domain.FileMetadata; -import io.metersphere.project.domain.FileMetadataExample; -import io.metersphere.project.mapper.FileMetadataMapper; +import io.metersphere.project.dto.filemanagement.FileLogRecord; +import io.metersphere.project.service.FileAssociationService; import io.metersphere.project.service.FileService; import io.metersphere.project.service.ProjectTemplateService; import io.metersphere.sdk.constants.ApplicationNumScope; +import io.metersphere.sdk.constants.HttpMethodConstants; import io.metersphere.sdk.constants.StorageType; import io.metersphere.sdk.constants.TemplateScene; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; -import io.metersphere.sdk.util.MsFileUtils; +import io.metersphere.sdk.util.FileAssociationSourceUtil; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.Template; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.sdk.TemplateDTO; import io.metersphere.system.file.FileRequest; +import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.mapper.BaseUserMapper; import io.metersphere.system.mapper.TemplateMapper; import io.metersphere.system.service.BaseTemplateService; @@ -78,11 +79,11 @@ public class BugService { @Resource private ExtBugRelateCaseMapper extBugRelateCaseMapper; @Resource - private FileMetadataMapper fileMetadataMapper; + private FileAssociationService fileAssociationService; @Resource - private BugAttachmentMapper bugAttachmentMapper; + private BugLocalAttachmentMapper bugLocalAttachmentMapper; @Resource - private ExtBugAttachmentMapper extBugAttachmentMapper; + private ExtBugLocalAttachmentMapper extBugLocalAttachmentMapper; @Resource private FileService fileService; @Resource @@ -90,6 +91,11 @@ public class BugService { @Resource private BugFollowerMapper bugFollowerMapper; + public static final String ADD_BUG_FILE_LOG_URL = "/bug/add"; + public static final String UPDATE_BUG_FILE_LOG_URL = "/bug/update"; + public static final String UPLOAD_SOURCE_DIR = "/project"; + public static final String UPLOAD_APP_DIR = "/bug"; + /** * 缺陷列表查询 * @@ -144,7 +150,7 @@ public class BugService { // 自定义字段 handleAndSaveCustomFields(request, false, false); // 附件 - handleAndSaveAttachments(request, files, currentUser); + handleAndSaveAttachments(request, files, currentUser, ADD_BUG_FILE_LOG_URL); } /** @@ -166,7 +172,7 @@ public class BugService { // 自定义字段 handleAndSaveCustomFields(request, true, false); // 附件 - handleAndSaveAttachments(request, files, currentUser); + handleAndSaveAttachments(request, files, currentUser, UPDATE_BUG_FILE_LOG_URL); } /** @@ -360,7 +366,6 @@ public class BugService { // } if (StringUtils.isEmpty(bug.getId())) { bug.setId(IDGenerator.nextStr()); - // TODO: 业务ID生成规则, 暂保留, 后续补充 bug.setNum(Long.valueOf(NumGenerator.nextNum(request.getProjectId(), ApplicationNumScope.BUG_MANAGEMENT)).intValue()); bug.setHandleUsers(request.getHandleUser()); bug.setCreateUser(currentUser); @@ -473,89 +478,62 @@ public class BugService { * @param request 请求参数 * @param files 上传附件集合 */ - private void handleAndSaveAttachments(BugEditRequest request, List files, String currentUser) { - Map uploadMinioFiles = new HashMap<>(16); - List addFiles = new ArrayList<>(); - // 处理删除的本地上传附件及取消关联的附件 - List deleteIds = new ArrayList<>(); + private void handleAndSaveAttachments(BugEditRequest request, List files, String currentUser, String fileLogUrl) { + /* + * 附件处理逻辑 + * 1. 先处理删除, 及取消关联的附件 + * 2. 再处理新上传的, 新关联的附件 + */ if (CollectionUtils.isNotEmpty(request.getDeleteLocalFileIds())) { - deleteIds.addAll(request.getDeleteLocalFileIds()); + // 删除本地上传的附件, BUG_LOCAL_ATTACHMENT表 request.getDeleteLocalFileIds().forEach(deleteFileId -> { - FileRequest fileRequest = new FileRequest(); - fileRequest.setProjectId(request.getProjectId()); - fileRequest.setFileName(deleteFileId); - fileRequest.setStorage(StorageType.MINIO.name()); + FileRequest fileRequest = buildBugFileRequest(request.getProjectId(), deleteFileId, null); try { fileService.deleteFile(fileRequest); } catch (Exception e) { throw new MSException(Translator.get("bug_attachment_delete_error")); } }); + BugLocalAttachmentExample example = new BugLocalAttachmentExample(); + example.createCriteria().andBugIdEqualTo(request.getId()).andFileIdIn(request.getDeleteLocalFileIds()); + bugLocalAttachmentMapper.deleteByExample(example); } - if (CollectionUtils.isNotEmpty(request.getUnLinkFileIds())) { - deleteIds.addAll(request.getUnLinkFileIds()); - } - if (CollectionUtils.isNotEmpty(deleteIds)) { - BugAttachmentExample example = new BugAttachmentExample(); - example.createCriteria().andBugIdEqualTo(request.getId()).andFileIdIn(deleteIds); - bugAttachmentMapper.deleteByExample(example); - // TODO: 如果是第三方平台, 需调用平台插件同步删除附件 + if (CollectionUtils.isNotEmpty(request.getUnLinkRefIds())) { + // 取消关联的附件, FILE_ASSOCIATION表 + fileAssociationService.deleteBySourceId(request.getUnLinkRefIds(), createFileLogRecord(fileLogUrl, currentUser, request.getProjectId())); } + // 新本地上传的附件 + List addFiles = new ArrayList<>(); + Map uploadMinioFiles = new HashMap<>(16); if (CollectionUtils.isNotEmpty(files)) { files.forEach(file -> { - BugAttachment bugAttachment = new BugAttachment(); + BugLocalAttachment bugAttachment = new BugLocalAttachment(); bugAttachment.setId(IDGenerator.nextStr()); bugAttachment.setBugId(request.getId()); bugAttachment.setFileId(IDGenerator.nextStr()); bugAttachment.setFileName(file.getOriginalFilename()); bugAttachment.setSize(file.getSize()); - bugAttachment.setLocal(true); bugAttachment.setCreateTime(System.currentTimeMillis()); bugAttachment.setCreateUser(currentUser); addFiles.add(bugAttachment); uploadMinioFiles.put(bugAttachment.getFileId(), file); }); - } - // 新关联的附件 - List linkIds = request.getLinkFileIds(); - if (CollectionUtils.isNotEmpty(linkIds)) { - FileMetadataExample example = new FileMetadataExample(); - example.createCriteria().andIdIn(linkIds); - List linkFiles = fileMetadataMapper.selectByExample(example); - Map linkFileMap = linkFiles.stream().collect(Collectors.toMap(FileMetadata::getId, v -> v)); - linkIds.forEach(fileId -> { - FileMetadata fileMetadata = linkFileMap.get(fileId); - if (fileMetadata == null) { - return; + extBugLocalAttachmentMapper.batchInsert(addFiles); + uploadMinioFiles.forEach((fileId, file) -> { + FileRequest fileRequest = buildBugFileRequest(request.getProjectId(), fileId, file.getOriginalFilename()); + try { + fileService.upload(file, fileRequest); + } catch (Exception e) { + throw new MSException(Translator.get("bug_attachment_upload_error")); } - BugAttachment bugAttachment = new BugAttachment(); - bugAttachment.setId(IDGenerator.nextStr()); - bugAttachment.setBugId(request.getId()); - bugAttachment.setFileId(fileId); - bugAttachment.setFileName(fileMetadata.getName()); - bugAttachment.setSize(fileMetadata.getSize()); - bugAttachment.setLocal(false); - bugAttachment.setCreateTime(System.currentTimeMillis()); - bugAttachment.setCreateUser(currentUser); - addFiles.add(bugAttachment); }); } - if (CollectionUtils.isNotEmpty(addFiles)) { - extBugAttachmentMapper.batchInsert(addFiles); + // 新关联的附件 + if (CollectionUtils.isNotEmpty(request.getLinkFileIds())) { + fileAssociationService.association(request.getId(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, request.getLinkFileIds(), false, + createFileLogRecord(fileLogUrl, currentUser, request.getProjectId())); } - // TODO: 如果是第三方平台, 需调用平台插件同步上传附件 - uploadMinioFiles.forEach((fileId, file) -> { - FileRequest fileRequest = new FileRequest(); - fileRequest.setFileName(file.getOriginalFilename()); - fileRequest.setResourceId("/" + MsFileUtils.BUG_MANAGEMENT_DIR + "/" + request.getProjectId() + "/" + fileId); - fileRequest.setStorage(StorageType.MINIO.name()); - try { - fileService.upload(file, fileRequest); - } catch (Exception e) { - throw new MSException(Translator.get("bug_attachment_upload_error")); - } - }); } // /** @@ -653,4 +631,24 @@ public class BugService { // } // return template; // } + + private FileLogRecord createFileLogRecord(String logUrl, String operator, String projectId){ + return FileLogRecord.builder() + .logModule(OperationLogModule.BUG_MANAGEMENT) + .requestMethod(HttpMethodConstants.POST.name()) + .requestUrl(logUrl) + .operator(operator) + .projectId(projectId) + .build(); + } + + private FileRequest buildBugFileRequest(String projectId, String resourceId, String fileName) { + FileRequest fileRequest = new FileRequest(); + fileRequest.setFolder(UPLOAD_SOURCE_DIR + "/" + projectId + UPLOAD_APP_DIR + "/" + resourceId); + fileRequest.setProjectId(projectId); + fileRequest.setResourceId(resourceId); + fileRequest.setFileName(StringUtils.isEmpty(fileName) ? null : fileName); + fileRequest.setStorage(StorageType.MINIO.name()); + return fileRequest; + } } diff --git a/backend/services/bug-management/src/main/resources/bugGeneratorConfig.xml b/backend/services/bug-management/src/main/resources/bugGeneratorConfig.xml index ac2cada802..87933d1b2d 100644 --- a/backend/services/bug-management/src/main/resources/bugGeneratorConfig.xml +++ b/backend/services/bug-management/src/main/resources/bugGeneratorConfig.xml @@ -74,7 +74,7 @@ - + diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java index f91670b867..04811b0ac3 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/controller/BugControllerTests.java @@ -440,13 +440,13 @@ public class BugControllerTests extends BaseTest { request.setHandleUser("admin"); request.setTemplateId("default-bug-template"); request.setStatus("prepare"); - request.setLinkFileIds(List.of("default-bug-file-id-1", "default-bug-file-id-3")); + request.setLinkFileIds(List.of("default-bug-file-id-1")); Map customFieldMap = new HashMap<>(); customFieldMap.put("custom-field", "oasis"); customFieldMap.put("test_field", JSON.toJSONString(List.of("test"))); if (isUpdate) { request.setId("default-bug-id"); - request.setUnLinkFileIds(List.of("default-bug-file-id-1")); + request.setUnLinkRefIds(List.of("default-bug-file-id-1")); request.setDeleteLocalFileIds(List.of("default-bug-file-id")); request.setLinkFileIds(List.of("default-bug-file-id-2")); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java index 4c6ee39f7d..143b16c234 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java @@ -102,4 +102,6 @@ public class OperationLogModule { public static final String API_DEBUG = "API_DEBUG"; //接口管理-环境 public static final String API_DEFINITION_ENVIRONMENT = "API_DEFINITION_ENVIRONMENT"; + // 缺陷管理 + public static final String BUG_MANAGEMENT = "BUG_MANAGEMENT"; }