|
72 | 72 | import java.util.Locale;
|
73 | 73 | import java.util.Map;
|
74 | 74 | import java.util.Objects;
|
| 75 | +import java.util.stream.Collectors; |
75 | 76 |
|
76 | 77 | import static ru.mystamps.web.common.ControllerUtils.redirectTo;
|
77 | 78 |
|
@@ -470,10 +471,12 @@ public String processAskForm(
|
470 | 471 | public String searchSeriesByCatalog(
|
471 | 472 | @RequestParam(name = "catalogNumber", defaultValue = "") String catalogNumber,
|
472 | 473 | @RequestParam(name = "catalogName", defaultValue = "") String catalogName,
|
| 474 | + @RequestParam(name = "inCollection", defaultValue = "false") Boolean inCollection, |
| 475 | + @CurrentUser Integer currentUserId, |
473 | 476 | Model model,
|
474 | 477 | Locale userLocale,
|
475 | 478 | RedirectAttributes redirectAttributes) {
|
476 |
| - |
| 479 | + |
477 | 480 | if (StringUtils.isBlank(catalogNumber)) {
|
478 | 481 | redirectAttributes.addFlashAttribute("numberIsEmpty", true);
|
479 | 482 | return "redirect:" + SiteUrl.INDEX_PAGE;
|
@@ -504,6 +507,18 @@ public String searchSeriesByCatalog(
|
504 | 507 | series = Collections.emptyList();
|
505 | 508 | break;
|
506 | 509 | }
|
| 510 | + |
| 511 | + if (Features.SEARCH_IN_COLLECTION.isActive() |
| 512 | + && inCollection |
| 513 | + && currentUserId != null) { |
| 514 | + series = series |
| 515 | + .stream() |
| 516 | + .filter( |
| 517 | + e -> collectionService.isSeriesInCollection(currentUserId, e.getId()) |
| 518 | + ) |
| 519 | + .collect(Collectors.toList()); |
| 520 | + } |
| 521 | + |
507 | 522 | model.addAttribute("searchResults", series);
|
508 | 523 |
|
509 | 524 | return "series/search_result";
|
|
0 commit comments