From a3fcc1b0f9523801f04cf53c38914a6a3aa8f508 Mon Sep 17 00:00:00 2001
From: zxj <1845124851@qq.com>
Date: Fri, 8 Mar 2024 16:49:43 +0800
Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3=E6=B3=A8?=
=?UTF-8?q?=E8=A7=A3=E5=92=8C=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/jnssd/config/CorsConfig.java | 22 ++++++++++++++
.../com/jnssd/controller/MenuController.java | 21 ++++++++-----
.../com/jnssd/controller/RoleController.java | 19 +++++++-----
.../com/jnssd/controller/UserController.java | 19 +++++++-----
.../src/test/java/com/demo/TestDemo.java | 30 +++++++++++++++++++
.../jnssd/config/SwaggerOpenApiConfig.java | 2 +-
6 files changed, 90 insertions(+), 23 deletions(-)
create mode 100644 spring-boot-springdoc/src/main/java/com/jnssd/config/CorsConfig.java
create mode 100644 spring-boot-springdoc/src/test/java/com/demo/TestDemo.java
diff --git a/spring-boot-springdoc/src/main/java/com/jnssd/config/CorsConfig.java b/spring-boot-springdoc/src/main/java/com/jnssd/config/CorsConfig.java
new file mode 100644
index 0000000..8b0732d
--- /dev/null
+++ b/spring-boot-springdoc/src/main/java/com/jnssd/config/CorsConfig.java
@@ -0,0 +1,22 @@
+package com.jnssd.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * @author zxj
+ * @since 2023-10-20 14:38:00
+ * @apiNote 配置接口跨域请求问题
+ */
+@Configuration
+public class CorsConfig implements WebMvcConfigurer {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**")
+ .allowedOrigins("*")
+ .allowedMethods("GET", "POST", "PUT", "DELETE")
+ .allowedHeaders("*");
+ }
+
+}
diff --git a/spring-boot-springdoc/src/main/java/com/jnssd/controller/MenuController.java b/spring-boot-springdoc/src/main/java/com/jnssd/controller/MenuController.java
index ee9e83e..21a00f7 100644
--- a/spring-boot-springdoc/src/main/java/com/jnssd/controller/MenuController.java
+++ b/spring-boot-springdoc/src/main/java/com/jnssd/controller/MenuController.java
@@ -1,11 +1,10 @@
package com.jnssd.controller;
import com.jnssd.model.Menu;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
@@ -17,6 +16,7 @@ import java.util.Objects;
* @author zxj
* @since 2023-10-12 16:33:23
*/
+@Tag(name = "菜单", description = "菜单")
@RestController
@RequestMapping("/menu")
public class MenuController {
@@ -27,13 +27,15 @@ public class MenuController {
List