Subversion Repositories SmartDukaan

Rev

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

Rev 32218 Rev 32544
Line 674... Line 674...
674
 
674
 
675
    @RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
675
    @RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
676
    public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
676
    public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
677
        List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
677
        List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
678
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
678
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
679
        Iterator<WebListing> webListingIterator = webListings.iterator();
-
 
680
        while (webListingIterator.hasNext()) {
679
        for (WebListing webListing : webListings) {
681
            WebListing webListing = webListingIterator.next();
680
            webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
682
            List<FofoCatalogResponse> catalogResponses = getDealResponses(userInfo, webListing);
-
 
683
            boolean isAvailable = catalogResponses.stream().anyMatch(x->x.getItems().stream().anyMatch(y->y.getAvailability()>0));
-
 
684
            if(!isAvailable) {
-
 
685
                webListings.remove(webListing);
-
 
686
            }
681
        }
687
        }
-
 
688
 
682
        return responseSender.ok(webListings);
689
        return responseSender.ok(webListings);
683
    }
690
    }
684
 
691
 
685
    private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing) throws ProfitMandiBusinessException {
692
    private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing) throws ProfitMandiBusinessException {
686
        List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
693
        List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());