Browse Source

feat: 创建项目

DingXiaoYu 2 years ago
parent
commit
5026dfa4c4

+ 9 - 0
src/main/java/com/seecoder/BlueWhale/Configure/MyWebMvcConfig.java

@@ -2,6 +2,7 @@ package com.seecoder.BlueWhale.Configure;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 @Configuration
@@ -17,4 +18,12 @@ public class MyWebMvcConfig implements WebMvcConfigurer {
                 .excludePathPatterns("/api/user/login")
                 .order(1);
     }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+                .allowedOrigins("*")
+                .allowedMethods("*")
+                .allowedHeaders("*");
+    }
 }

+ 0 - 4
src/main/java/com/seecoder/BlueWhale/Controller/UserController.java

@@ -22,8 +22,4 @@ public class UserController {
         return ResultVO.buildSuccess(userService.register(userVO));
     }
 
-    @GetMapping("/test")
-    public String a(){
-        return securityUtil.getCurrentUser().getRole().toString();
-    }
 }

+ 2 - 2
src/main/java/com/seecoder/BlueWhale/Exception/BlueWhaleException.java

@@ -6,10 +6,10 @@ public class BlueWhaleException extends RuntimeException{
         super(message);
     }
     public static BlueWhaleException phoneAlreadyExists(){
-        return new BlueWhaleException("手机号已经存在!");
+        return new BlueWhaleException("手机号已经存在!");
     }
 
     public static BlueWhaleException notLogin(){
-        return new BlueWhaleException("未登录");
+        return new BlueWhaleException("未登录!");
     }
 }