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 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.ext.ExtApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiModuleMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||
import io.metersphere.commons.constants.TestCaseConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
|
@ -62,6 +63,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
private ApiDefinitionService apiDefinitionService;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ExtApiTestCaseMapper extApiTestCaseMapper;
|
||||
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
@ -347,16 +350,25 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
}
|
||||
|
||||
public int deleteNode(List<String> nodeIds) {
|
||||
ApiDefinitionExampleWithOperation apiDefinitionExample = new ApiDefinitionExampleWithOperation();
|
||||
apiDefinitionExample.createCriteria().andModuleIdIn(nodeIds);
|
||||
apiDefinitionExample.setOperator(SessionUtils.getUserId());
|
||||
apiDefinitionExample.setOperationTime(System.currentTimeMillis());
|
||||
apiDefinitionService.removeToGcByExample(apiDefinitionExample);
|
||||
// extApiDefinitionMapper.removeToGcByExample(apiDefinitionExample); // 删除模块,则模块下的接口放入回收站
|
||||
if (CollectionUtils.isNotEmpty(nodeIds)) {
|
||||
//删除case
|
||||
ApiTestCaseRequest request = new ApiTestCaseRequest();
|
||||
request.setIds(nodeIds);
|
||||
request.setDeleteUserId(SessionUtils.getUserId());
|
||||
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();
|
||||
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);
|
||||
return apiModuleMapper.deleteByExample(apiDefinitionNodeExample);
|
||||
ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample();
|
||||
apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds);
|
||||
return apiModuleMapper.deleteByExample(apiDefinitionNodeExample);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void batchUpdateApiDefinition(List<ApiDefinitionResult> apiModule) {
|
||||
|
|
|
@ -104,4 +104,6 @@ public interface ExtApiDefinitionMapper {
|
|||
int countById(String id);
|
||||
|
||||
List<ApiDefinition> selectEffectiveIdByProjectIdAndHaveNotCase(String projectId);
|
||||
|
||||
int deleteApiToGc(ApiDefinitionRequest request);
|
||||
}
|
||||
|
|
|
@ -87,6 +87,21 @@
|
|||
<sql id="Blob_Column_List">
|
||||
request
|
||||
</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 t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
||||
|
|
|
@ -86,4 +86,6 @@ public interface ExtApiTestCaseMapper {
|
|||
int countById(String resourceID);
|
||||
|
||||
List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId);
|
||||
|
||||
int deleteCaseToGc(ApiTestCaseRequest request);
|
||||
}
|
||||
|
|
|
@ -870,6 +870,18 @@
|
|||
</foreach>
|
||||
</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 api_test_case
|
||||
set status = original_status
|
||||
|
|
Loading…
Reference in New Issue