Skip to content

Commit 52021f7

Browse files
committed
FullStack Backend
1 parent 7e3417c commit 52021f7

File tree

1 file changed

+45
-6
lines changed
  • Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/service

1 file changed

+45
-6
lines changed

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/service/CommonDataServiceImpl.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.urunov.model.MainScreenResponse;
1919
import com.urunov.model.SearchSuggestionResponse;
2020
import com.urunov.service.interfaces.CommonDataService;
21+
import org.javatuples.Pair;
2122
import org.modelmapper.ModelMapper;
2223
import org.modelmapper.TypeToken;
2324
import org.springframework.beans.factory.annotation.Autowired;
@@ -109,20 +110,58 @@ public MainScreenResponse getHomeScreenData(String apiName)
109110
return new MainScreenResponse(brandDtoList, apparelDTOList, carouselImages);
110111
}
111112

112-
113-
@Override
113+
@Cacheable(key = "#queryParams", value = "filterAttributesResponse")
114114
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+
115125
return null;
116126
}
117127

118-
@Override
128+
@Cacheable(key = "#queryParams", value = "productInfoDTO")
119129
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;
121144
}
122145

123-
@Override
146+
@Cacheable(key = "#queryParams", value = "bashMap")
124147
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;
126165
}
127166

128167
@Override

0 commit comments

Comments
 (0)