|
|
@ -5,9 +5,11 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.inscloudtech.common.config.ProjectConfig; |
|
|
|
import com.inscloudtech.common.constant.Constants; |
|
|
|
import com.inscloudtech.common.core.domain.R; |
|
|
|
import com.inscloudtech.common.utils.spring.SpringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.servlet.*; |
|
|
@ -26,20 +28,24 @@ import java.util.stream.Collectors; |
|
|
|
@Component |
|
|
|
public class ExpirationDateFilter implements Filter { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
ProjectConfig projectConfig; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void init(FilterConfig filterConfig) throws ServletException { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private static DateTime START_DAY = DateUtil.parse("2024-07-01"); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
|
|
|
throws IOException, ServletException { |
|
|
|
response.setCharacterEncoding(Constants.UTF8); |
|
|
|
response.setContentType("application/json;charset=UTF-8"); |
|
|
|
|
|
|
|
int compare = DateUtil.compare(new Date(), START_DAY); |
|
|
|
DateTime startDate = DateUtil.parse(projectConfig.getAuthStartDate()); |
|
|
|
int compare = DateUtil.compare(new Date(), startDate); |
|
|
|
|
|
|
|
if(compare < 0){ |
|
|
|
PrintWriter printWriter = response.getWriter(); |
|
|
@ -47,7 +53,7 @@ public class ExpirationDateFilter implements Filter { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
long betweenDay = DateUtil.betweenDay(new Date(), START_DAY, true); |
|
|
|
long betweenDay = DateUtil.betweenDay(new Date(), startDate, true); |
|
|
|
if(betweenDay > 90){ |
|
|
|
PrintWriter printWriter = response.getWriter(); |
|
|
|
printWriter.write(JSONUtil.toJsonStr(R.fail("授权超过有效期"))); |
|
|
@ -60,7 +66,7 @@ public class ExpirationDateFilter implements Filter { |
|
|
|
String methodName = "checkFirstOperInfo"; |
|
|
|
List<Method> methodList = Arrays.stream(serviceClass.getMethods()).filter(method -> method.getName().equals(methodName)).collect(Collectors.toList()); |
|
|
|
Method method = methodList.get(0);// |
|
|
|
Object[] args = new Object[]{response, START_DAY}; |
|
|
|
Object[] args = new Object[]{response, startDate}; |
|
|
|
try { |
|
|
|
method.invoke(serviceObj, args); |
|
|
|
}catch (Exception e){ |
|
|
|