Subversion Repositories SmartDukaan

Rev

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

Rev 36563 Rev 36598
Line 1909... Line 1909...
1909
        }
1909
        }
1910
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1910
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1911
        return "response";
1911
        return "response";
1912
    }
1912
    }
1913
 
1913
 
-
 
1914
    @RequestMapping(value = "/catalogItem", method = RequestMethod.GET)
-
 
1915
    public String getCatalogItemSearch(HttpServletRequest request, Model model,
-
 
1916
                                       @RequestParam String query,
-
 
1917
                                       @RequestParam(required = false, defaultValue = "0") float minPrice) throws Throwable {
-
 
1918
        String query1 = query.toLowerCase();
-
 
1919
        List<Catalog> allCatalogs = catalogRepository.selectAll();
-
 
1920
        List<Catalog> matchingCatalogs = allCatalogs.stream()
-
 
1921
                .filter(c -> c.getDescription().toLowerCase().contains(query1))
-
 
1922
                .collect(Collectors.toList());
-
 
1923
 
-
 
1924
        if (minPrice > 0 && !matchingCatalogs.isEmpty()) {
-
 
1925
            List<Integer> catalogIds = matchingCatalogs.stream()
-
 
1926
                    .map(Catalog::getId).collect(Collectors.toList());
-
 
1927
            Map<Integer, TagListing> tagMap = tagListingRepository.selectAllByCatalogIds(catalogIds);
-
 
1928
            matchingCatalogs = matchingCatalogs.stream()
-
 
1929
                    .filter(c -> {
-
 
1930
                        TagListing tl = tagMap.get(c.getId());
-
 
1931
                        return tl != null && tl.getSellingPrice() >= minPrice;
-
 
1932
                    })
-
 
1933
                    .collect(Collectors.toList());
-
 
1934
        }
-
 
1935
 
-
 
1936
        List<ItemDescriptionModel> result = matchingCatalogs.stream().map(c -> {
-
 
1937
            ItemDescriptionModel m = new ItemDescriptionModel();
-
 
1938
            m.setCatalogId(c.getId());
-
 
1939
            m.setItemDescription(c.getDescription() + " (" + c.getId() + ")");
-
 
1940
            return m;
-
 
1941
        }).collect(Collectors.toList());
-
 
1942
 
-
 
1943
        model.addAttribute("response1", mvcResponseSender.createResponseString(result));
-
 
1944
        return "response";
-
 
1945
    }
-
 
1946
 
1914
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1947
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1915
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1948
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1916
 
1949
 
1917
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1950
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1918
 
1951