fix(接口定义): 修复删除模块报错的缺陷
--bug=1015154 --user=王孝刚 【接口测试】接口定义列表,删除模块报错 https://www.tapd.cn/55049933/s/1209483
This commit is contained in:
parent
9578fb6318
commit
05504d5ae5
|
@ -47,4 +47,7 @@ public class ApiDefinitionRequest extends BaseQueryRequest {
|
||||||
|
|
||||||
//全选
|
//全选
|
||||||
private boolean selectAll;
|
private boolean selectAll;
|
||||||
|
|
||||||
|
private Long deleteTime;
|
||||||
|
private String deleteUserId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ApiModuleMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiModuleMapper;
|
import io.metersphere.base.mapper.ext.ExtApiModuleMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.TestCaseConstants;
|
import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
|
@ -62,6 +63,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
private ApiDefinitionService apiDefinitionService;
|
private ApiDefinitionService apiDefinitionService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestCaseMapper apiTestCaseMapper;
|
private ApiTestCaseMapper apiTestCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
SqlSessionFactory sqlSessionFactory;
|
SqlSessionFactory sqlSessionFactory;
|
||||||
|
@ -347,16 +350,25 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteNode(List<String> nodeIds) {
|
public int deleteNode(List<String> nodeIds) {
|
||||||
ApiDefinitionExampleWithOperation apiDefinitionExample = new ApiDefinitionExampleWithOperation();
|
if (CollectionUtils.isNotEmpty(nodeIds)) {
|
||||||
apiDefinitionExample.createCriteria().andModuleIdIn(nodeIds);
|
//删除case
|
||||||
apiDefinitionExample.setOperator(SessionUtils.getUserId());
|
ApiTestCaseRequest request = new ApiTestCaseRequest();
|
||||||
apiDefinitionExample.setOperationTime(System.currentTimeMillis());
|
request.setIds(nodeIds);
|
||||||
apiDefinitionService.removeToGcByExample(apiDefinitionExample);
|
request.setDeleteUserId(SessionUtils.getUserId());
|
||||||
// extApiDefinitionMapper.removeToGcByExample(apiDefinitionExample); // 删除模块,则模块下的接口放入回收站
|
request.setDeleteTime(System.currentTimeMillis());
|
||||||
|
extApiTestCaseMapper.deleteCaseToGc(request);
|
||||||
|
//删除api
|
||||||
|
ApiDefinitionRequest apiDefinitionRequest = new ApiDefinitionRequest();
|
||||||
|
apiDefinitionRequest.setIds(nodeIds);
|
||||||
|
apiDefinitionRequest.setDeleteUserId(SessionUtils.getUserId());
|
||||||
|
apiDefinitionRequest.setDeleteTime(System.currentTimeMillis());
|
||||||
|
extApiDefinitionMapper.deleteApiToGc(apiDefinitionRequest);
|
||||||
|
|
||||||
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
|
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
|
||||||
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);
|
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);
|
||||||
return apiModuleMapper.deleteByExample(apiDefinitionNodeExample);
|
return apiModuleMapper.deleteByExample(apiDefinitionNodeExample);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void batchUpdateApiDefinition(List<ApiDefinitionResult> apiModule) {
|
private void batchUpdateApiDefinition(List<ApiDefinitionResult> apiModule) {
|
||||||
|
|
|
@ -104,4 +104,6 @@ public interface ExtApiDefinitionMapper {
|
||||||
int countById(String id);
|
int countById(String id);
|
||||||
|
|
||||||
List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId);
|
List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId);
|
||||||
|
|
||||||
|
int deleteApiToGc(ApiDefinitionRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,21 @@
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
request
|
request
|
||||||
</sql>
|
</sql>
|
||||||
|
<delete id="deleteApiToGc" parameterType="io.metersphere.api.dto.definition.ApiDefinitionRequest">
|
||||||
|
update api_definition
|
||||||
|
set original_state=status,
|
||||||
|
status = 'Trash', delete_user_id = #{deleteUserId},delete_time = #{deleteTime}, to_be_updated = 0
|
||||||
|
where id in (
|
||||||
|
SELECT api_tmp.* from (
|
||||||
|
SELECT id from api_definition api INNER JOIN (
|
||||||
|
SELECT ref_id from api_definition where module_id in
|
||||||
|
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||||
|
#{v}
|
||||||
|
</foreach>
|
||||||
|
) api_ref on api_ref.ref_id = api.ref_id
|
||||||
|
) api_tmp
|
||||||
|
)
|
||||||
|
</delete>
|
||||||
|
|
||||||
<select id="selectByIds" resultType="io.metersphere.api.dto.definition.ApiComputeResult">
|
<select id="selectByIds" resultType="io.metersphere.api.dto.definition.ApiComputeResult">
|
||||||
SELECT t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
SELECT t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
||||||
|
|
|
@ -86,4 +86,6 @@ public interface ExtApiTestCaseMapper {
|
||||||
int countById(String resourceID);
|
int countById(String resourceID);
|
||||||
|
|
||||||
List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId);
|
List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId);
|
||||||
|
|
||||||
|
int deleteCaseToGc(ApiTestCaseRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -870,6 +870,18 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteCaseToGc" parameterType="io.metersphere.api.dto.definition.ApiTestCaseRequest">
|
||||||
|
update api_test_case
|
||||||
|
set original_status=status,
|
||||||
|
status = 'Trash',delete_time = #{deleteTime},delete_user_id = #{deleteUserId}, to_be_updated = 0
|
||||||
|
where api_definition_id IN
|
||||||
|
(SELECT id from api_definition api INNER JOIN (
|
||||||
|
SELECT ref_id from api_definition where module_id in
|
||||||
|
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||||
|
#{v}
|
||||||
|
</foreach>
|
||||||
|
) api_ref on api.ref_id = api_ref.ref_id)
|
||||||
|
</update>
|
||||||
<update id="reduction">
|
<update id="reduction">
|
||||||
update api_test_case
|
update api_test_case
|
||||||
set status = original_status
|
set status = original_status
|
||||||
|
|
Loading…
Reference in New Issue