fix(接口测试): 接口用例附件删除增加校验

This commit is contained in:
fit2-zhao 2022-12-26 10:44:56 +08:00 committed by fit2-zhao
parent 39bd9c1fec
commit 0b14520dac
1 changed files with 6 additions and 2 deletions

View File

@ -347,7 +347,10 @@ public class ApiTestCaseService {
apiTestCaseMapper.deleteByPrimaryKey(testId);
esbApiParamService.deleteByResourceId(testId);
testPlanApiCaseService.deleteByCaseId(testId);
deleteBodyFiles(testId);
ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(testId);
if (apiTestCase != null) {
deleteBodyFiles(apiTestCase.getId());
}
// 删除附件关系
fileAssociationService.deleteByResourceId(testId);
deleteFollows(testId);
@ -388,7 +391,8 @@ public class ApiTestCaseService {
}
public void deleteBodyFiles(String testId) {
File file = new File(BODY_FILE_DIR + "/" + testId);
String path = StringUtils.join(BODY_FILE_DIR, "/", testId);
File file = new File(path);
FileUtil.deleteContents(file);
if (file.exists()) {
file.delete();