提交 4df45d19 编写于 作者: C chenjianxing

测试用例筛选排序

上级 7c9004aa
......@@ -5,6 +5,7 @@ import io.metersphere.controller.request.ReportRequest;
import io.metersphere.controller.request.testcase.QueryTestCaseRequest;
import io.metersphere.controller.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.dto.ReportDTO;
import io.metersphere.dto.TestCaseDTO;
import io.metersphere.dto.TestPlanCaseDTO;
import org.apache.ibatis.annotations.Param;
......@@ -15,4 +16,6 @@ public interface ExtTestCaseMapper {
List<TestCase> getTestCaseNames(@Param("request") QueryTestCaseRequest request);
List<TestPlanCaseDTO> getTestPlanTestCases(@Param("request") QueryTestPlanCaseRequest request);
List<TestCaseDTO> list(@Param("request") QueryTestCaseRequest request);
}
......@@ -41,4 +41,38 @@
and t1.executor = #{request.executor}
</if>
</select>
<select id="list" resultType="io.metersphere.dto.TestCaseDTO">
select test_case.*, user.name as maintainerName
from test_case
left join user on test_case.maintainer = user.id
<where>
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and test_case.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
</foreach>
</if>
</where>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.testcase.QueryTestCaseRequest;
import io.metersphere.controller.request.testcase.TestCaseBatchRequest;
import io.metersphere.controller.request.testcase.TestPlanCaseBatchRequest;
import io.metersphere.dto.TestCaseDTO;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.service.TestCaseService;
import io.metersphere.user.SessionUtils;
......@@ -16,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
@RequestMapping("/test/case")
......@@ -26,7 +28,7 @@ public class TestCaseController {
TestCaseService testCaseService;
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<TestCaseWithBLOBs>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
public Pager<List<TestCaseDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.listTestCase(request));
}
......
package io.metersphere.controller.request;
import lombok.Data;
@Data
public class OrderRequest {
private String name;
private String value;
}
package io.metersphere.controller.request.testcase;
import io.metersphere.base.domain.TestCase;
import io.metersphere.controller.request.FilterRequest;
import io.metersphere.controller.request.OrderRequest;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class QueryTestCaseRequest extends TestCase {
private List<String> nodeIds;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private String planId;
private String workspaceId;
......
package io.metersphere.controller.request.testplancase;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestPlanTestCase;
import io.metersphere.controller.request.OrderRequest;
import lombok.Data;
import java.util.List;
......@@ -11,6 +11,8 @@ public class QueryTestPlanCaseRequest extends TestPlanTestCase {
private List<String> nodeIds;
private List<OrderRequest> orders;
private String workspaceId;
private String name;
......
package io.metersphere.dto;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import lombok.Data;
@Data
public class TestCaseDTO extends TestCaseWithBLOBs{
private String maintainerName;
public String getMaintainerName() {
return maintainerName;
}
public void setMaintainerName(String maintainerName) {
this.maintainerName = maintainerName;
}
}
......@@ -2,34 +2,12 @@ package io.metersphere.dto;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import lombok.Data;
@Data
public class TestPlanCaseDTO extends TestCaseWithBLOBs {
private String executor;
private String status;
private String results;
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getResults() {
return results;
}
public void setResults(String results) {
this.results = results;
}
}
......@@ -12,6 +12,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.controller.request.testcase.QueryTestCaseRequest;
import io.metersphere.controller.request.testcase.TestCaseBatchRequest;
import io.metersphere.controller.request.testcase.TestPlanCaseBatchRequest;
import io.metersphere.dto.TestCaseDTO;
import io.metersphere.excel.domain.ExcelErrData;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.excel.domain.TestCaseExcelData;
......@@ -101,19 +102,8 @@ public class TestCaseService {
return testCaseMapper.deleteByPrimaryKey(testCaseId);
}
public List<TestCaseWithBLOBs> listTestCase(QueryTestCaseRequest request) {
TestCaseExample testCaseExample = new TestCaseExample();
TestCaseExample.Criteria criteria = testCaseExample.createCriteria();
if ( StringUtils.isNotBlank(request.getName()) ) {
criteria.andNameLike("%" + request.getName() + "%");
}
if ( StringUtils.isNotBlank(request.getProjectId()) ) {
criteria.andProjectIdEqualTo(request.getProjectId());
}
if ( request.getNodeIds() != null && request.getNodeIds().size() > 0) {
criteria.andNodeIdIn(request.getNodeIds());
}
return testCaseMapper.selectByExampleWithBLOBs(testCaseExample);
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request) {
return extTestCaseMapper.list(request);
}
/**
......
......@@ -21,6 +21,7 @@ mybatis.configuration.multiple-result-sets-enabled=true
mybatis.configuration.use-column-label=true
mybatis.configuration.auto-mapping-behavior=full
mybatis.configuration.default-statement-timeout=25000
mybatis.configuration.map-underscore-to-camel-case=true
logging.file.path=/opt/metersphere/logs/${spring.application.name}
......
......@@ -3,9 +3,9 @@
<div>
<el-dialog :title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
:visible.sync="dialogFormVisible" width="65%" v-loading="result.loading">
:visible.sync="dialogFormVisible" width="65%">
<el-form :model="form" :rules="rules" ref="caseFrom">
<el-form :model="form" :rules="rules" ref="caseFrom" v-loading="result.loading">
<el-row>
<el-col :span="8" :offset="1">
......
......@@ -22,6 +22,8 @@
<el-table
:data="tableData"
@sort-change="sort"
@filter-change="filter"
@select-all="handleSelectAll"
@select="handleSelectionChange"
@row-click="showDetail"
......@@ -37,7 +39,7 @@
<el-table-column
prop="priority"
:filters="priorityFilters"
:filter-method="filter"
column-key="priority"
:label="$t('test_track.case.priority')"
show-overflow-tooltip>
<template v-slot:default="scope">
......@@ -47,7 +49,7 @@
<el-table-column
prop="type"
:filters="typeFilters"
:filter-method="filter"
column-key="type"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
......@@ -56,8 +58,8 @@
</el-table-column>
<el-table-column
prop="method"
column-key="method"
:filters="methodFilters"
:filter-method="filter"
:label="$t('test_track.case.method')"
show-overflow-tooltip>
<template v-slot:default="scope">
......@@ -72,7 +74,7 @@
<el-table-column
prop="updateTime"
sortable
sortable="custom"
:label="$t('commons.update_time')"
show-overflow-tooltip>
<template v-slot:default="scope">
......@@ -113,6 +115,7 @@
import MsTableOperator from "../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
import MsTableButton from "../../../common/components/MsTableButton";
import {humpToLine} from "../../../../../common/js/utils";
export default {
name: "TestCaseList",
......@@ -222,9 +225,18 @@
this.selectIds.clear();
this.$emit('refresh');
},
filter(value, row, column) {
const property = column['property'];
return row[property] === value;
filter(filters) {
if (!this.condition.filters) {
this.condition.filters = {};
}
for(let filter in filters) {
if (filters[filter] && filters[filter].length > 0) {
this.condition.filters[filter] = filters[filter];
} else {
this.condition.filters[filter] = null;
}
}
this.initTableData();
},
showDetail(row, event, column) {
this.$emit('testCaseDetail', row);
......@@ -250,6 +262,29 @@
},
moveToNode() {
this.$emit('moveToNode', this.selectIds);
},
sort(column) {
column.prop = humpToLine(column.prop);
if (column.order == 'descending') {
column.order = 'desc';
} else {
column.order = 'asc';
}
if (!this.condition.orders) {
this.condition.orders = [];
}
let hasProp = false;
this.condition.orders.forEach(order => {
if (order.name == column.prop) {
order.type = column.order;
hasProp = true;
return;
}
});
if (!hasProp) {
this.condition.orders.push({name: column.prop, type: column.order});
}
this.initTableData();
}
}
}
......
......@@ -55,3 +55,8 @@ export function mapToJson(strMap){
}
return JSON.stringify(obj);
}
// 驼峰转换下划线
export function humpToLine(name) {
return name.replace(/([A-Z])/g,"_$1").toLowerCase();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册