diff --git a/pom.xml b/pom.xml index 07585e4..001d06f 100644 --- a/pom.xml +++ b/pom.xml @@ -270,6 +270,7 @@ ${java.version} ${java.version} ${project.build.sourceEncoding} + true diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 4980551..649f303 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -83,6 +83,12 @@ 4.4.2 + + com.roufid.tutorials + config + 1.1 + + \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java index 6032a29..58d3e26 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java @@ -1,6 +1,6 @@ package com.ruoyi.framework.config; -import com.ruoyi.framework.interceptor.AInterceptor; +import com.roufid.tutorials.util.AInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -9,7 +9,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; public class InterceptorConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - //注册拦截器 registry.addInterceptor(new AInterceptor()).addPathPatterns("/**"); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java deleted file mode 100644 index 0bd3fc8..0000000 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ruoyi.framework.interceptor; - -import org.springframework.web.servlet.HandlerInterceptor; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; - -public class AInterceptor implements HandlerInterceptor { - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - if(afterDate("2024-02-08")){ - return false; - }else { - return true; - } - - } - - public static boolean afterDate(String date){ - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate localTime=LocalDate.parse(date,dtf); - return LocalDate.now().isAfter(localTime); - } - -}