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