Subversion Repositories SmartDukaan

Rev

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

Rev 36401 Rev 36563
Line 1857... Line 1857...
1857
 
1857
 
1858
    @Autowired
1858
    @Autowired
1859
    private CustomerRepository customerRepository;
1859
    private CustomerRepository customerRepository;
1860
 
1860
 
1861
 
1861
 
-
 
1862
    @Autowired
-
 
1863
    private com.spice.profitmandi.dao.repository.catalog.ModelFlagshipRepository modelFlagshipRepository;
-
 
1864
 
-
 
1865
    @RequestMapping(value = "/manageFlagship", method = RequestMethod.GET)
-
 
1866
    public String manageFlagship(HttpServletRequest request, Model model) throws Exception {
-
 
1867
        List<com.spice.profitmandi.dao.entity.catalog.ModelFlagship> flagshipModels = modelFlagshipRepository.selectAll();
-
 
1868
        if (!flagshipModels.isEmpty()) {
-
 
1869
            List<Integer> catalogIds = flagshipModels.stream()
-
 
1870
                    .map(com.spice.profitmandi.dao.entity.catalog.ModelFlagship::getCatalogItemId)
-
 
1871
                    .distinct().collect(Collectors.toList());
-
 
1872
            try {
-
 
1873
                Map<Integer, String> descMap = catalogRepository.selectAllByIds(catalogIds).stream()
-
 
1874
                        .collect(Collectors.toMap(Catalog::getId, Catalog::getDescription, (a, b) -> a));
-
 
1875
                for (com.spice.profitmandi.dao.entity.catalog.ModelFlagship fm : flagshipModels) {
-
 
1876
                    fm.setCatalogDescription(descMap.getOrDefault(fm.getCatalogItemId(), "Unknown"));
-
 
1877
                }
-
 
1878
            } catch (Exception e) {
-
 
1879
                LOGGER.error("Error fetching catalog descriptions for flagship models", e);
-
 
1880
            }
-
 
1881
        }
-
 
1882
        model.addAttribute("flagshipModels", flagshipModels);
-
 
1883
        return "manage-flagship";
-
 
1884
    }
-
 
1885
 
-
 
1886
    @RequestMapping(value = "/addFlagship", method = RequestMethod.POST)
-
 
1887
    public String addFlagship(HttpServletRequest request, @RequestParam int catalogItemId,
-
 
1888
                              @RequestParam String startDate, @RequestParam(required = false) String endDate,
-
 
1889
                              Model model) throws Exception {
-
 
1890
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
1891
        com.spice.profitmandi.dao.entity.catalog.ModelFlagship fm = new com.spice.profitmandi.dao.entity.catalog.ModelFlagship();
-
 
1892
        fm.setCatalogItemId(catalogItemId);
-
 
1893
        fm.setStartDate(java.time.LocalDate.parse(startDate));
-
 
1894
        if (endDate != null && !endDate.isEmpty()) {
-
 
1895
            fm.setEndDate(java.time.LocalDate.parse(endDate));
-
 
1896
        }
-
 
1897
        fm.setCreatedOn(java.time.LocalDateTime.now());
-
 
1898
        fm.setCreatedBy(loginDetails.getEmailId());
-
 
1899
        modelFlagshipRepository.persist(fm);
-
 
1900
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
1901
        return "response";
-
 
1902
    }
-
 
1903
 
-
 
1904
    @RequestMapping(value = "/flagship/remove", method = RequestMethod.POST)
-
 
1905
    public String removeFlagship(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
-
 
1906
        com.spice.profitmandi.dao.entity.catalog.ModelFlagship fm = modelFlagshipRepository.selectById(id);
-
 
1907
        if (fm != null) {
-
 
1908
            modelFlagshipRepository.delete(fm);
-
 
1909
        }
-
 
1910
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
1911
        return "response";
-
 
1912
    }
-
 
1913
 
1862
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1914
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1863
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1915
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1864
 
1916
 
1865
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1917
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1866
 
1918