正在显示
5 个修改的文件
包含
16 行增加
和
11 行删除
| @@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
| 43 | <dependency> | 43 | <dependency> |
| 44 | <groupId>org.springframework.boot</groupId> | 44 | <groupId>org.springframework.boot</groupId> |
| 45 | <artifactId>spring-boot-dependencies</artifactId> | 45 | <artifactId>spring-boot-dependencies</artifactId> |
| 46 | - <version>2.2.13.RELEASE</version> | 46 | + <version>2.5.5</version> |
| 47 | <type>pom</type> | 47 | <type>pom</type> |
| 48 | <scope>import</scope> | 48 | <scope>import</scope> |
| 49 | </dependency> | 49 | </dependency> |
| 1 | package com.ruoyi.web.controller.system; | 1 | package com.ruoyi.web.controller.system; |
| 2 | 2 | ||
| 3 | import org.springframework.beans.factory.annotation.Autowired; | 3 | import org.springframework.beans.factory.annotation.Autowired; |
| 4 | -import org.springframework.util.StringUtils; | ||
| 5 | import org.springframework.web.bind.annotation.PostMapping; | 4 | import org.springframework.web.bind.annotation.PostMapping; |
| 6 | import org.springframework.web.bind.annotation.RequestBody; | 5 | import org.springframework.web.bind.annotation.RequestBody; |
| 7 | import org.springframework.web.bind.annotation.RestController; | 6 | import org.springframework.web.bind.annotation.RestController; |
| 8 | import com.ruoyi.common.core.controller.BaseController; | 7 | import com.ruoyi.common.core.controller.BaseController; |
| 9 | import com.ruoyi.common.core.domain.AjaxResult; | 8 | import com.ruoyi.common.core.domain.AjaxResult; |
| 10 | import com.ruoyi.common.core.domain.model.RegisterBody; | 9 | import com.ruoyi.common.core.domain.model.RegisterBody; |
| 10 | +import com.ruoyi.common.utils.StringUtils; | ||
| 11 | import com.ruoyi.framework.web.service.SysRegisterService; | 11 | import com.ruoyi.framework.web.service.SysRegisterService; |
| 12 | import com.ruoyi.system.service.ISysConfigService; | 12 | import com.ruoyi.system.service.ISysConfigService; |
| 13 | 13 |
| @@ -28,10 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer | @@ -28,10 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer | ||
| 28 | public void addResourceHandlers(ResourceHandlerRegistry registry) | 28 | public void addResourceHandlers(ResourceHandlerRegistry registry) |
| 29 | { | 29 | { |
| 30 | /** 本地文件上传路径 */ | 30 | /** 本地文件上传路径 */ |
| 31 | - registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); | 31 | + registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**") |
| 32 | + .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); | ||
| 32 | 33 | ||
| 33 | /** swagger配置 */ | 34 | /** swagger配置 */ |
| 34 | - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); | 35 | + registry.addResourceHandler("/swagger-ui/**") |
| 36 | + .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); | ||
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | /** | 39 | /** |
| @@ -49,17 +51,20 @@ public class ResourcesConfig implements WebMvcConfigurer | @@ -49,17 +51,20 @@ public class ResourcesConfig implements WebMvcConfigurer | ||
| 49 | @Bean | 51 | @Bean |
| 50 | public CorsFilter corsFilter() | 52 | public CorsFilter corsFilter() |
| 51 | { | 53 | { |
| 52 | - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
| 53 | CorsConfiguration config = new CorsConfiguration(); | 54 | CorsConfiguration config = new CorsConfiguration(); |
| 54 | config.setAllowCredentials(true); | 55 | config.setAllowCredentials(true); |
| 55 | // 设置访问源地址 | 56 | // 设置访问源地址 |
| 56 | - config.addAllowedOrigin("*"); | 57 | + config.addAllowedOriginPattern("*"); |
| 57 | // 设置访问源请求头 | 58 | // 设置访问源请求头 |
| 58 | config.addAllowedHeader("*"); | 59 | config.addAllowedHeader("*"); |
| 59 | // 设置访问源请求方法 | 60 | // 设置访问源请求方法 |
| 60 | config.addAllowedMethod("*"); | 61 | config.addAllowedMethod("*"); |
| 61 | - // 对接口配置跨域设置 | 62 | + // 有效期 1800秒 |
| 63 | + config.setMaxAge(1800L); | ||
| 64 | + // 添加映射路径,拦截一切请求 | ||
| 65 | + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
| 62 | source.registerCorsConfiguration("/**", config); | 66 | source.registerCorsConfiguration("/**", config); |
| 67 | + // 返回新的CorsFilter | ||
| 63 | return new CorsFilter(source); | 68 | return new CorsFilter(source); |
| 64 | } | 69 | } |
| 65 | } | 70 | } |
| @@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletRequest; | @@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletRequest; | ||
| 5 | import javax.servlet.http.HttpServletResponse; | 5 | import javax.servlet.http.HttpServletResponse; |
| 6 | import org.springframework.stereotype.Component; | 6 | import org.springframework.stereotype.Component; |
| 7 | import org.springframework.web.method.HandlerMethod; | 7 | import org.springframework.web.method.HandlerMethod; |
| 8 | -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | 8 | +import org.springframework.web.servlet.HandlerInterceptor; |
| 9 | import com.alibaba.fastjson.JSONObject; | 9 | import com.alibaba.fastjson.JSONObject; |
| 10 | import com.ruoyi.common.annotation.RepeatSubmit; | 10 | import com.ruoyi.common.annotation.RepeatSubmit; |
| 11 | import com.ruoyi.common.core.domain.AjaxResult; | 11 | import com.ruoyi.common.core.domain.AjaxResult; |
| @@ -17,7 +17,7 @@ import com.ruoyi.common.utils.ServletUtils; | @@ -17,7 +17,7 @@ import com.ruoyi.common.utils.ServletUtils; | ||
| 17 | * @author ruoyi | 17 | * @author ruoyi |
| 18 | */ | 18 | */ |
| 19 | @Component | 19 | @Component |
| 20 | -public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter | 20 | +public abstract class RepeatSubmitInterceptor implements HandlerInterceptor |
| 21 | { | 21 | { |
| 22 | @Override | 22 | @Override |
| 23 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception | 23 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception |
| @@ -40,7 +40,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter | @@ -40,7 +40,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter | ||
| 40 | } | 40 | } |
| 41 | else | 41 | else |
| 42 | { | 42 | { |
| 43 | - return super.preHandle(request, response, handler); | 43 | + return true; |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 |
| @@ -2,7 +2,6 @@ package com.ruoyi.framework.web.service; | @@ -2,7 +2,6 @@ package com.ruoyi.framework.web.service; | ||
| 2 | 2 | ||
| 3 | import org.springframework.beans.factory.annotation.Autowired; | 3 | import org.springframework.beans.factory.annotation.Autowired; |
| 4 | import org.springframework.stereotype.Component; | 4 | import org.springframework.stereotype.Component; |
| 5 | -import org.springframework.util.StringUtils; | ||
| 6 | import com.ruoyi.common.constant.Constants; | 5 | import com.ruoyi.common.constant.Constants; |
| 7 | import com.ruoyi.common.constant.UserConstants; | 6 | import com.ruoyi.common.constant.UserConstants; |
| 8 | import com.ruoyi.common.core.domain.entity.SysUser; | 7 | import com.ruoyi.common.core.domain.entity.SysUser; |
| @@ -12,6 +11,7 @@ import com.ruoyi.common.exception.user.CaptchaException; | @@ -12,6 +11,7 @@ import com.ruoyi.common.exception.user.CaptchaException; | ||
| 12 | import com.ruoyi.common.exception.user.CaptchaExpireException; | 11 | import com.ruoyi.common.exception.user.CaptchaExpireException; |
| 13 | import com.ruoyi.common.utils.MessageUtils; | 12 | import com.ruoyi.common.utils.MessageUtils; |
| 14 | import com.ruoyi.common.utils.SecurityUtils; | 13 | import com.ruoyi.common.utils.SecurityUtils; |
| 14 | +import com.ruoyi.common.utils.StringUtils; | ||
| 15 | import com.ruoyi.framework.manager.AsyncManager; | 15 | import com.ruoyi.framework.manager.AsyncManager; |
| 16 | import com.ruoyi.framework.manager.factory.AsyncFactory; | 16 | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| 17 | import com.ruoyi.system.service.ISysConfigService; | 17 | import com.ruoyi.system.service.ISysConfigService; |
-
请 注册 或 登录 后发表评论