Merge branch 'master' of https://github.com/metersphere/server
This commit is contained in:
commit
37bf65ce07
|
@ -14,6 +14,7 @@ import io.metersphere.track.dto.TestPlanDTOWithMetric;
|
|||
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
|
||||
import io.metersphere.track.service.TestPlanProjectService;
|
||||
import io.metersphere.track.service.TestPlanService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
|
@ -111,8 +112,18 @@ public class TestPlanController {
|
|||
return testPlanService.getProjectNameByPlanId(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/project/{planId}")
|
||||
public List<Project> getProjectByPlanId(@PathVariable String planId) {
|
||||
return testPlanProjectService.getProjectByPlanId(planId);
|
||||
@PostMapping("/project")
|
||||
public List<Project> getProjectByPlanId(@RequestBody TestCaseRelevanceRequest request) {
|
||||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
|
||||
request.setProjectIds(projectIds);
|
||||
return testPlanProjectService.getProjectByPlanId(request);
|
||||
}
|
||||
|
||||
@PostMapping("/project/{goPage}/{pageSize}")
|
||||
public Pager<List<Project>> getProjectByPlanId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestCaseRelevanceRequest request) {
|
||||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
|
||||
request.setProjectIds(projectIds);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, testPlanProjectService.getProjectByPlanId(request));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.track.request.testplancase;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestCaseRelevanceRequest {
|
||||
private String planId;
|
||||
private String name;
|
||||
private List<String> projectIds;
|
||||
}
|
|
@ -6,26 +6,25 @@ import io.metersphere.base.domain.TestPlanProject;
|
|||
import io.metersphere.base.domain.TestPlanProjectExample;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.TestPlanProjectMapper;
|
||||
import org.python.antlr.ast.Str;
|
||||
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TestPlanProjectService {
|
||||
|
||||
|
||||
@Resource
|
||||
TestPlanProjectMapper testPlanProjectMapper;
|
||||
@Resource
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
|
||||
public List<String> getProjectIdsByPlanId(String planId) {
|
||||
TestPlanProjectExample example = new TestPlanProjectExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
|
@ -41,12 +40,14 @@ public class TestPlanProjectService {
|
|||
return projectIds;
|
||||
}
|
||||
|
||||
public List<Project> getProjectByPlanId(String planId) {
|
||||
List<String> projectIds = getProjectIdsByPlanId(planId);
|
||||
public List<Project> getProjectByPlanId(TestCaseRelevanceRequest request) {
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andIdIn(projectIds);
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
return Optional.ofNullable(projects).orElse(new ArrayList<>());
|
||||
ProjectExample.Criteria criteria = projectExample.createCriteria();
|
||||
criteria.andIdIn(request.getProjectIds());
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
return projectMapper.selectByExample(projectExample);
|
||||
}
|
||||
|
||||
public void deleteTestPlanProjectByPlanId(String planId) {
|
||||
|
|
|
@ -1,86 +1,101 @@
|
|||
<template>
|
||||
<el-dialog v-loading="result.loading"
|
||||
:visible.sync="dialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
@current-change="handleCurrentChange"
|
||||
style="width: 100%">
|
||||
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
|
||||
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
{{ scope.row.description }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="createTime"
|
||||
:label="$t('commons.create_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sortable
|
||||
prop="updateTime"
|
||||
:label="$t('commons.update_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template v-slot:footer>
|
||||
<div class="dialog-footer">
|
||||
<ms-dialog-footer
|
||||
@cancel="dialogVisible = false"
|
||||
@confirm="submit()"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-loading="result.loading"
|
||||
:visible.sync="dialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
class="ms-switch-project"
|
||||
>
|
||||
<ms-table-header :condition.sync="condition" @search="initData" title="" :show-create="false"/>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
highlight-current-row
|
||||
@current-change="handleCurrentChange"
|
||||
style="width: 100%">
|
||||
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
|
||||
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
{{ scope.row.description }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
:label="$t('commons.create_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="updateTime"
|
||||
:label="$t('commons.update_time')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<ms-table-pagination :change="initData" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
<template v-slot:footer>
|
||||
<div class="dialog-footer">
|
||||
<ms-dialog-footer
|
||||
@cancel="dialogVisible = false"
|
||||
@confirm="submit()"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsDialogFooter from "../../../common/components/MsDialogFooter";
|
||||
import MsDialogFooter from "../../../common/components/MsDialogFooter";
|
||||
import MsTableHeader from "../../../common/components/MsTableHeader";
|
||||
import MsTablePagination from "../../../common/pagination/TablePagination";
|
||||
|
||||
export default {
|
||||
name: "SwitchProject",
|
||||
components: {MsDialogFooter},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
result: {},
|
||||
dialogVisible: false,
|
||||
projectId: ''
|
||||
export default {
|
||||
name: "SwitchProject",
|
||||
components: {MsDialogFooter, MsTableHeader, MsTablePagination},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
result: {},
|
||||
dialogVisible: false,
|
||||
projectId: '',
|
||||
planId: '',
|
||||
condition: {},
|
||||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
total: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(planId) {
|
||||
this.dialogVisible = true;
|
||||
this.planId = planId;
|
||||
this.initData();
|
||||
},
|
||||
initData() {
|
||||
this.condition.planId = this.planId;
|
||||
this.result = this.$post("/test/plan/project/" + this.currentPage + "/" + this.pageSize, this.condition, res => {
|
||||
const data = res.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
})
|
||||
},
|
||||
handleCurrentChange(currentRow) {
|
||||
// initData 改变表格数据会触发此方法
|
||||
if (currentRow) {
|
||||
this.projectId = currentRow.id;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(planId) {
|
||||
this.dialogVisible = true;
|
||||
this.initData(planId);
|
||||
},
|
||||
initData(planId) {
|
||||
this.result = this.$get("/test/plan/project/" + planId,res => {
|
||||
this.tableData = res.data;
|
||||
})
|
||||
},
|
||||
handleCurrentChange(currentRow) {
|
||||
// initData 改变表格数据会触发此方法
|
||||
if (currentRow) {
|
||||
this.projectId = currentRow.id;
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
this.$emit('getProjectNode', this.projectId);
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
submit() {
|
||||
this.$emit('getProjectNode', this.projectId);
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.ms-switch-project >>> .el-dialog__body {
|
||||
padding: 0 15px !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -192,8 +192,8 @@ export default {
|
|||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
let path = "/test/plan/project/" + this.tableData[i].id;
|
||||
this.$get(path, res => {
|
||||
let path = "/test/plan/project";
|
||||
this.$post(path,{planId: this.tableData[i].id}, res => {
|
||||
let arr = res.data;
|
||||
let projectName = arr.map(data => data.name).join("、");
|
||||
let projectIds = arr.map(data => data.id);
|
||||
|
|
|
@ -256,7 +256,7 @@
|
|||
},
|
||||
getProject() {
|
||||
if (this.planId) {
|
||||
this.$get("/test/plan/project/" + this.planId,res => {
|
||||
this.$post("/test/plan/project/", {planId: this.planId},res => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.projects = data;
|
||||
|
|
Loading…
Reference in New Issue