From e74346c705e6acb73571d23c7c2277f898c5a795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=98=B1=E6=B6=B5?= Date: Tue, 11 Feb 2025 18:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/controller/TestApiController.java | 18 +- .../controller/TestApiGroupController.java | 3 +- .../com/test/test/domain/TestApiGroup.java | 4 + .../com/test/test/domain/dto/SwaggerInfo.java | 4 + .../test/service/ITestApiGroupService.java | 2 +- .../test/test/service/ITestApiService.java | 8 + .../service/impl/TestApiGroupServiceImpl.java | 5 +- .../test/service/impl/TestApiServiceImpl.java | 9 + .../mapper/test/TestApiGroupMapper.xml | 10 +- test-ui/src/assets/styles/index.scss | 1 - test-ui/src/views/test/api/index.vue | 247 ++++++++++++------ 11 files changed, 215 insertions(+), 96 deletions(-) create mode 100644 test-test/src/main/java/com/test/test/domain/dto/SwaggerInfo.java diff --git a/test-test/src/main/java/com/test/test/controller/TestApiController.java b/test-test/src/main/java/com/test/test/controller/TestApiController.java index b5c5f2b..93ef420 100644 --- a/test-test/src/main/java/com/test/test/controller/TestApiController.java +++ b/test-test/src/main/java/com/test/test/controller/TestApiController.java @@ -6,12 +6,7 @@ import com.test.test.domain.qo.IDQO; import com.test.test.domain.qo.TestApiListQO; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.test.common.annotation.Log; import com.test.common.core.controller.BaseController; import com.test.common.core.domain.AjaxResult; @@ -19,6 +14,7 @@ import com.test.common.enums.BusinessType; import com.test.test.domain.TestApi; import com.test.test.service.ITestApiService; import com.test.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 接口Controller @@ -58,6 +54,14 @@ public class TestApiController extends BaseController { return toAjax(testApiService.insertTestApi(testApi)); } + /** + * 导入Swagger接口 + */ + @Log(title = "接口", businessType = BusinessType.INSERT) + @PostMapping("/import/swagger") + public AjaxResult importSwagger(@RequestParam(value = "url") String url) throws Exception { + return toAjax(testApiService.importSwaggerApi(url)); + } /** * 修改接口 */ @@ -75,4 +79,6 @@ public class TestApiController extends BaseController { public AjaxResult remove(@RequestBody IDQO qo) { return toAjax(testApiService.deleteTestApiById(qo.getId())); } + + } diff --git a/test-test/src/main/java/com/test/test/controller/TestApiGroupController.java b/test-test/src/main/java/com/test/test/controller/TestApiGroupController.java index 95d20b8..5944bca 100644 --- a/test-test/src/main/java/com/test/test/controller/TestApiGroupController.java +++ b/test-test/src/main/java/com/test/test/controller/TestApiGroupController.java @@ -6,7 +6,6 @@ import com.test.test.domain.qo.IDQO; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -43,7 +42,7 @@ public class TestApiGroupController extends BaseController { @Log(title = "接口节点", businessType = BusinessType.INSERT) @PostMapping("/add") public AjaxResult add(@RequestBody TestApiGroup testApiGroup) { - return toAjax(testApiGroupService.insertTestApiGroup(testApiGroup)); + return success(testApiGroupService.insertTestApiGroup(testApiGroup)); } /** diff --git a/test-test/src/main/java/com/test/test/domain/TestApiGroup.java b/test-test/src/main/java/com/test/test/domain/TestApiGroup.java index 1101954..e93f29b 100644 --- a/test-test/src/main/java/com/test/test/domain/TestApiGroup.java +++ b/test-test/src/main/java/com/test/test/domain/TestApiGroup.java @@ -19,6 +19,10 @@ public class TestApiGroup extends BaseEntity /** 节点id */ private Long id; + /** 父节点id */ + @Excel(name = "父节点id") + private Long parentId; + /** 节点名称 */ @Excel(name = "节点名称") private String name; diff --git a/test-test/src/main/java/com/test/test/domain/dto/SwaggerInfo.java b/test-test/src/main/java/com/test/test/domain/dto/SwaggerInfo.java new file mode 100644 index 0000000..9afe569 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/dto/SwaggerInfo.java @@ -0,0 +1,4 @@ +package com.test.test.domain.dto; + +public class SwaggerInfo { +} diff --git a/test-test/src/main/java/com/test/test/service/ITestApiGroupService.java b/test-test/src/main/java/com/test/test/service/ITestApiGroupService.java index dbd5c08..13977e2 100644 --- a/test-test/src/main/java/com/test/test/service/ITestApiGroupService.java +++ b/test-test/src/main/java/com/test/test/service/ITestApiGroupService.java @@ -24,7 +24,7 @@ public interface ITestApiGroupService { * @param testApiGroup 接口节点 * @return 结果 */ - public int insertTestApiGroup(TestApiGroup testApiGroup); + public TestApiGroup insertTestApiGroup(TestApiGroup testApiGroup); /** * 修改接口节点 diff --git a/test-test/src/main/java/com/test/test/service/ITestApiService.java b/test-test/src/main/java/com/test/test/service/ITestApiService.java index 2d302d8..87a2d52 100644 --- a/test-test/src/main/java/com/test/test/service/ITestApiService.java +++ b/test-test/src/main/java/com/test/test/service/ITestApiService.java @@ -35,6 +35,14 @@ public interface ITestApiService { */ public int insertTestApi(TestApi testApi); + /** + * 导入Swagger接口 + * + * @param url Swagger文档链接 + * @return 结果 + */ + int importSwaggerApi(String url); + /** * 修改接口 * diff --git a/test-test/src/main/java/com/test/test/service/impl/TestApiGroupServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestApiGroupServiceImpl.java index 04ad896..a2bd235 100644 --- a/test-test/src/main/java/com/test/test/service/impl/TestApiGroupServiceImpl.java +++ b/test-test/src/main/java/com/test/test/service/impl/TestApiGroupServiceImpl.java @@ -38,10 +38,11 @@ public class TestApiGroupServiceImpl implements ITestApiGroupService * @return 结果 */ @Override - public int insertTestApiGroup(TestApiGroup testApiGroup) + public TestApiGroup insertTestApiGroup(TestApiGroup testApiGroup) { testApiGroup.setCreateTime(DateUtils.getNowDate()); - return testApiGroupMapper.insertTestApiGroup(testApiGroup); + testApiGroupMapper.insertTestApiGroup(testApiGroup); + return testApiGroup; } /** diff --git a/test-test/src/main/java/com/test/test/service/impl/TestApiServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestApiServiceImpl.java index 69310d7..3ed7868 100644 --- a/test-test/src/main/java/com/test/test/service/impl/TestApiServiceImpl.java +++ b/test-test/src/main/java/com/test/test/service/impl/TestApiServiceImpl.java @@ -2,7 +2,10 @@ package com.test.test.service.impl; import java.util.List; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.test.common.utils.DateUtils; +import com.test.common.utils.http.HttpUtils; import com.test.test.domain.qo.TestApiListQO; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; @@ -54,6 +57,12 @@ public class TestApiServiceImpl implements ITestApiService { return testApiMapper.insertTestApi(testApi); } + @Override + public int importSwaggerApi(String url) { + JSONObject json = JSONObject.parse(HttpUtils.sendGet(url)); + return 0; + } + /** * 修改接口 * diff --git a/test-test/src/main/resources/mapper/test/TestApiGroupMapper.xml b/test-test/src/main/resources/mapper/test/TestApiGroupMapper.xml index b8a1479..aff38e2 100644 --- a/test-test/src/main/resources/mapper/test/TestApiGroupMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestApiGroupMapper.xml @@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -15,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, name, del_flag, create_by, create_time, update_by, update_time from test_api_group + select id, parent_id, name, del_flag, create_by, create_time, update_by, update_time from test_api_group