diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java index 79a51257f5..905b408b5e 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java @@ -1,6 +1,7 @@ package io.metersphere.track.controller; import io.metersphere.base.domain.Issues; +import io.metersphere.track.domain.TapdUser; import io.metersphere.track.service.IssuesService; import io.metersphere.track.request.testcase.IssuesRequest; import org.springframework.web.bind.annotation.*; @@ -35,4 +36,9 @@ public class TestCaseIssuesController { issuesService.closeLocalIssue(id); } + @GetMapping("/tapd/user/{caseId}") + public List getTapdUsers(@PathVariable String caseId) { + return issuesService.getTapdProjectUsers(caseId); + } + } diff --git a/backend/src/main/java/io/metersphere/track/domain/TapdUser.java b/backend/src/main/java/io/metersphere/track/domain/TapdUser.java new file mode 100644 index 0000000000..53d193c088 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/domain/TapdUser.java @@ -0,0 +1,12 @@ +package io.metersphere.track.domain; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class TapdUser implements Serializable { + private List roleId; + private String name; + private String user; +} diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java index e5658e3684..88fb097185 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java @@ -3,6 +3,8 @@ package io.metersphere.track.request.testcase; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class IssuesRequest { @@ -10,4 +12,5 @@ public class IssuesRequest { private String content; private String projectId; private String testCaseId; + private List tapdUsers; } 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 3426bd6084..9febb2149b 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -1,6 +1,7 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; @@ -17,6 +18,7 @@ import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.service.IntegrationService; import io.metersphere.service.ProjectService; +import io.metersphere.track.domain.TapdUser; import io.metersphere.track.request.testcase.IssuesRequest; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -188,10 +190,14 @@ public class IssuesService { MSException.throwException("未关联Tapd 项目ID"); } + List tapdUsers = issuesRequest.getTapdUsers(); + String usersStr = String.join(";", tapdUsers); + MultiValueMap paramMap = new LinkedMultiValueMap<>(); paramMap.add("title", issuesRequest.getTitle()); paramMap.add("workspace_id", tapdId); paramMap.add("description", issuesRequest.getContent()); + paramMap.add("current_owner", usersStr); ResultHolder result = call(url, HttpMethod.POST, paramMap); @@ -535,4 +541,19 @@ public class IssuesService { issuesMapper.updateByPrimaryKeySelective(issues); } + public List getTapdProjectUsers(String caseId) { + List users = new ArrayList<>(); + String projectId = getTapdProjectId(caseId); + String url = "https://api.tapd.cn/workspaces/users?workspace_id=" + projectId; + ResultHolder call = call(url); + String listJson = JSON.toJSONString(call.getData()); + JSONArray jsonArray = JSON.parseArray(listJson); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject o = jsonArray.getJSONObject(i); + TapdUser user = o.getObject("UserWorkspace", TapdUser.class); + users.add(user); + } + return users; + } + } diff --git a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue index c8a2b56e08..8731050c0c 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue @@ -218,6 +218,12 @@ /> + + Tapd平台处理人: + + + + {{$t('commons.save')}} {{$t('commons.cancel')}} @@ -323,6 +329,8 @@ test: {}, activeTab: 'detail', isFailure: true, + users: [], + hasTapdId: false }; }, props: { @@ -490,6 +498,17 @@ executeResult += this.addPLabel(stepPrefix + (step.executeResult == undefined ? '' : step.executeResult)); }); this.testCase.issues.content = desc + this.addPLabel('') + result + this.addPLabel('') + executeResult + this.addPLabel(''); + + this.$get("/test/case/project/" + this.testCase.caseId, res => { + const project = res.data; + if (project.tapdId) { + this.hasTapdId = true; + this.result = this.$get("/issues/tapd/user/" + this.testCase.caseId, response => { + let data = response.data; + this.users = data; + }) + } + }) } }, addPLabel(str) { @@ -515,6 +534,7 @@ param.title = this.testCase.issues.title; param.content = this.testCase.issues.content; param.testCaseId = this.testCase.caseId; + param.tapdUsers = this.testCase.tapdUsers; this.result = this.$post("/issues/add", param, () => { this.$success(this.$t('commons.save_success')); this.getIssues(param.testCaseId); @@ -522,6 +542,7 @@ this.issuesSwitch = false; this.testCase.issues.title = ""; this.testCase.issues.content = ""; + this.testCase.tapdUsers = []; }, getIssues(caseId) { this.result = this.$get("/issues/get/" + caseId, response => {