You've already forked FrameTour-BE
refactor(device): 优化默认配置示例代码
- 移除了不必要的 getData() 调用,直接使用 getList() 和 getTotal() 方法 - 使用 Java 8 Stream API 简化了部分代码,提高了可读性 - 优化了配置类型分布统计逻辑,使用更简洁的方式
This commit is contained in:
@@ -57,10 +57,10 @@ public class DefaultConfigIntegrationExample implements CommandLineRunner {
|
||||
// 获取默认配置列表(自动缓存,服务不可用时返回缓存数据)
|
||||
PageResponse<DefaultConfigResponse> configList = defaultConfigService.listDefaultConfigs(1, 10);
|
||||
log.info("默认配置列表: 总数={}, 当前页配置数={}",
|
||||
configList.getData().getTotal(), configList.getData().getList().size());
|
||||
configList.getTotal(), configList.getList().size());
|
||||
|
||||
// 显示配置详情
|
||||
for (DefaultConfigResponse config : configList.getData().getList()) {
|
||||
for (DefaultConfigResponse config : configList.getList()) {
|
||||
log.info("配置详情: key={}, value={}, type={}, description={}",
|
||||
config.getConfigKey(), config.getConfigValue(),
|
||||
config.getConfigType(), config.getDescription());
|
||||
@@ -234,14 +234,14 @@ public class DefaultConfigIntegrationExample implements CommandLineRunner {
|
||||
// 检查必需的基础配置是否存在
|
||||
String[] requiredConfigs = {"resolution", "frameRate", "codec", "protocol"};
|
||||
for (String requiredConfig : requiredConfigs) {
|
||||
boolean exists = allConfigs.getData().getList().stream()
|
||||
boolean exists = allConfigs.getList().stream()
|
||||
.anyMatch(config -> requiredConfig.equals(config.getConfigKey()));
|
||||
log.info("必需配置 {} 存在: {}", requiredConfig, exists ? "✓" : "✗");
|
||||
}
|
||||
|
||||
// 统计配置类型分布
|
||||
Map<String, Long> typeDistribution = new HashMap<>();
|
||||
allConfigs.getData().getList().forEach(config ->
|
||||
allConfigs.getList().forEach(config ->
|
||||
typeDistribution.merge(config.getConfigType(), 1L, Long::sum)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user