feat(filter): 更新白名单并优化设备类型查询性能

- 在AppVersionFilter白名单中添加hangUp和exportPdf接口
- 优化DeviceTypeController中的数据库查询逻辑
- 使用Set替代List避免重复数据提高查询效率
- 添加CollectionUtil非空检查增强代码健壮性
- 减少不必要的流操作提升查询性能
This commit is contained in:
曹鹏飞 2026-01-16 09:21:57 +08:00
parent 27d6fe13e8
commit d0d78d54c6
2 changed files with 6 additions and 3 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

@ -30,7 +30,7 @@ public class AppVersionFilter extends OncePerRequestFilter {
/**
* 因前端部分接口遗漏App-Version参数ios打包重新审核需要很久所以需要排除掉否则会导致接口无法访问
*/
private static final Set<String> WHITE_LIST = Set.of("getTicket", "uploadSingleFile", "getInfoById");
private static final Set<String> WHITE_LIST = Set.of("getTicket", "uploadSingleFile", "getInfoById", "hangUp", "exportPdf");
private static final String MIN_SUPPER_VERSION = "1.0.9";