|
18 | 18 | import com.urunov.model.MainScreenResponse; |
19 | 19 | import com.urunov.model.SearchSuggestionResponse; |
20 | 20 | import com.urunov.service.interfaces.CommonDataService; |
| 21 | +import org.javatuples.Pair; |
21 | 22 | import org.modelmapper.ModelMapper; |
22 | 23 | import org.modelmapper.TypeToken; |
23 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -109,20 +110,58 @@ public MainScreenResponse getHomeScreenData(String apiName) |
109 | 110 | return new MainScreenResponse(brandDtoList, apparelDTOList, carouselImages); |
110 | 111 | } |
111 | 112 |
|
112 | | - |
113 | | - @Override |
| 113 | + @Cacheable(key = "#queryParams", value = "filterAttributesResponse") |
114 | 114 | public FilterAttributesResponse getFilterAttributesByProducts(String queryParams) { |
| 115 | + HashMap<String, String> conditionMap = getConditionMapFromQuery(queryParams); |
| 116 | + |
| 117 | + |
| 118 | + if(conditionMap != null && !conditionMap.isEmpty()) |
| 119 | + { |
| 120 | + FilterAttributesResponse filterAttributesResponse = productInfoRepository.getFilterAttributesByProducts(conditionMap); |
| 121 | + filterAttributesResponse.setSortby(sortByCategoryRepository.getAllData()); |
| 122 | + return filterAttributesResponse; |
| 123 | + } |
| 124 | + |
115 | 125 | return null; |
116 | 126 | } |
117 | 127 |
|
118 | | - @Override |
| 128 | + @Cacheable(key = "#queryParams", value = "productInfoDTO") |
119 | 129 | public ProductInfoDTO getProductsByCategories(String queryParams) { |
120 | | - return null; |
| 130 | + |
| 131 | + HashMap<String, String> conditionMap = getConditionMapFromQuery(queryParams); |
| 132 | + ProductInfoDTO productInfoDTO = null; |
| 133 | + |
| 134 | + if(conditionMap !=null && !conditionMap.isEmpty()) |
| 135 | + { |
| 136 | + Pair<Long, List<ProductInfo>> result = productInfoRepository.getProductByCategories(conditionMap); |
| 137 | + if(result !=null) |
| 138 | + { |
| 139 | + productInfoDTO = new ProductInfoDTO(result.getValue0(), result.getValue1()); |
| 140 | + |
| 141 | + } |
| 142 | + } |
| 143 | + return productInfoDTO; |
121 | 144 | } |
122 | 145 |
|
123 | | - @Override |
| 146 | + @Cacheable(key = "#queryParams", value = "bashMap") |
124 | 147 | public HashMap<Integer, ProductInfo> getProductsById(String queryParams) { |
125 | | - return null; |
| 148 | + |
| 149 | + String[] productIds = queryParams.split(","); |
| 150 | + HashMap<Integer, ProductInfo> resultMap = null; |
| 151 | + |
| 152 | + if(productIds.length > 0) { |
| 153 | + List<ProductInfo> result = productInfoRepository.getProductsById(productIds); |
| 154 | + |
| 155 | + if(result !=null) |
| 156 | + { |
| 157 | + resultMap = new HashMap<>(); |
| 158 | + for(ProductInfo info: result) |
| 159 | + { |
| 160 | + resultMap.put(info.getId(), info); |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + return resultMap; |
126 | 165 | } |
127 | 166 |
|
128 | 167 | @Override |
|
0 commit comments