refactor(domain): 优化智能柜应用服务中店铺信息设置逻辑
将流式操作中的直接映射改为先获取店铺对象再设置属性,避免重复查找并增加mode字段的设置
This commit is contained in:
parent
b1328b35ec
commit
4a9e6d8d1c
|
@ -54,14 +54,15 @@ public class SmartCabinetApplicationService {
|
||||||
.map(SmartCabinetDTO::new)
|
.map(SmartCabinetDTO::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dtoList.forEach(dto ->
|
dtoList.forEach(dto -> {
|
||||||
dto.setShopName(
|
ShopEntity shopDo = shopEntities.stream()
|
||||||
shopEntities.stream()
|
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
||||||
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
.findFirst().orElse(null);
|
||||||
.findFirst()
|
if (shopDo != null) {
|
||||||
.map(ShopEntity::getShopName)
|
dto.setShopName(shopDo.getShopName());
|
||||||
.orElse(""))
|
dto.setMode(shopDo.getMode());
|
||||||
);
|
}
|
||||||
|
});
|
||||||
return new PageDTO<>(dtoList, page.getTotal());
|
return new PageDTO<>(dtoList, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,14 +73,15 @@ public class SmartCabinetApplicationService {
|
||||||
.map(SmartCabinetDTO::new)
|
.map(SmartCabinetDTO::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dtoList.forEach(dto ->
|
dtoList.forEach(dto -> {
|
||||||
dto.setShopName(
|
ShopEntity shopDo = shopEntities.stream()
|
||||||
shopEntities.stream()
|
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
||||||
.filter(shop -> shop.getShopId().equals(dto.getShopId()))
|
.findFirst().orElse(null);
|
||||||
.findFirst()
|
if (shopDo != null) {
|
||||||
.map(ShopEntity::getShopName)
|
dto.setShopName(shopDo.getShopName());
|
||||||
.orElse(""))
|
dto.setMode(shopDo.getMode());
|
||||||
);
|
}
|
||||||
|
});
|
||||||
return dtoList;
|
return dtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue