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 71882dc889..091e14a9bd 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -14,6 +14,7 @@ import io.metersphere.commons.utils.Pager; import io.metersphere.dto.IssueTemplateDao; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.notice.annotation.SendNotice; +import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.jira.JiraIssueType; import io.metersphere.track.issue.domain.zentao.ZentaoBuild; @@ -161,4 +162,9 @@ public class IssuesController { public List getJiraIssueType(@RequestBody JiraIssueTypeRequest request) { return issuesService.getIssueTypes(request); } + + @GetMapping("/demand/list/{projectId}") + public List getDemandList(@PathVariable String projectId) { + return issuesService.getDemandList(projectId); + } } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseDemandController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseDemandController.java deleted file mode 100644 index f9f789d0ad..0000000000 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseDemandController.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.metersphere.track.controller; - -import io.metersphere.track.dto.DemandDTO; -import io.metersphere.track.service.DemandService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -@RequestMapping("demand") -@RestController -public class TestCaseDemandController { - @Resource - private DemandService demandService; - - @GetMapping("/list/{projectId}") - public List getDemandList(@PathVariable String projectId) { - return demandService.getDemandList(projectId); - } -} diff --git a/backend/src/main/java/io/metersphere/track/service/DemandService.java b/backend/src/main/java/io/metersphere/track/service/DemandService.java deleted file mode 100644 index 77761284ad..0000000000 --- a/backend/src/main/java/io/metersphere/track/service/DemandService.java +++ /dev/null @@ -1,82 +0,0 @@ -package io.metersphere.track.service; - -import io.metersphere.base.domain.Project; -import io.metersphere.base.mapper.ProjectMapper; -import io.metersphere.commons.constants.IssuesManagePlatform; -import io.metersphere.commons.utils.LogUtil; -import io.metersphere.track.dto.DemandDTO; -import io.metersphere.track.issue.AbstractIssuePlatform; -import io.metersphere.track.issue.IssueFactory; -import io.metersphere.track.request.testcase.IssuesRequest; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; - -@Service -@Transactional(rollbackFor = Exception.class) -public class DemandService { - @Resource - private IssuesService issuesService; - @Resource - private ProjectMapper projectMapper; - - public List getDemandList(String projectId) { - Project project = projectMapper.selectByPrimaryKey(projectId); - - String workspaceId = project.getWorkspaceId(); - boolean tapd = issuesService.isIntegratedPlatform(workspaceId, IssuesManagePlatform.Tapd.toString()); - boolean jira = issuesService.isIntegratedPlatform(workspaceId, IssuesManagePlatform.Jira.toString()); - boolean zentao = issuesService.isIntegratedPlatform(workspaceId, IssuesManagePlatform.Zentao.toString()); - boolean azureDevops = issuesService.isIntegratedPlatform(workspaceId, IssuesManagePlatform.AzureDevops.toString()); - List list = new ArrayList<>(); - List platforms = new ArrayList<>(); - IssuesRequest issueRequest = new IssuesRequest(); - if (tapd) { - // 是否关联了项目 - String tapdId = project.getTapdId(); - if (StringUtils.isNotBlank(tapdId)) { - platforms.add(IssuesManagePlatform.Tapd.name()); - } - } - - if (jira) { - String jiraKey = project.getJiraKey(); - if (StringUtils.isNotBlank(jiraKey)) { - platforms.add(IssuesManagePlatform.Jira.name()); - } - } - - if (zentao) { - String zentaoId = project.getZentaoId(); - if (StringUtils.isNotBlank(zentaoId)) { - platforms.add(IssuesManagePlatform.Zentao.name()); - } - } - - if (azureDevops) { - String azureDevopsId = project.getAzureDevopsId(); - if (StringUtils.isNotBlank(azureDevopsId)) { - platforms.add(IssuesManagePlatform.AzureDevops.name()); - } - } - - issueRequest.setWorkspaceId(workspaceId); - issueRequest.setProjectId(projectId); - List platformList = IssueFactory.createPlatforms(platforms, issueRequest); - platformList.forEach(platform -> { - List demand = new ArrayList<>(); - try { - demand = platform.getDemandList(projectId); - } catch (Exception e) { - LogUtil.error(e); - } - list.addAll(demand); - }); - - return list; - } -} 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 89642bafe2..529467a961 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -24,10 +24,7 @@ import io.metersphere.service.CustomFieldTemplateService; import io.metersphere.service.IntegrationService; import io.metersphere.service.IssueTemplateService; import io.metersphere.service.ProjectService; -import io.metersphere.track.dto.PlanReportIssueDTO; -import io.metersphere.track.dto.TestCaseReportStatusResultDTO; -import io.metersphere.track.dto.TestPlanFunctionResultReportDTO; -import io.metersphere.track.dto.TestPlanSimpleReportDTO; +import io.metersphere.track.dto.*; import io.metersphere.track.issue.*; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.jira.JiraIssueType; @@ -684,4 +681,14 @@ public class IssuesService { return new ArrayList<>(); } } + + public List getDemandList(String projectId) { + Project project = projectService.getProjectById(projectId); + String workspaceId = project.getWorkspaceId(); + IssuesRequest issueRequest = new IssuesRequest(); + issueRequest.setWorkspaceId(workspaceId); + issueRequest.setProjectId(projectId); + AbstractIssuePlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest); + return platform.getDemandList(projectId); + } } diff --git a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue index be57719f40..7ec112167b 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue @@ -274,7 +274,7 @@ export default { getDemandOptions() { if (this.demandOptions.length === 0) { this.result = {loading: true}; - this.$get("demand/list/" + this.projectId).then(response => { + this.$get("/issues/demand/list/" + this.projectId).then(response => { this.demandOptions = []; if (response.data.data && response.data.data.length > 0) { this.buildDemandCascaderOptions(response.data.data, this.demandOptions, []);