From 0926947cb877f9d1abdb01186f2d2d722a66a3b1 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 5 Nov 2021 19:16:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.15=20=E7=BC=BA=E9=99=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E6=88=91=E7=9A=84=E5=85=B3=E6=B3=A8=20=E5=85=B3?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtIssuesMapper.xml | 9 +++++- .../track/controller/IssuesController.java | 4 +++ .../request/testcase/IssuesUpdateRequest.java | 2 ++ .../track/service/IssuesService.java | 29 ++++++++++++++++++- .../track/issue/IssueEditDetail.vue | 23 +++++++++++++-- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml index eb15788b39..e84cac7465 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml @@ -142,7 +142,14 @@ - + + and issues.id in ( + select issue_id from issue_follow where follow_id + + + + ) + diff --git a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java index 6871ee9c1e..455425ee8c 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -129,4 +129,8 @@ public class IssuesController { return issuesService.getCountByStatus(request); } + @GetMapping("/follow/{issueId}") + public List getFollows(@PathVariable String issueId) { + return issuesService.getFollows(issueId); + } } diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java index 29c2fd6bde..8c1c145e84 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java @@ -24,4 +24,6 @@ public class IssuesUpdateRequest extends IssuesWithBLOBs { */ private List zentaoBuilds; private List testCaseIds; + + private List follows; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index ff2aee594b..c0ff1b3b0e 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -76,6 +76,8 @@ public class IssuesService { private TestCaseIssueService testCaseIssueService; @Resource private TestPlanTestCaseService testPlanTestCaseService; + @Resource + private IssueFollowMapper issueFollowMapper; public void testAuth(String workspaceId, String platform) { IssuesRequest issuesRequest = new IssuesRequest(); @@ -93,6 +95,7 @@ public class IssuesService { issuesRequest.getTestCaseIds().forEach(l -> { testCaseIssueService.updateIssuesCount(l); }); + saveFollows(issuesRequest.getId(), issuesRequest.getFollows()); } @@ -102,9 +105,22 @@ public class IssuesService { platformList.forEach(platform -> { platform.updateIssue(issuesRequest); }); + saveFollows(issuesRequest.getId(), issuesRequest.getFollows()); // todo 缺陷更新事件? } - + private void saveFollows(String issueId, List follows) { + IssueFollowExample example = new IssueFollowExample(); + example.createCriteria().andIssueIdEqualTo(issueId); + issueFollowMapper.deleteByExample(example); + if (!CollectionUtils.isEmpty(follows)) { + for (String follow : follows) { + IssueFollow issueFollow = new IssueFollow(); + issueFollow.setIssueId(issueId); + issueFollow.setFollowId(follow); + issueFollowMapper.insert(issueFollow); + } + } + } public List getAddPlatforms(IssuesUpdateRequest updateRequest) { List platforms = new ArrayList<>(); if (StringUtils.isNotBlank(updateRequest.getTestCaseId())) { @@ -565,4 +581,15 @@ public class IssuesService { return extIssuesMapper.getCountByStatus(request); } + + public List getFollows(String issueId) { + List result = new ArrayList<>(); + if (StringUtils.isBlank(issueId)) { + return result; + } + IssueFollowExample example = new IssueFollowExample(); + example.createCriteria().andIssueIdEqualTo(issueId); + List follows = issueFollowMapper.selectByExample(example); + return follows.stream().map(IssueFollow::getFollowId).distinct().collect(Collectors.toList()); + } } diff --git a/frontend/src/business/components/track/issue/IssueEditDetail.vue b/frontend/src/business/components/track/issue/IssueEditDetail.vue index 4b4384c151..fb602589f7 100644 --- a/frontend/src/business/components/track/issue/IssueEditDetail.vue +++ b/frontend/src/business/components/track/issue/IssueEditDetail.vue @@ -81,7 +81,7 @@ import {buildCustomFields, parseCustomField} from "@/common/js/custom_field"; import CustomFiledComponent from "@/business/components/settings/workspace/template/CustomFiledComponent"; import TestCaseIssueList from "@/business/components/track/issue/TestCaseIssueList"; import IssueEditDetail from "@/business/components/track/issue/IssueEditDetail"; -import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId} from "@/common/js/utils"; +import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId} from "@/common/js/utils"; import {getIssueTemplate} from "@/network/custom-field-template"; export default { @@ -159,6 +159,18 @@ export default { this.getThirdPartyInfo(); initAddFuc(data); }); + this.$get('/issues/follow/' + data.id, response =>{ + this.form.follows = response.data; + for (let i = 0; i < response.data.length; i++) { + if(response.data[i]===this.currentUser().id){ + this.showFollow = true; + break; + } + } + }) + }, + currentUser: () => { + return getCurrentUser(); }, getThirdPartyInfo() { let platform = this.issueTemplate.platform; @@ -284,9 +296,16 @@ export default { saveFollow(){ if(this.showFollow){ this.showFollow = false; + for (let i = 0; i < this.form.follows.length; i++) { + if(this.form.follows[i]===this.currentUser().id){ + this.form.follows.splice(i,1) + break; + } + } + }else { this.showFollow = true; - + this.form.follows.push(this.currentUser().id) } } }