From 3bff069867e5c2d81ec97a918936c4c3b115671b Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 17 Feb 2023 16:36:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=96=87=E4=BB=B6=E6=97=B6case=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6=E5=85=B3=E7=B3=BB=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1023255 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001023255 --- .../service/definition/ApiTestCaseService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index cd34f38a94..a8cf4d6ca1 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -738,7 +738,7 @@ public class ApiTestCaseService { JSONObject element = JSONUtil.parseObject(apiTestCase.getRequest()); ElementUtil.dataFormatting(element); MsHTTPSamplerProxy req = JSON.parseObject(element.toString(), MsHTTPSamplerProxy.class); - if (element != null && StringUtils.isNotEmpty(element.optString(ElementConstants.HASH_TREE))) { + if (StringUtils.isNotEmpty(element.optString(ElementConstants.HASH_TREE))) { req.setHashTree(JSONUtil.readValue(element.optString(ElementConstants.HASH_TREE))); } if (StringUtils.isNotBlank(method)) { @@ -752,11 +752,17 @@ public class ApiTestCaseService { ApiCaseBatchSyncService apiCaseBatchSyncService = CommonBeanFactory.getBean(ApiCaseBatchSyncService.class); if (apiCaseBatchSyncService != null) { apiCaseBatchSyncService.oneClickSyncCase(apiUpdateRule, test, apiTestCase); + // 存储附件关系 + JSONObject requestCase = JSONUtil.parseObject(apiTestCase.getRequest()); + ElementUtil.dataFormatting(requestCase); + MsHTTPSamplerProxy caseProxy = JSON.parseObject(requestCase.toString(), MsHTTPSamplerProxy.class); + extFileAssociationService.saveApi(apiTestCase.getId(), caseProxy, FileAssociationTypeEnums.CASE.name()); } batchMapper.updateByPrimaryKeySelective(apiTestCase); + }); sqlSession.flushStatements(); - if (sqlSession != null && sqlSessionFactory != null) { + if (sqlSessionFactory != null) { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } }