Subversion Repositories SmartDukaan

Rev

Rev 35583 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35583 Rev 35585
Line 422... Line 422...
422
        String email = loginDetails.getEmailId();
422
        String email = loginDetails.getEmailId();
423
        AuthUser authUser = authRepository.selectByEmailOrMobile(email);
423
        AuthUser authUser = authRepository.selectByEmailOrMobile(email);
424
        List<Position> positions = positionRepository.selectAllByAuthUserId(authUser.getId());
424
        List<Position> positions = positionRepository.selectAllByAuthUserId(authUser.getId());
425
        LocalDate selectedDate = LocalDate.parse(date);
425
        LocalDate selectedDate = LocalDate.parse(date);
426
 
426
 
427
        // DB data
427
        // DB data (can be any order)
428
        Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> dbBulletins =
428
        Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> dbBulletins =
429
                adminUser.getTodayBulletin(positions, selectedDate.atStartOfDay());
429
                adminUser.getTodayBulletin(positions, selectedDate.atStartOfDay());
430
 
430
 
431
        // Final ordered map
431
        // Final ordered map (STRICT enum order)
432
        Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> bulletins =
432
        Map<ProfitMandiConstants.BULLETIN_TYPE_ENUM, List<BulletinOfferModal>> bulletins =
433
                new LinkedHashMap<>();
433
                new LinkedHashMap<>();
434
 
434
 
435
        // 1️⃣ First add types that HAVE data
-
 
436
        dbBulletins.forEach((key, value) -> {
-
 
437
            if (value != null && !value.isEmpty()) {
-
 
438
                bulletins.put(key, value);
-
 
439
            }
-
 
440
        });
-
 
441
 
-
 
442
        // 2️⃣ Then add missing enum types as empty
-
 
443
        for (ProfitMandiConstants.BULLETIN_TYPE_ENUM type :
435
        for (ProfitMandiConstants.BULLETIN_TYPE_ENUM type :
444
                ProfitMandiConstants.BULLETIN_TYPE_ENUM.values()) {
436
                ProfitMandiConstants.BULLETIN_TYPE_ENUM.values()) {
-
 
437
 
-
 
438
            List<BulletinOfferModal> list = dbBulletins.get(type);
-
 
439
 
-
 
440
            if (list != null && !list.isEmpty()) {
445
            bulletins.putIfAbsent(type, new ArrayList<>());
441
                bulletins.put(type, list);   // only add if has data
-
 
442
            }
446
        }
443
        }
447
 
444
 
448
        model.addAttribute("bulletins", bulletins);
445
        model.addAttribute("bulletins", bulletins);
449
        return "bulletin-list";
446
        return "bulletin-list";
450
    }
447
    }
451
 
448
 
452
 
449
 
453
 
-
 
454
    @RequestMapping(value = "/dashboard", method = RequestMethod.GET)
450
    @RequestMapping(value = "/dashboard", method = RequestMethod.GET)
455
    public String dashboard(HttpServletRequest request, Model model) throws Exception {
451
    public String dashboard(HttpServletRequest request, Model model) throws Exception {
456
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
452
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
457
        String email = loginDetails.getEmailId();
453
        String email = loginDetails.getEmailId();
458
        int fofoId = loginDetails.getFofoId();
454
        int fofoId = loginDetails.getFofoId();