fix(接口定义): 修复自定义排序不生效的缺陷

--bug=1017736 --user=王孝刚 【接口测试】接口定义自定义排序,刷新后又恢复了原来的顺序
https://www.tapd.cn/55049933/s/1257672
This commit is contained in:
wxg0103 2022-10-11 10:50:30 +08:00 committed by f2c-ci-robot[bot]
parent a50728b648
commit 89e3fa61aa
6 changed files with 22 additions and 55 deletions

View File

@ -369,7 +369,7 @@ public class ApiDefinitionService {
//计算全部用例
definitionList = this.selectEffectiveIdByProjectId(request.getProjectId());
}
if (CollectionUtils.isNotEmpty(definitionList)) {
//如果查询条件中有未覆盖/已覆盖 则需要解析出没有用例的接口中有多少是符合场景覆盖规律的然后将这些接口的id作为查询参数
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(request.getProjectId());
@ -1862,11 +1862,13 @@ public class ApiDefinitionService {
String tags = apiDefinition.getTags();
if (StringUtils.isBlank(tags) || BooleanUtils.isFalse(request.isAppendTag())) {
apiDefinition.setTags(JSON.toJSONString(request.getTagList()));
apiDefinition.setUpdateTime(System.currentTimeMillis());
} else {
try {
List<String> list = JSON.parseArray(tags, String.class);
list.addAll(request.getTagList());
apiDefinition.setTags(JSON.toJSONString(list));
apiDefinition.setUpdateTime(System.currentTimeMillis());
} catch (Exception e) {
LogUtil.error("batch edit tags error.");
LogUtil.error(e, e.getMessage());

View File

@ -2,56 +2,23 @@ package io.metersphere.service.definition;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.api.dto.ApiCaseEditRequest;
import io.metersphere.api.dto.ApiCaseRelevanceRequest;
import io.metersphere.api.dto.ApiCountChartResult;
import io.metersphere.api.dto.ApiCountRequest;
import io.metersphere.api.dto.DeleteCheckResult;
import io.metersphere.api.dto.*;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.datacount.ApiDataCountResult;
import io.metersphere.api.dto.datacount.response.ExecuteResultCountDTO;
import io.metersphere.api.dto.definition.ApiTestBatchRequest;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseInfo;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.definition.*;
import io.metersphere.api.dto.definition.request.ElementUtil;
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.base.domain.*;
import io.metersphere.service.ext.ExtFileAssociationService;
import io.metersphere.service.plan.TestPlanApiCaseService;
import io.metersphere.service.scenario.ApiScenarioReferenceIdService;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.ApiScenarioReferenceIdMapper;
import io.metersphere.base.mapper.ApiTestCaseFollowMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
import io.metersphere.base.mapper.ProjectApplicationMapper;
import io.metersphere.base.mapper.ext.BaseProjectVersionMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
import io.metersphere.commons.constants.CommonConstants;
import io.metersphere.commons.constants.ElementConstants;
import io.metersphere.commons.constants.MsTestElementConstants;
import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.RequestTypeConstants;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.*;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.enums.ApiReportStatus;
import io.metersphere.commons.enums.ApiTestDataStatus;
import io.metersphere.commons.enums.FileAssociationTypeEnums;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.FileUtils;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.*;
import io.metersphere.dto.ParamsDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
@ -63,7 +30,9 @@ import io.metersphere.request.OrderRequest;
import io.metersphere.request.ResetOrderRequest;
import io.metersphere.service.BaseUserService;
import io.metersphere.service.ServiceUtils;
import io.metersphere.commons.utils.JSONUtil;
import io.metersphere.service.ext.ExtFileAssociationService;
import io.metersphere.service.plan.TestPlanApiCaseService;
import io.metersphere.service.scenario.ApiScenarioReferenceIdService;
import io.metersphere.xpack.api.service.ApiCaseBatchSyncService;
import io.metersphere.xpack.api.service.ApiTestCaseSyncService;
import org.apache.commons.beanutils.BeanComparator;
@ -83,15 +52,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
import static io.metersphere.commons.utils.ShareUtil.getTimeMills;
@ -750,11 +711,13 @@ public class ApiTestCaseService {
String tags = apiTestCase.getTags();
if (StringUtils.isBlank(tags) || BooleanUtils.isFalse(request.isAppendTag())) {
apiTestCase.setTags(JSON.toJSONString(request.getTagList()));
apiTestCase.setUpdateTime(System.currentTimeMillis());
} else {
try {
List<String> list = JSON.parseArray(tags, String.class);
list.addAll(request.getTagList());
apiTestCase.setTags(JSON.toJSONString(list));
apiTestCase.setUpdateTime(System.currentTimeMillis());
} catch (Exception e) {
LogUtil.error("batch edit tags error.");
LogUtil.error(e, e.getMessage());

View File

@ -1132,11 +1132,13 @@ public class ApiScenarioService {
String tags = apiScenario.getTags();
if (StringUtils.isBlank(tags) || BooleanUtils.isFalse(request.isAppendTag())) {
apiScenario.setTags(JSON.toJSONString(request.getTagList()));
apiScenario.setUpdateTime(System.currentTimeMillis());
} else {
try {
List<String> list = JSON.parseArray(tags, String.class);
list.addAll(request.getTagList());
apiScenario.setTags(JSON.toJSONString(list));
apiScenario.setUpdateTime(System.currentTimeMillis());
} catch (Exception e) {
LogUtil.error("batch edit tags error.");
LogUtil.error(e, e.getMessage());

View File

@ -2,7 +2,7 @@ import {fileUpload} from "@/api/base-network";
import {get, post} from "metersphere-frontend/src/plugins/request"
export function editApiTestCaseOrder(request) {
return get('/api/testcase/sort', request);
return post('/api/testcase/sort', request);
}
export function getCaseById(id) {

View File

@ -10,7 +10,7 @@ export function getRelationshipApi(id, relationshipType) {
}
export function editApiDefinitionOrder(request) {
return get('/api/definition/sort', request);
return post('/api/definition/sort', request);
}
export function getDefinitionById(id) {

View File

@ -188,7 +188,7 @@
/>
</div>
<!-- 快捷调试 -->
<div v-else-if="item.type=== 'debug'" class="ms-api-div">
<div v-else-if="item.type=== 'debug'" class="ms-api-schedule-div">
<ms-debug-http-page
:currentProtocol="currentProtocol"
:testCase="item.api"
@ -250,7 +250,7 @@
<script>
import {createDefinitionEnv, getDefinitionById, getDefinitionEnv} from "@/api/definition";
import {getProjectConfig} from "@/api/project";
import {getApiModuleByProjectIdAndProtocol, getApiModules, trashCount} from "@/api/definition-module";
import {getApiModuleByProjectIdAndProtocol, trashCount} from "@/api/definition-module";
import MsApiList from './components/list/ApiList';
import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
@ -804,7 +804,7 @@ export default {
if (selectParamArr.length === 2) {
let scenarioId = selectParamArr[1];
if (dataType === 'api') {
getDefinitionById( scenarioId).then((response) => {
getDefinitionById(scenarioId).then((response) => {
this.defaultProtocol = response.data.protocol;
this.editApi(response.data);
});