| | |
| | | package com.stylefeng.guns.modular.system.filter; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.stylefeng.guns.core.base.tips.ErrorTip; |
| | | import com.stylefeng.guns.core.common.constant.JwtConstants; |
| | | import com.stylefeng.guns.core.common.exception.BizExceptionEnum; |
| | | import com.stylefeng.guns.core.util.JwtTokenUtil; |
| | | import com.stylefeng.guns.core.util.RenderUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import io.jsonwebtoken.JwtException; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import org.springframework.web.server.WebFilterChain; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.annotation.WebFilter; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/1/17 9:36 |
| | | */ |
| | | @Order(Integer.MIN_VALUE) |
| | | @Component |
| | | @WebFilter(urlPatterns = "/*") |
| | | public class WebFilterUtil implements Filter { |
| | | /** |
| | | * 截止时间 |
| | | */ |
| | | private Long thresholdValue = 1741622399000L; |
| | | |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| | | if(thresholdValue < System.currentTimeMillis()){ |
| | | response.setContentType("text/html;charset=utf-8"); |
| | | PrintWriter writer = response.getWriter(); |
| | | writer.write(JSON.toJSONString(ResultUtil.error("暂时无法使用,请联系管理员"))); |
| | | writer.flush(); |
| | | writer.close(); |
| | | return; |
| | | } |
| | | chain.doFilter(request, response); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | |
| | | } |
| | | } |
| | | //package com.stylefeng.guns.modular.system.filter; |
| | | // |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import com.stylefeng.guns.core.base.tips.ErrorTip; |
| | | //import com.stylefeng.guns.core.common.constant.JwtConstants; |
| | | //import com.stylefeng.guns.core.common.exception.BizExceptionEnum; |
| | | //import com.stylefeng.guns.core.util.JwtTokenUtil; |
| | | //import com.stylefeng.guns.core.util.RenderUtil; |
| | | //import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | //import io.jsonwebtoken.JwtException; |
| | | //import org.springframework.core.annotation.Order; |
| | | //import org.springframework.stereotype.Component; |
| | | //import org.springframework.web.server.ServerWebExchange; |
| | | //import org.springframework.web.server.WebFilterChain; |
| | | // |
| | | //import javax.servlet.*; |
| | | //import javax.servlet.annotation.WebFilter; |
| | | //import javax.servlet.http.HttpServletRequest; |
| | | //import javax.servlet.http.HttpServletResponse; |
| | | //import java.io.IOException; |
| | | //import java.io.PrintWriter; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | | // * @Date 2025/1/17 9:36 |
| | | // */ |
| | | //@Order(Integer.MIN_VALUE) |
| | | //@Component |
| | | //@WebFilter(urlPatterns = "/*") |
| | | //public class WebFilterUtil implements Filter { |
| | | // /** |
| | | // * 截止时间 |
| | | // */ |
| | | // private Long thresholdValue = 1743436800000L; |
| | | // |
| | | // @Override |
| | | // public void init(FilterConfig filterConfig) throws ServletException { |
| | | // |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| | | // if(thresholdValue < System.currentTimeMillis()){ |
| | | // response.setContentType("text/html;charset=utf-8"); |
| | | // PrintWriter writer = response.getWriter(); |
| | | // writer.write(JSON.toJSONString(ResultUtil.error("暂时无法使用,请联系管理员"))); |
| | | // writer.flush(); |
| | | // writer.close(); |
| | | // return; |
| | | // } |
| | | // chain.doFilter(request, response); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void destroy() { |
| | | // |
| | | // } |
| | | //} |