refactor(接口测试): 优化接口列表排序
This commit is contained in:
parent
ca1955a99e
commit
1cc659f0e9
|
@ -12,6 +12,7 @@ import io.metersphere.sdk.constants.PermissionConstants;
|
|||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.request.OperationHistoryVersionRequest;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.notice.annotation.SendNotice;
|
||||
|
@ -139,7 +140,7 @@ public class ApiDefinitionController {
|
|||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public Pager<List<ApiDefinitionDTO>> getPage(@Validated @RequestBody ApiDefinitionPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
return PageUtils.setPageInfo(page, apiDefinitionService.getApiDefinitionPage(request, SessionUtils.getUserId()));
|
||||
}
|
||||
|
||||
|
@ -235,4 +236,12 @@ public class ApiDefinitionController {
|
|||
apiDefinitionService.saveOperationHistory(request);
|
||||
}
|
||||
|
||||
@PostMapping("/edit/pos")
|
||||
@Operation(summary = "接口测试-接口管理-接口-拖拽排序")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_UPDATE)
|
||||
public void editPos(@Validated @RequestBody PosRequest request) {
|
||||
apiDefinitionService.editPos(request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class ApiTestCaseController {
|
|||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_READ)
|
||||
public Pager<List<ApiTestCaseDTO>> page(@Validated @RequestBody ApiTestCasePageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
return PageUtils.setPageInfo(page, apiTestCaseService.page(request, false));
|
||||
}
|
||||
|
||||
|
@ -184,11 +184,11 @@ public class ApiTestCaseController {
|
|||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_READ)
|
||||
public Pager<List<ApiTestCaseDTO>> pageTrash(@Validated @RequestBody ApiTestCasePageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
return PageUtils.setPageInfo(page, apiTestCaseService.page(request, true));
|
||||
}
|
||||
|
||||
@PostMapping("edit/pos")
|
||||
@PostMapping("/edit/pos")
|
||||
@Operation(summary = "接口测试-接口管理-接口用例-拖拽排序")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE)
|
||||
public void editPos(@Validated @RequestBody PosRequest request) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.api.service.scenario.ApiScenarioLogService;
|
|||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.notice.annotation.SendNotice;
|
||||
|
@ -45,7 +46,7 @@ public class ApiScenarioController {
|
|||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public Pager<List<ApiScenarioDTO>> getPage(@Validated @RequestBody ApiScenarioPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
return PageUtils.setPageInfo(page, apiScenarioService.getScenarioPage(request));
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class ApiScenarioController {
|
|||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public Pager<List<ApiScenarioDTO>> getTrashPage(@Validated @RequestBody ApiScenarioPageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
request.setDeleted(true);
|
||||
return PageUtils.setPageInfo(page, apiScenarioService.getScenarioPage(request));
|
||||
}
|
||||
|
@ -200,5 +201,12 @@ public class ApiScenarioController {
|
|||
return apiScenarioService.getSystemRequest(request);
|
||||
}
|
||||
|
||||
@PostMapping("/edit/pos")
|
||||
@Operation(summary = "接口测试-接口场景管理-场景-拖拽排序")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_UPDATE)
|
||||
public void editPos(@Validated @RequestBody PosRequest request) {
|
||||
apiScenarioService.editPos(request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -57,4 +57,8 @@ public interface ExtApiDefinitionMapper {
|
|||
List<ApiDefinitionCustomField> getCustomFieldByCaseIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<String> getIdsByModules(@Param("request") ScenarioSystemRequest request);
|
||||
|
||||
Long getPrePos(@Param("projectId") String projectId, @Param("basePos") Long basePos);
|
||||
|
||||
Long getLastPos(@Param("projectId") String projectId, @Param("basePos") Long basePos);
|
||||
}
|
||||
|
|
|
@ -524,4 +524,21 @@
|
|||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getPrePos" resultType="java.lang.Long">
|
||||
select `pos` from api_definition where project_id = #{projectId}
|
||||
<if test="basePos != null">
|
||||
and `pos` < #{basePos}
|
||||
</if>
|
||||
order by `pos` desc limit 1;
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getLastPos" resultType="java.lang.Long">
|
||||
select `pos` from api_definition where project_id = #{projectId}
|
||||
<if test="basePos != null">
|
||||
and `pos` > #{basePos}
|
||||
</if>
|
||||
order by `pos` desc limit 1;
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -39,4 +39,9 @@ public interface ExtApiScenarioMapper {
|
|||
List<String> getIdsByModules(@Param("request") ScenarioSystemRequest scenarioRequest);
|
||||
|
||||
List<String> selectByProjectId(String projectId);
|
||||
|
||||
Long getPrePos(@Param("projectId") String projectId, @Param("basePos") Long basePos);
|
||||
|
||||
Long getLastPosEdit(@Param("projectId") String projectId, @Param("basePos") Long basePos);
|
||||
|
||||
}
|
||||
|
|
|
@ -479,4 +479,21 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getPrePos" resultType="java.lang.Long">
|
||||
select `pos` from api_scenario where project_id = #{projectId}
|
||||
<if test="basePos != null">
|
||||
and `pos` < #{basePos}
|
||||
</if>
|
||||
order by `pos` desc limit 1;
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getLastPosEdit" resultType="java.lang.Long">
|
||||
select `pos` from api_scenario where project_id = #{projectId}
|
||||
<if test="basePos != null">
|
||||
and `pos` > #{basePos}
|
||||
</if>
|
||||
order by `pos` desc limit 1;
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
t1.last_report_id,
|
||||
t1.environment_id,
|
||||
t1.tags,
|
||||
a.module_id
|
||||
a.module_id,
|
||||
t1.pos
|
||||
FROM
|
||||
api_test_case t1
|
||||
LEFT JOIN api_report t3 ON t1.last_report_id = t3.id
|
||||
|
|
|
@ -28,6 +28,7 @@ import io.metersphere.system.dto.OperationHistoryDTO;
|
|||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.request.OperationHistoryVersionRequest;
|
||||
import io.metersphere.system.dto.sdk.SessionUser;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.service.OperationHistoryService;
|
||||
|
@ -999,4 +1000,13 @@ public class ApiDefinitionService {
|
|||
apiDefinitionBlobExample.createCriteria().andIdIn(apiIds);
|
||||
return apiDefinitionBlobMapper.selectByExampleWithBLOBs(apiDefinitionBlobExample);
|
||||
}
|
||||
|
||||
public void editPos(PosRequest request) {
|
||||
ServiceUtils.updatePosField(request,
|
||||
ApiDefinition.class,
|
||||
apiDefinitionMapper::selectByPrimaryKey,
|
||||
extApiDefinitionMapper::getPrePos,
|
||||
extApiTestCaseMapper::getLastPos,
|
||||
apiDefinitionMapper::updateByPrimaryKeySelective);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import io.metersphere.system.domain.Schedule;
|
|||
import io.metersphere.system.domain.ScheduleExample;
|
||||
import io.metersphere.system.dto.LogInsertModule;
|
||||
import io.metersphere.system.dto.request.ScheduleConfig;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.ScheduleMapper;
|
||||
|
@ -1951,4 +1952,13 @@ public class ApiScenarioService {
|
|||
}
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void editPos(PosRequest request) {
|
||||
ServiceUtils.updatePosField(request,
|
||||
ApiScenario.class,
|
||||
apiScenarioMapper::selectByPrimaryKey,
|
||||
extApiScenarioMapper::getPrePos,
|
||||
extApiScenarioMapper::getLastPosEdit,
|
||||
apiScenarioMapper::updateByPrimaryKeySelective);
|
||||
}
|
||||
}
|
|
@ -24,8 +24,6 @@ import io.metersphere.sdk.constants.SessionConstants;
|
|||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.file.FileCenter;
|
||||
import io.metersphere.sdk.file.FileRequest;
|
||||
import io.metersphere.sdk.mapper.OperationLogBlobMapper;
|
||||
import io.metersphere.sdk.mapper.OperationLogMapper;
|
||||
import io.metersphere.sdk.util.*;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
|
@ -35,6 +33,7 @@ import io.metersphere.system.domain.OperationHistoryExample;
|
|||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.request.OperationHistoryVersionRequest;
|
||||
import io.metersphere.system.dto.sdk.BaseCondition;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.OperationHistoryMapper;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
|
@ -1047,6 +1046,24 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
|||
Assertions.assertNotNull(comparisonNewVersion);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testPos() throws Exception {
|
||||
|
||||
apiDefinition = apiDefinitionMapper.selectByPrimaryKey("1001");
|
||||
ApiDefinition apiDefinition1 = apiDefinitionMapper.selectByPrimaryKey("1002");
|
||||
PosRequest posRequest = new PosRequest();
|
||||
posRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
posRequest.setTargetId(apiDefinition.getId());
|
||||
posRequest.setMoveId(apiDefinition1.getId());
|
||||
posRequest.setMoveMode("AFTER");
|
||||
this.requestPostWithOkAndReturn(BASE_PATH + "edit/pos", posRequest);
|
||||
|
||||
posRequest.setMoveMode("BEFORE");
|
||||
this.requestPostWithOkAndReturn(BASE_PATH + "edit/pos", posRequest);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
public void testOperationHistoryRecover() throws Exception {
|
||||
|
|
|
@ -53,6 +53,7 @@ import io.metersphere.system.controller.handler.ResultHolder;
|
|||
import io.metersphere.system.domain.Plugin;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.dto.request.PluginUpdateRequest;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.ScheduleMapper;
|
||||
import io.metersphere.system.service.PluginLoadService;
|
||||
|
@ -2062,8 +2063,20 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testPos() throws Exception {
|
||||
PosRequest posRequest = new PosRequest();
|
||||
posRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
posRequest.setTargetId(addApiScenario.getId());
|
||||
posRequest.setMoveId(anOtherAddApiScenario.getId());
|
||||
posRequest.setMoveMode("AFTER");
|
||||
this.requestPostWithOkAndReturn("/edit/pos", posRequest);
|
||||
|
||||
posRequest.setMoveMode("BEFORE");
|
||||
this.requestPostWithOkAndReturn("/edit/pos", posRequest);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(35)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
)
|
||||
|
||||
</if>
|
||||
ORDER BY update_time DESC
|
||||
ORDER BY pos DESC
|
||||
</select>
|
||||
<select id="groupList" resultType="io.metersphere.sdk.domain.EnvironmentGroup">
|
||||
SELECT
|
||||
|
@ -33,7 +33,7 @@
|
|||
)
|
||||
|
||||
</if>
|
||||
ORDER BY update_time DESC
|
||||
ORDER BY pos DESC
|
||||
</select>
|
||||
<select id="getPos" resultType="java.lang.Long">
|
||||
SELECT pos
|
||||
|
|
Loading…
Reference in New Issue