package com.stylefeng.guns.modular.system.filter;
|
|
import com.alibaba.fastjson.JSON;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
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 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 = 1737561599000L;
|
|
@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() {
|
|
}
|
}
|