mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
fix(接口测试): 修复删除接口未删除及联关系表的缺陷
https://github.com/metersphere/metersphere/issues/23097
This commit is contained in:
parent
45737dbed1
commit
bad0eac479
@ -27,6 +27,9 @@ import io.metersphere.notice.sender.NoticeModel;
|
||||
import io.metersphere.notice.service.NoticeSendService;
|
||||
import io.metersphere.service.definition.ApiDefinitionService;
|
||||
import io.metersphere.service.ext.ExtProjectApplicationService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -39,9 +42,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -678,6 +678,21 @@ public class MockConfigService {
|
||||
mockConfigMapper.deleteByExample(configExample);
|
||||
}
|
||||
|
||||
public void deleteMockConfigByApiIds(List<String> apiIds) {
|
||||
MockConfigExample configExample = new MockConfigExample();
|
||||
configExample.createCriteria().andApiIdIn(apiIds);
|
||||
List<MockConfig> mockConfigList = mockConfigMapper.selectByExample(configExample);
|
||||
MockExpectConfigExample example = new MockExpectConfigExample();
|
||||
List<String> mockConfigIds = mockConfigList.stream().map(MockConfig::getId).toList();
|
||||
example.createCriteria().andMockConfigIdIn(mockConfigIds);
|
||||
List<MockExpectConfigWithBLOBs> deleteBlobs = mockExpectConfigMapper.selectByExampleWithBLOBs(example);
|
||||
for (MockExpectConfigWithBLOBs model : deleteBlobs) {
|
||||
this.deleteMockExpectFiles(model);
|
||||
}
|
||||
mockExpectConfigMapper.deleteByExample(example);
|
||||
mockConfigMapper.deleteByExample(configExample);
|
||||
}
|
||||
|
||||
public Map<String, List<MockParamSuggestions>> getApiParamsByApiDefinitionBLOBs(ApiDefinitionWithBLOBs apiModel) {
|
||||
if (apiModel == null) {
|
||||
return new HashMap<>();
|
||||
|
@ -1219,9 +1219,19 @@ public class ApiDefinitionService {
|
||||
example.createCriteria().andRefIdIn(refIds);
|
||||
List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example);
|
||||
List<String> apiIds = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList());
|
||||
//删除Api、ApiCase中resourceID被删除了的执行记录
|
||||
apiTestCaseService.deleteBatchByDefinitionId(apiIds);
|
||||
apiDefinitionMapper.deleteByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(apiIds)) {
|
||||
//删除Api、ApiCase中resourceID被删除了的执行记录
|
||||
apiTestCaseService.deleteBatchByDefinitionId(apiIds);
|
||||
apiDefinitionMapper.deleteByExample(example);
|
||||
// 删除附件关系
|
||||
extFileAssociationService.deleteByResourceIds(apiIds);
|
||||
// 删除自定义字段关联关系
|
||||
customFieldApiService.deleteByResourceIds(apiIds);
|
||||
// 删除关系图
|
||||
relationshipEdgeService.delete(apiIds);
|
||||
mockConfigService.deleteMockConfigByApiIds(apiIds);
|
||||
deleteFollows(apiIds);
|
||||
}
|
||||
}
|
||||
|
||||
public ApiDefinitionExample getBatchExample(ApiBatchRequest request) {
|
||||
|
Loading…
Reference in New Issue
Block a user