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)
}
}
}