feat: 测试评审用例支持自定义顺序

This commit is contained in:
chenjianxing 2021-09-24 10:32:32 +08:00 committed by jianxing
parent ec091bd43c
commit 3f6a0e41c7
16 changed files with 185 additions and 27 deletions

View File

@ -23,5 +23,7 @@ public class TestCaseReviewTestCase implements Serializable {
private String createUser;
private Long order;
private static final long serialVersionUID = 1L;
}
}

View File

@ -713,6 +713,66 @@ public class TestCaseReviewTestCaseExample {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andOrderIsNull() {
addCriterion("`order` is null");
return (Criteria) this;
}
public Criteria andOrderIsNotNull() {
addCriterion("`order` is not null");
return (Criteria) this;
}
public Criteria andOrderEqualTo(Long value) {
addCriterion("`order` =", value, "order");
return (Criteria) this;
}
public Criteria andOrderNotEqualTo(Long value) {
addCriterion("`order` <>", value, "order");
return (Criteria) this;
}
public Criteria andOrderGreaterThan(Long value) {
addCriterion("`order` >", value, "order");
return (Criteria) this;
}
public Criteria andOrderGreaterThanOrEqualTo(Long value) {
addCriterion("`order` >=", value, "order");
return (Criteria) this;
}
public Criteria andOrderLessThan(Long value) {
addCriterion("`order` <", value, "order");
return (Criteria) this;
}
public Criteria andOrderLessThanOrEqualTo(Long value) {
addCriterion("`order` <=", value, "order");
return (Criteria) this;
}
public Criteria andOrderIn(List<Long> values) {
addCriterion("`order` in", values, "order");
return (Criteria) this;
}
public Criteria andOrderNotIn(List<Long> values) {
addCriterion("`order` not in", values, "order");
return (Criteria) this;
}
public Criteria andOrderBetween(Long value1, Long value2) {
addCriterion("`order` between", value1, value2, "order");
return (Criteria) this;
}
public Criteria andOrderNotBetween(Long value1, Long value2) {
addCriterion("`order` not between", value1, value2, "order");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
@ -807,4 +867,4 @@ public class TestCaseReviewTestCaseExample {
this(condition, value, secondValue, null);
}
}
}
}

View File

