feat: 1.15 缺陷管理 我的关注 关注

This commit is contained in:
guoyuqi 2021-11-05 19:16:03 +08:00 committed by 刘瑞斌
parent 9f474841c7
commit 0926947cb8
5 changed files with 63 additions and 4 deletions

View File

@ -142,7 +142,14 @@
<property name="object" value="${condition}.creator"/>
</include>
</if>
<if test="${condition}.followPeople != null">
and issues.id in (
select issue_id from issue_follow where follow_id
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="${condition}.followPeople"/>
</include>
)
</if>
</sql>
<sql id="condition">
<choose>

View File

@ -129,4 +129,8 @@ public class IssuesController {
return issuesService.getCountByStatus(request);
}
@GetMapping("/follow/{issueId}")
public List<String> getFollows(@PathVariable String issueId) {
return issuesService.getFollows(issueId);
}
}

View File

@ -24,4 +24,6 @@ public class IssuesUpdateRequest extends IssuesWithBLOBs {
*/
private List<String> zentaoBuilds;
private List<String> testCaseIds;
private List<String> follows;
}

View File

@ -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<String> 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<AbstractIssuePlatform> getAddPlatforms(IssuesUpdateRequest updateRequest) {
List<String> platforms = new ArrayList<>();
if (StringUtils.isNotBlank(updateRequest.getTestCaseId())) {
@ -565,4 +581,15 @@ public class IssuesService {
return extIssuesMapper.getCountByStatus(request);
}
public List<String> getFollows(String issueId) {
List<String> result = new ArrayList<>();
if (StringUtils.isBlank(issueId)) {
return result;
}
IssueFollowExample example = new IssueFollowExample();
example.createCriteria().andIssueIdEqualTo(issueId);
List<IssueFollow> follows = issueFollowMapper.selectByExample(example);
return follows.stream().map(IssueFollow::getFollowId).distinct().collect(Collectors.toList());
}
}

View File

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