diff --git a/backend/src/main/java/io/metersphere/api/controller/ShareInfoController.java b/backend/src/main/java/io/metersphere/api/controller/ShareInfoController.java index a9e5a831e7..0cc9b81a5f 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ShareInfoController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ShareInfoController.java @@ -9,9 +9,11 @@ import io.metersphere.api.service.ShareInfoService; import io.metersphere.base.domain.ApiDefinitionWithBLOBs; import io.metersphere.base.domain.ReportStatisticsWithBLOBs; import io.metersphere.base.domain.ShareInfo; +import io.metersphere.base.domain.User; import io.metersphere.commons.utils.LogUtil; import io.metersphere.reportstatistics.dto.ReportStatisticsSaveRequest; import io.metersphere.reportstatistics.service.ReportStatisticsService; +import io.metersphere.service.UserService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -34,6 +36,8 @@ public class ShareInfoController { ApiDefinitionService apiDefinitionService; @Resource ReportStatisticsService reportStatisticsService; + @Resource + UserService userService; @PostMapping("/selectApiSimpleInfo") public List list(@RequestBody ApiDocumentRequest request) { @@ -53,6 +57,7 @@ public class ShareInfoController { //要根据ids的顺序进行返回排序 List apiModels = apiDefinitionService.getBLOBs(request.getApiIdList()); Map apiModelMaps = apiModels.stream().collect(Collectors.toMap(ApiDefinitionWithBLOBs::getId, a -> a, (k1, k2) -> k1)); + Map userIdMap = userService.queryName(); for (String id : request.getApiIdList()) { ApiDefinitionWithBLOBs model = apiModelMaps.get(id); if (model == null) { @@ -60,7 +65,7 @@ public class ShareInfoController { model.setId(id); model.setName(id); } - ApiDocumentInfoDTO returnDTO = shareInfoService.conversionModelToDTO(model); + ApiDocumentInfoDTO returnDTO = shareInfoService.conversionModelToDTO(model,userIdMap); returnList.add(returnDTO); } } @@ -72,7 +77,8 @@ public class ShareInfoController { ApiDefinitionWithBLOBs apiModel = apiDefinitionService.getBLOBs(id); ApiDocumentInfoDTO returnDTO = new ApiDocumentInfoDTO(); try { - returnDTO = shareInfoService.conversionModelToDTO(apiModel); + Map userIdMap = userService.queryName(); + returnDTO = shareInfoService.conversionModelToDTO(apiModel,userIdMap); } catch (Exception e) { LogUtil.error(e); } diff --git a/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java index 1f3566702b..bd3f1203b0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java @@ -18,8 +18,15 @@ public class ApiDocumentInfoDTO { private String name; private String status; + private String tags; + private String modules; + private String createUser; + private String responsibler; + private String desc; + private String requestHead; private String urlParams; + private String restParams; private String requestBodyParamType; private String requestBodyFormData; private String requestBodyStrutureData; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index f7eb907fb0..6bfd2681d7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -563,4 +563,8 @@ public class ApiModuleService extends NodeTreeService { example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andStatusEqualTo("Trash"); return extApiDefinitionMapper.countByExample(example); } + + public String getModuleNameById(String moduleId) { + return extApiModuleMapper.getNameById(moduleId); + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java index 1e4fee821c..4c18a644df 100644 --- a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java +++ b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java @@ -110,7 +110,7 @@ public class ShareInfoService { return true; } - public ApiDocumentInfoDTO conversionModelToDTO(ApiDefinitionWithBLOBs apiModel) { + public ApiDocumentInfoDTO conversionModelToDTO(ApiDefinitionWithBLOBs apiModel, Map userIdMap) { ApiDocumentInfoDTO apiInfoDTO = new ApiDocumentInfoDTO(); JSONArray previewJsonArray = new JSONArray(); if (apiModel != null) { @@ -120,6 +120,23 @@ public class ShareInfoService { apiInfoDTO.setUri(apiModel.getPath()); apiInfoDTO.setStatus(apiModel.getStatus()); + if(StringUtils.isNotEmpty(apiModel.getTags())){ + JSONArray tagsArr = JSONArray.parseArray(apiModel.getTags()); + List tagList = new ArrayList<>(); + for(int i = 0;i < tagsArr.size();i ++){ + tagList.add(tagsArr.getString(i)); + } + if(!tagList.isEmpty()){ + apiInfoDTO.setTags(StringUtils.join(tagList,",")); + } + } + + apiInfoDTO.setResponsibler(userIdMap.get(apiModel.getUserId()) == null? apiModel.getUserId() : userIdMap.get(apiModel.getUserId()).getName()); + apiInfoDTO.setCreateUser(userIdMap.get(apiModel.getCreateUser()) == null? apiModel.getCreateUser() : userIdMap.get(apiModel.getCreateUser()).getName()); + apiInfoDTO.setDesc(apiModel.getDescription()); + ApiModuleService apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class); + apiInfoDTO.setModules(apiModuleService.getModuleNameById(apiModel.getModuleId())); + if (apiModel.getRequest() != null) { JSONObject requestObj = this.genJSONObject(apiModel.getRequest()); if (requestObj != null) { @@ -150,6 +167,8 @@ public class ShareInfoService { } catch (Exception e) { } } + //rest参数设置 + JSONArray restParamArr = new JSONArray(); if (requestObj.containsKey("rest")) { try { //urlParam -- rest赋值 @@ -157,13 +176,14 @@ public class ShareInfoService { for (int index = 0; index < headArr.size(); index++) { JSONObject headObj = headArr.getJSONObject(index); if (headObj.containsKey("name")) { - urlParamArr.add(headObj); + restParamArr.add(headObj); } } } catch (Exception e) { } } apiInfoDTO.setUrlParams(urlParamArr.toJSONString()); + apiInfoDTO.setRestParams(restParamArr.toJSONString()); //请求体参数类型 if (requestObj.containsKey("body")) { try { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.java index 20ef2f4557..6fd85f532a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.java @@ -12,4 +12,6 @@ public interface ExtApiModuleMapper { List getNodeTreeByProjectId(@Param("projectId") String projectId, @Param("protocol") String protocol); void updatePos(String id, Double pos); + + String getNameById(String moduleId); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.xml index 8e0937ac1f..65dd9745c0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiModuleMapper.xml @@ -21,6 +21,10 @@ and api_module.protocol = #{protocol} order by api_module.pos asc + update api_module set pos = #{pos} where id = #{id} diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index da55384c0d..de41ed2c22 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -3,6 +3,7 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.esotericsoftware.minlog.Log; import io.metersphere.api.dto.automation.TestPlanFailureApiDTO; import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO; import io.metersphere.api.service.ShareInfoService; @@ -53,8 +54,6 @@ import java.util.stream.Collectors; @Transactional(rollbackFor = Exception.class) public class TestPlanReportService { - Logger testPlanLog = LoggerFactory.getLogger("testPlanExecuteLog"); - @Resource TestPlanReportMapper testPlanReportMapper; @Resource @@ -74,7 +73,6 @@ public class TestPlanReportService { @Lazy @Resource TestPlanService testPlanService; - @Lazy @Resource TestPlanReportContentMapper testPlanReportContentMapper; @Resource @@ -854,6 +852,7 @@ public class TestPlanReportService { } public TestPlanSimpleReportDTO getReport(String reportId) { + Log.info("----> SELECT REPORT: "+ reportId); TestPlanReportContentExample example = new TestPlanReportContentExample(); example.createCriteria().andTestPlanReportIdEqualTo(reportId); List testPlanReportContents = testPlanReportContentMapper.selectByExampleWithBLOBs(example); @@ -865,8 +864,11 @@ public class TestPlanReportService { return null; } if (this.isDynamicallyGenerateReports(testPlanReportContent)) { + Log.info("----> GenerateReports: "+ JSONObject.toJSONString(testPlanReportContent)); testPlanReportContent = this.dynamicallyGenerateReports(testPlanReportContent); + Log.info("----> GenerateReports OVER: "+ JSONObject.toJSONString(testPlanReportContent)); } + Log.info("----> parse return object: "+ JSONObject.toJSONString(testPlanReportContent)); TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO(); BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent); if (StringUtils.isNotBlank(testPlanReportContent.getFunctionResult())) { @@ -914,6 +916,7 @@ public class TestPlanReportService { testPlanReportDTO.setId(reportId); TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId()); testPlanReportDTO.setName(testPlanReport.getName()); + Log.info("----> SELECT REPORT OVER "); return testPlanReportDTO; } diff --git a/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue b/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue new file mode 100644 index 0000000000..ee1db31bf7 --- /dev/null +++ b/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/frontend/src/business/components/api/definition/components/document/components/ApiInformation.vue b/frontend/src/business/components/api/definition/components/document/components/ApiInformation.vue index d1d73d6149..4cc5eaf1cf 100644 --- a/frontend/src/business/components/api/definition/components/document/components/ApiInformation.vue +++ b/frontend/src/business/components/api/definition/components/document/components/ApiInformation.vue @@ -1,11 +1,11 @@ + + diff --git a/frontend/src/business/components/api/definition/components/document/components/ApiResponseInfo.vue b/frontend/src/business/components/api/definition/components/document/components/ApiResponseInfo.vue new file mode 100644 index 0000000000..92d7baa889 --- /dev/null +++ b/frontend/src/business/components/api/definition/components/document/components/ApiResponseInfo.vue @@ -0,0 +1,154 @@ + + + + + + + diff --git a/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue b/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue index 298e604eff..7d4e3eb120 100644 --- a/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue +++ b/frontend/src/business/components/common/json-schema/JsonSchemaEditor.vue @@ -2,11 +2,12 @@
- + {{ this.$t('commons.import') }} -
+
-
{{this.preview}}
+
{{ this.preview }}
@@ -26,107 +27,109 @@