@ -11,6 +11,7 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="order" jdbcType="BIGINT" property="order" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -71,7 +72,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, review_id, case_id, `status`, `result`, reviewer, create_time, update_time, create_user
id, review_id, case_id, `status`, `result`, reviewer, create_time, update_time, create_user,
`order`
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseReviewTestCaseExample" resultMap="BaseResultMap">
select
@ -88,7 +90,7 @@
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from test_case_review_test_case
where id = #{id,jdbcType=VARCHAR}
@ -104,14 +106,14 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseReviewTestCase">
insert into test_case_review_test_case (id, review_id, case_id,
`status`, `result`, reviewer,
create_time, update_time, create_user
)
values (#{id,jdbcType=VARCHAR}, #{reviewId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{reviewer,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}
)
insert into test_case_review_test_case (id, review_id, case_id,
`status`, `result`, reviewer,
create_time, update_time, create_user,
`order`)
values (#{id,jdbcType=VARCHAR}, #{reviewId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{reviewer,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR},
#{order,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseReviewTestCase">
insert into test_case_review_test_case
@ -143,6 +145,9 @@
<if test="createUser != null">
create_user,
</if>
<if test="order != null">
`order`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -172,6 +177,9 @@
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="order != null">
#{order,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseReviewTestCaseExample" resultType="java.lang.Long">
@ -210,6 +218,9 @@
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.order != null">
`order` = #{record.order,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -225,7 +236,8 @@
reviewer = #{record.reviewer,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR}
create_user = #{record.createUser,jdbcType=VARCHAR},
`order` = #{record.order,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -257,6 +269,9 @@
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="order != null">
`order` = #{order,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -269,7 +284,8 @@
reviewer = #{reviewer,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR}
create_user = #{createUser,jdbcType=VARCHAR},
`order` = #{order,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
</mapper>

View File

@ -36,4 +36,13 @@ public interface ExtTestReviewCaseMapper {
List<String> selectTestCaseIds(@Param("request") QueryCaseReviewRequest request);
List<TestReviewCaseDTO> listForMinder(@Param("request") QueryCaseReviewRequest request);
List<String> selectReviewIds();
List<String> getIdsOrderByUpdateTime(@Param("reviewId") String reviewId);
Long getPreOrder(@Param("reviewId")String reviewId, @Param("baseOrder") Long baseOrder);
Long getLastOrder(@Param("reviewId")String reviewId, @Param("baseOrder") Long baseOrder);
}

View File

@ -427,4 +427,28 @@
</where>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="selectReviewIds" resultType="java.lang.String">
select DISTINCT review_id from test_case_review_test_case;
</select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id from test_case_review_test_case where review_id = #{reviewId} order by update_time ASC;
</select>
<select id="getLastOrder" resultType="java.lang.Long">
select `order` from test_case_review_test_case where review_id = #{reviewId}
<if test="baseOrder != null">
and `order` &gt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
<select id="getPreOrder" resultType="java.lang.Long">
select `order` from test_case_review_test_case where review_id = #{reviewId}
<if test="baseOrder != null">
and `order` &lt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
</mapper>

View File

@ -35,6 +35,10 @@ public class ServiceUtils {
return getDefaultOrderByField(null, orders, "order");
}
public static List<OrderRequest> getDefaultSortOrder(String prefix, List<OrderRequest> orders) {
return getDefaultOrderByField(prefix, orders, "order");
}
public static List<OrderRequest> getDefaultOrder(String prefix, List<OrderRequest> orders) {
return getDefaultOrderByField(prefix, orders, "update_time");
}

View File

@ -61,6 +61,8 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
private TestPlanLoadCaseService testPlanLoadCaseService;
@Resource
private ApiDefinitionService apiDefinitionService;
@Resource
private TestReviewTestCaseService testReviewTestCaseService;
@Value("${jmeter.home}")
private String jmeterHome;
@ -128,6 +130,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
initOnceOperate(testPlanApiCaseService::initOrderField, "init.sort.plan.api.case");
initOnceOperate(testPlanScenarioCaseService::initOrderField, "init.sort.plan.api.scenario");
initOnceOperate(testPlanLoadCaseService::initOrderField, "init.sort.plan.api.load");
initOnceOperate(testReviewTestCaseService::initOrderField, "init.sort.review.test.case");
}
/**

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.TestCaseReviewTestCase;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest;
@ -75,4 +76,9 @@ public class TestReviewTestCaseController {
return testReviewTestCaseService.getTestCaseReviewDTOList(request);
}
@PostMapping("/edit/order")
public void orderCase(@RequestBody ResetOrderRequest request) {
testReviewTestCaseService.updateOrder(request);
}
}

View File

@ -294,9 +294,9 @@ public class TestCaseReviewService {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseReviewTestCaseMapper batchMapper = sqlSession.getMapper(TestCaseReviewTestCaseMapper.class);
Long nextOrder = ServiceUtils.getNextOrder(request.getReviewId(), extTestReviewCaseMapper::getLastOrder);
if (!testCaseIds.isEmpty()) {
testCaseIds.forEach(caseId -> {
for (String caseId : testCaseIds) {
TestCaseReviewTestCase caseReview = new TestCaseReviewTestCase();
caseReview.setId(UUID.randomUUID().toString());
caseReview.setReviewer(SessionUtils.getUser().getId());
@ -306,8 +306,10 @@ public class TestCaseReviewService {
caseReview.setUpdateTime(System.currentTimeMillis());
caseReview.setReviewId(request.getReviewId());
caseReview.setStatus(TestCaseReviewStatus.Prepare.name());
caseReview.setOrder(nextOrder);
batchMapper.insert(caseReview);
});
nextOrder += 5000;
}
}
sqlSession.flushStatements();

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
@ -60,7 +61,7 @@ public class TestReviewTestCaseService {
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
public List<TestReviewCaseDTO> list(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
List<TestReviewCaseDTO> list = extTestReviewCaseMapper.list(request);
QueryMemberRequest queryMemberRequest = new QueryMemberRequest();
queryMemberRequest.setWorkspaceId(SessionUtils.getCurrentProjectId());
@ -75,7 +76,7 @@ public class TestReviewTestCaseService {
}
public List<String> selectIds(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
List<String> list = extTestReviewCaseMapper.selectIds(request);
return list;
}
@ -150,7 +151,7 @@ public class TestReviewTestCaseService {
}
public List<TestReviewCaseDTO> getTestCaseReviewDTOList(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
return extTestReviewCaseMapper.list(request);
}
@ -344,7 +345,7 @@ public class TestReviewTestCaseService {
}
public List<TestReviewCaseDTO> listForMinder(QueryCaseReviewRequest request) {
List<OrderRequest> orders = ServiceUtils.getDefaultOrder("tcrtc", request.getOrders());
List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder("tcrtc", request.getOrders());
orders.forEach(order -> {
if (order.getName().equals("update_time")) {
order.setPrefix("tcrtc");
@ -353,4 +354,22 @@ public class TestReviewTestCaseService {
request.setOrders(orders);
return extTestReviewCaseMapper.listForMinder(request);
}
public void initOrderField() {
ServiceUtils.initOrderField(TestCaseReviewTestCase.class, TestCaseReviewMapper.class,
extTestReviewCaseMapper::selectReviewIds,
extTestReviewCaseMapper::getIdsOrderByUpdateTime);
}
/**
* 用例自定义排序
* @param request
*/
public void updateOrder(ResetOrderRequest request) {
ServiceUtils.updateOrderField(request, TestCaseReviewTestCase.class,
testCaseReviewTestCaseMapper::selectByPrimaryKey,
extTestReviewCaseMapper::getPreOrder,
extTestReviewCaseMapper::getLastOrder,
testCaseReviewTestCaseMapper::updateByPrimaryKeySelective);
}
}

View File

@ -1,2 +1,4 @@
CREATE INDEX load_test_report_test_resource_pool_id_index
ON load_test_report (test_resource_pool_id);
ON load_test_report (test_resource_pool_id);
ALTER TABLE test_case_review_test_case ADD `order` bigint(20) NOT NULL COMMENT '自定义排序间隔5000';

View File

@ -193,7 +193,7 @@ quota_max_threads_excess_workspace=The maximum number of concurrent threads exce
quota_max_threads_excess_organization=The maximum number of concurrent threads exceeds the organization quota
quota_duration_excess_workspace=The stress test duration exceeds the work space quota
quota_duration_excess_organization=The stress test duration exceeds the organization quota
import_xmind_count_error=The number of use cases imported into the mind map cannot exceed 500
import_xmind_count_error=The number of use cases imported into the mind map cannot exceed 800
import_xmind_not_found=Test case not found
license_valid_license_error=Authorization authentication failed
test_review_task_notice=Test review task notice
@ -282,4 +282,4 @@ scenario_case=SCENARIO
create_user=Create user
test_case_status=Case status
id_not_rightful=ID is not rightful
id_not_rightful=ID is not rightful

View File

@ -193,7 +193,7 @@ quota_max_threads_excess_workspace=最大并发数超过工作空间限额
quota_max_threads_excess_organization=最大并发数超过组织限额
quota_duration_excess_workspace=压测时长超过工作空间限额
quota_duration_excess_organization=压测时长超过组织限额
import_xmind_count_error=思维导图导入用例数量不能超过 500 条
import_xmind_count_error=思维导图导入用例数量不能超过 800 条
license_valid_license_error=授权认证失败
import_xmind_not_found=未找到测试用例
test_review_task_notice=测试评审任务通知

View File

@ -195,7 +195,7 @@ quota_duration_excess_workspace=壓測時長超過工作空間限額
quota_duration_excess_organization=壓測時長超過組織限額
license_valid_license_error=授權驗證失敗
license_valid_license_code=授權碼已經存在
import_xmind_count_error=思維導圖導入用例數量不能超過 500 條
import_xmind_count_error=思維導圖導入用例數量不能超過 800 條
import_xmind_not_found=未找到测试用例
test_review_task_notice=測試評審任務通知
swagger_url_scheduled_import_notification=swagger_url定時導入通知

View File

@ -30,6 +30,9 @@
@handleRowClick="showDetail"
:fields.sync="fields"
:remember-order="true"
:enable-order-drag="true"
:row-order-func="editTestReviewTestCaseOrder"
:row-order-group-id="reviewId"
@refresh="initTableData"
ref="table"
>
@ -181,6 +184,7 @@ import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOpe
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import MsTable from "@/business/components/common/components/table/MsTable";
import {editTestReviewTestCaseOrder} from "@/network/testCase";
export default {
name: "TestReviewTestCaseList",
@ -286,6 +290,9 @@ export default {
computed: {
selectNodeIds() {
return this.$store.state.testReviewSelectNodeIds;
},
editTestReviewTestCaseOrder() {
return editTestReviewTestCaseOrder;
}
},
created() {

View File

@ -59,3 +59,7 @@ export function getMinderExtraNode(groupId, nodeId, callback) {
return baseGet('/minder/extra/node/list/' + groupId + '/' + nodeId, callback);
}
export function editTestReviewTestCaseOrder(request, callback) {
return basePost('/test/review/case/edit/order', request, callback);
}