From 7c127bd7cf161e9ff0ecf955427626edf76d40fc Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 25 Jan 2024 14:39:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E9=A1=B5=E9=9D=A2=E5=88=9B=E5=BB=BA=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E5=B9=B6=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bug/dto/request/BugEditRequest.java | 3 +++ .../io/metersphere/bug/mapper/ExtBugMapper.xml | 6 ++++-- .../bug/mapper/ExtBugRelateCaseMapper.xml | 4 ++-- .../io/metersphere/bug/service/BugService.java | 14 ++++++++++++++ .../bug/controller/BugControllerTests.java | 4 ++++ 5 files changed, 27 insertions(+), 4 deletions(-) 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 1d8162f372..63f4ab81e7 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 @@ -54,4 +54,7 @@ public class BugEditRequest { @Schema(description = "关联附件集合, 文件ID") private List linkFileIds; + + @Schema(description = "用例ID") + private String caseId; } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml index fe13a514ba..be181191df 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml @@ -378,18 +378,20 @@ - + and b.project_id = #{request.projectId} - + and ( b.title like concat('%', #{request.keyword},'%') or b.num like concat('%', #{request.keyword},'%') + or b.tags like concat('%', #{request.keyword},'%') ) + diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml index 94a2e41836..815aabdd26 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml @@ -91,10 +91,10 @@ - + and brc.case_id = #{request.caseId} - + and b.title like concat('%', #{request.keyword},'%') 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 4ed925fec9..3ae9e20679 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 @@ -224,6 +224,20 @@ public class BugService { handleAndSaveCustomFields(request, isUpdate); // 处理附件 handleAndSaveAttachments(request, files, currentUser, platformName, platformBug); + + if (!isUpdate && StringUtils.isNotBlank(request.getCaseId())) { + //用例创建缺陷并关联 + BugRelationCase bugRelationCase = new BugRelationCase(); + bugRelationCase.setId(IDGenerator.nextStr()); + bugRelationCase.setCaseId(request.getCaseId()); + bugRelationCase.setBugId(bug.getId()); + bugRelationCase.setCaseType(CaseType.FUNCTIONAL_CASE.getKey()); + bugRelationCase.setCreateUser(currentUser); + bugRelationCase.setCreateTime(System.currentTimeMillis()); + bugRelationCase.setUpdateTime(System.currentTimeMillis()); + bugRelationCaseMapper.insertSelective(bugRelationCase); + } + return bug; } 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 4f4f248b7f..5f37e0f213 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 @@ -239,6 +239,10 @@ public class BugControllerTests extends BaseTest { MultiValueMap paramMap = getDefaultMultiPartParam(request, file); this.requestMultipartWithOkAndReturn(BUG_ADD, paramMap); + request.setCaseId("test"); + paramMap = new LinkedMultiValueMap<>(); + paramMap.add("request", JSON.toJSONString(request)); + this.requestMultipartWithOkAndReturn(BUG_ADD, paramMap); } @Test