| Line 60... |
Line 60... |
| 60 |
model.addAttribute("brands", brandsService.getBrandsToDisplay(MOBILE_BRAND_CATEGORY_ID));
|
60 |
model.addAttribute("brands", brandsService.getBrandsToDisplay(MOBILE_BRAND_CATEGORY_ID));
|
| 61 |
model.addAttribute("maxDeals", ModelHotDealService.MAX_ACTIVE_DEALS_PER_BRAND);
|
61 |
model.addAttribute("maxDeals", ModelHotDealService.MAX_ACTIVE_DEALS_PER_BRAND);
|
| 62 |
return "hot-deals";
|
62 |
return "hot-deals";
|
| 63 |
}
|
63 |
}
|
| 64 |
|
64 |
|
| - |
|
65 |
/** All deals across brands: server-side searched + paginated table fragment. */
|
| 65 |
@RequestMapping(value = "/hotDeals", method = RequestMethod.GET)
|
66 |
@RequestMapping(value = "/hotDeals/all", method = RequestMethod.GET)
|
| 66 |
public String getHotDeals(@RequestParam int brandId, Model model) throws Exception {
|
67 |
public String getAllHotDeals(@RequestParam(defaultValue = "1") int page,
|
| - |
|
68 |
@RequestParam(required = false, defaultValue = "") String q,
|
| - |
|
69 |
Model model) throws Exception {
|
| - |
|
70 |
int pageSize = 20;
|
| - |
|
71 |
long total = modelHotDealService.countDeals(q);
|
| - |
|
72 |
int pages = (int) Math.max(1, (total + pageSize - 1) / pageSize);
|
| - |
|
73 |
page = Math.min(Math.max(1, page), pages);
|
| 67 |
model.addAttribute("deals", modelHotDealService.getDealsForBrand(brandId));
|
74 |
model.addAttribute("deals", modelHotDealService.searchDeals(q, page, pageSize));
|
| 68 |
model.addAttribute("activeCount", modelHotDealService.countActive(brandId));
|
75 |
model.addAttribute("total", total);
|
| - |
|
76 |
model.addAttribute("page", page);
|
| 69 |
model.addAttribute("maxDeals", ModelHotDealService.MAX_ACTIVE_DEALS_PER_BRAND);
|
77 |
model.addAttribute("pages", pages);
|
| 70 |
return "hot-deals-table";
|
78 |
return "hot-deals-table";
|
| 71 |
}
|
79 |
}
|
| 72 |
|
80 |
|
| - |
|
81 |
/** Active-slot usage for a brand, e.g. "3 / 15". */
|
| - |
|
82 |
@RequestMapping(value = "/hotDeals/slots", method = RequestMethod.GET)
|
| - |
|
83 |
public String getSlots(@RequestParam int brandId, Model model) throws Exception {
|
| - |
|
84 |
model.addAttribute("response1", modelHotDealService.countActive(brandId)
|
| - |
|
85 |
+ " / " + ModelHotDealService.MAX_ACTIVE_DEALS_PER_BRAND);
|
| - |
|
86 |
return "response";
|
| - |
|
87 |
}
|
| - |
|
88 |
|
| 73 |
@RequestMapping(value = "/hotDeals/models", method = RequestMethod.GET)
|
89 |
@RequestMapping(value = "/hotDeals/models", method = RequestMethod.GET)
|
| 74 |
public String getModelsForBrand(@RequestParam int brandId, Model model) throws Exception {
|
90 |
public String getModelsForBrand(@RequestParam int brandId, Model model) throws Exception {
|
| 75 |
List<Catalog> catalogs = catalogRepository.selectAllByBrandId(brandId,
|
91 |
List<Catalog> catalogs = catalogRepository.selectAllByBrandId(brandId,
|
| 76 |
ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
92 |
ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
| 77 |
Set<Integer> activeIds = modelHotDealService.getDealsForBrand(brandId).stream()
|
93 |
Set<Integer> activeIds = modelHotDealService.getDealsForBrand(brandId).stream()
|