From 69828f5c5da283d14ac6a77ff84ab62696582eb5 Mon Sep 17 00:00:00 2001 From: anasElhaddad <anas.elhaddad@marketingconfort.com> Date: Thu, 13 Feb 2025 21:21:57 +0000 Subject: [PATCH] fix item count --- CHANGELOG.md | 18 ++++++++++++++++++ .../services/impl/CartServiceImp.java | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2179125..87220ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +### Added +- New features that have been added. + +### Changed +- Changes in existing functionality. + +### Deprecated +- Soon-to-be removed features. + +### Removed +- Features that have been removed. + +### Fixed +- fix item count + +### Security +- Any security improvements. + ## [1.0.70-RELEASE] ### Added - Added a method to verify cart consistency with the database. diff --git a/src/main/java/com/marketingconfort/mydressin/services/impl/CartServiceImp.java b/src/main/java/com/marketingconfort/mydressin/services/impl/CartServiceImp.java index 5e2813f..5f374ac 100644 --- a/src/main/java/com/marketingconfort/mydressin/services/impl/CartServiceImp.java +++ b/src/main/java/com/marketingconfort/mydressin/services/impl/CartServiceImp.java @@ -981,7 +981,7 @@ public class CartServiceImp implements CartService { throws TechnicalException { List<ClientDTO> clients = (keyword != null && !keyword.isBlank()) ? externalApiService.getClientsByKeyword(keyword) - : Collections.emptyList(); + : Collections.emptyList() ; List<ProductCartDTO> products = (productKeyword != null && !productKeyword.isBlank()) ? productStockService.getProductByKeyword(productKeyword) : Collections.emptyList(); @@ -993,10 +993,10 @@ public class CartServiceImp implements CartService { .map(ProductCartDTO::getProductId) .filter(Objects::nonNull) .collect(Collectors.toList()); - if (clientIds.isEmpty()) { + if (clientIds.isEmpty() && keyword == null || keyword.isBlank()) { clientIds = List.of(-1L); } - if (productIds.isEmpty()) { + if (productIds.isEmpty() && productKeyword == null || productKeyword.isBlank()) { productIds = List.of(-1L); } Map<Long, ClientDTO> clientMap = clients.stream() @@ -1041,6 +1041,7 @@ public class CartServiceImp implements CartService { .mapToDouble(ProductDetailsCartDTO::getTotalPrice) .sum()); cartDTO.setClientDTO(clientDTO); + cartDTO.setItemsCount(productDetailsCartDTOS.size()); cartDTO.setProductDetailsCartDTOS(productDetailsCartDTOS); return cartDTO; }); -- GitLab