Subversion Repositories SmartDukaan

Rev

Rev 31628 | Rev 31634 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31628 Rev 31629
Line 261... Line 261...
261
 
261
 
262
		return responseSender.ok(true);
262
		return responseSender.ok(true);
263
	}
263
	}
264
 
264
 
265
	@RequestMapping(value = "/fofo/fovourites", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
265
	@RequestMapping(value = "/fofo/fovourites", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
266
	public ResponseEntity<?> getFavourites(HttpServletRequest request, @RequestParam int fofoId) throws Exception {
266
	public ResponseEntity<?> getFavourites(HttpServletRequest request) throws Exception {
-
 
267
 
-
 
268
		int userId = (int) request.getAttribute("userId");
-
 
269
		UserCart uc = userAccountRepository.getUserCart(userId);
-
 
270
		int fofoId = uc.getUserId();
267
 
271
 
268
		Set<Integer> catalogIds = catalogFavouriteRepository.selectBypartnerId(fofoId).stream()
272
		Set<Integer> catalogIds = catalogFavouriteRepository.selectBypartnerId(fofoId).stream()
269
				.map(x -> x.getCatalogId()).collect(Collectors.toSet());
273
				.map(x -> x.getCatalogId()).collect(Collectors.toSet());
270
		RestClient rc = new RestClient();
274
		RestClient rc = new RestClient();
271
		Map<String, String> params = new HashMap<>();
275
		Map<String, String> params = new HashMap<>();
Line 730... Line 734...
730
				priceCircularItemModelMap = priceCircularItemModels.stream()
734
				priceCircularItemModelMap = priceCircularItemModels.stream()
731
						.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
735
						.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
732
			}
736
			}
733
		}
737
		}
734
 
738
 
-
 
739
		List<CatalogFavourite> catalogFavourites = catalogFavouriteRepository.selectBypartnerId(fofoId);
-
 
740
		List<Integer> catalogFavouriteIds = new ArrayList<>();
-
 
741
		if (!catalogFavourites.isEmpty()) {
-
 
742
			catalogFavouriteIds = catalogFavourites.stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
-
 
743
		}
-
 
744
 
-
 
745
		if (!catalogFavourites.isEmpty()) {
-
 
746
			catalogFavourites.stream().collect(Collectors.toMap(x -> x.getCatalogId(), x -> x));
-
 
747
		}
-
 
748
 
735
		for (int i = 0; i < docs.length(); i++) {
749
		for (int i = 0; i < docs.length(); i++) {
736
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
750
			Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
737
			JSONObject doc = docs.getJSONObject(i);
751
			JSONObject doc = docs.getJSONObject(i);
738
			FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
752
			FofoCatalogResponse fofoCatalogResponse = new FofoCatalogResponse();
739
			fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
753
			fofoCatalogResponse.setCatalogId(doc.getInt("catalogId_i"));
740
			fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
754
			fofoCatalogResponse.setImageUrl(doc.getString("imageUrl_s"));
741
			fofoCatalogResponse.setTitle(doc.getString("title_s"));
755
			fofoCatalogResponse.setTitle(doc.getString("title_s"));
742
 
756
 
-
 
757
			if (catalogFavouriteIds.contains(fofoCatalogResponse.getCatalogId())) {
-
 
758
				fofoCatalogResponse.setFavourite(true);
-
 
759
			}
-
 
760
 
743
			List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers()
761
			List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers()
744
					.get(fofoCatalogResponse.getCatalogId());
762
					.get(fofoCatalogResponse.getCatalogId());
745
 
763
 
746
			logger.info("webOffers {}", webOffers);
764
			logger.info("webOffers {}", webOffers);
747
			if (webOffers != null && webOffers.size() > 0) {
765
			if (webOffers != null && webOffers.size() > 0) {