Compare commits

..

4 Commits

Author SHA1 Message Date
曹鹏飞 d0d78d54c6 feat(filter): 更新白名单并优化设备类型查询性能
- 在AppVersionFilter白名单中添加hangUp和exportPdf接口
- 优化DeviceTypeController中的数据库查询逻辑
- 使用Set替代List避免重复数据提高查询效率
- 添加CollectionUtil非空检查增强代码健壮性
- 减少不必要的流操作提升查询性能
2026-01-16 09:21:57 +08:00
曹鹏飞 27d6fe13e8 feat(AppUserMapper): 添加用户类型字段映射
- 在查询结果中新增 userType 字段映射为 type
- 保持现有所有用户信息字段的映射关系不变
- 优化用户申请表的数据查询结构
2026-01-15 15:54:39 +08:00
曹鹏飞 33365d5aa9 fix(filter): 修复应用版本过滤器逻辑
- 添加else分支确保请求正常通过过滤器链
- 防止过滤器在特定条件下阻断正常请求处理流程
2026-01-15 15:29:59 +08:00
曹鹏飞 7cf1dfcf9f fix(filter): 修复App-Version参数缺失导致的接口访问问题
- 添加白名单配置,排除部分遗漏App-Version参数的前端接口
- 对getTicket、uploadSingleFile、getInfoById接口跳过版本校验
- 解决iOS打包重新审核期间的接口兼容性问题
- 保留原有版本校验逻辑,仅对白名单接口进行特殊处理
2026-01-15 15:15:30 +08:00
3 changed files with 32 additions and 18 deletions

View File

@ -30,6 +30,7 @@ import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -58,8 +59,9 @@ public class DeviceTypeController extends ControllerBase {
.eq(GongfuDeviceType::getParentId, 0)
.orderByDesc(GongfuDeviceType::getId)
.page(new Page<>(query.getPage(), query.getPageSize()));
Set<Long> ids = result.getRecords().stream().map(GongfuDeviceType::getId).collect(Collectors.toSet());
List<GongfuDeviceType> children = deviceTypeService.lambdaQuery()
.in(GongfuDeviceType::getParentId, result.getRecords().stream().map(GongfuDeviceType::getId).collect(Collectors.toList()))
.in(CollectionUtil.isNotEmpty(ids), GongfuDeviceType::getParentId, ids)
.list();
return ApiResult.success(convert(query, result, children));
} else {
@ -70,8 +72,9 @@ public class DeviceTypeController extends ControllerBase {
if (CollectionUtil.isEmpty(children)) {
return ApiResult.success(new PageData<>());
}
Set<Long> ids = children.stream().map(GongfuDeviceType::getParentId).collect(Collectors.toSet());
Page<GongfuDeviceType> result = deviceTypeService.lambdaQuery()
.in(GongfuDeviceType::getId, children.stream().map(GongfuDeviceType::getParentId).collect(Collectors.toSet()))
.in(CollectionUtil.isNotEmpty(ids), GongfuDeviceType::getId, ids)
.orderByDesc(GongfuDeviceType::getId)
.page(new Page<>(query.getPage(), query.getPageSize()));
return ApiResult.success(convert(query, result, children));

View File

@ -31,6 +31,7 @@
SELECT u.id,c.agency_company_name AS 'companyName',u.user_name AS 'name',u.user_email AS 'email',u.user_avatar AS 'avatar'
,a.`name` AS 'areaName',0 AS 'userState',u.create_by AS 'createBy',u.create_time AS 'createTime',u.update_by AS 'updateBy'
,u.update_time AS 'updateTime',null AS 'lastLoginTime',null AS 'expireTime',false AS 'isPrimary',0 AS 'state'
,u.user_type as 'type'
FROM app_user_applyfor u
INNER JOIN t_base_customer c ON u.company_id=c.id
INNER JOIN app_area a ON u.area_id=a.id

View File

@ -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,30 +27,39 @@ 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", "hangUp", "exportPdf");
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);
}
}
}
} else {
filterChain.doFilter(request, response);
}
}