Merge branch 'feature/gongfu' into feature/data-permission
This commit is contained in:
commit
1509b20788
|
|
@ -18,6 +18,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@Order(0)
|
||||
|
|
@ -26,28 +27,35 @@ public class AppVersionFilter extends OncePerRequestFilter {
|
|||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 因前端部分接口遗漏App-Version参数,ios打包重新审核需要很久,所以需要排除掉,否则会导致接口无法访问
|
||||
*/
|
||||
private static final Set<String> WHITE_LIST = Set.of("getTicket", "uploadSingleFile", "getInfoById");
|
||||
|
||||
private static final String MIN_SUPPER_VERSION = "1.0.9";
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||
String appPlatform = request.getHeader("App-Platform");
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
if (StrUtil.isBlank(appPlatform)) {
|
||||
log.error("请求头中未找到App-Platform");
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "请更新版本!"));
|
||||
} else {
|
||||
if (appPlatform.startsWith("pc")) {
|
||||
filterChain.doFilter(request, response);
|
||||
if (WHITE_LIST.stream().noneMatch(path -> request.getRequestURI().endsWith(path))) {
|
||||
String appPlatform = request.getHeader("App-Platform");
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
if (StrUtil.isBlank(appPlatform)) {
|
||||
log.error("请求头中未找到App-Platform");
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "请更新版本!"));
|
||||
} else {
|
||||
String appVersion = request.getHeader("App-Version");
|
||||
if (StrUtil.isBlank(appVersion)) {
|
||||
log.error("请求头中未找到App-Version");
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "请更新版本!"));
|
||||
} else if (VersionComparator.INSTANCE.compare(appVersion, MIN_SUPPER_VERSION) < 0) {
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "版本太低,请更新版本!"));
|
||||
} else {
|
||||
if (appPlatform.startsWith("pc")) {
|
||||
filterChain.doFilter(request, response);
|
||||
} else {
|
||||
String appVersion = request.getHeader("App-Version");
|
||||
if (StrUtil.isBlank(appVersion)) {
|
||||
log.error("请求头中未找到App-Version");
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "请更新版本!"));
|
||||
} else if (VersionComparator.INSTANCE.compare(appVersion, MIN_SUPPER_VERSION) < 0) {
|
||||
out(response, ApiResult.error(STATE.ServiceConnectRefused, "版本太低,请更新版本!"));
|
||||
} else {
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue