Пример #1
0
  @RequestMapping(method = RequestMethod.GET)
  public String search(
      @PathVariable String language,
      @Validated ArticleSearchForm form,
      BindingResult result,
      @PageableDefault(50) Pageable pageable,
      Model model,
      HttpSession session) {
    Page<Article> articles = articleService.readArticles(form.toArticleSearchRequest(), pageable);

    new DomainObjectSearchCondition<>(session, form, pageable);

    model.addAttribute("form", form);
    model.addAttribute("articles", articles);
    model.addAttribute("pageable", pageable);

    UriComponentsBuilder builder = UriComponentsBuilder.fromPath(Application.ADMIN_SERVLET_PATH);
    builder.path("/{language}/articles/index");
    builder.queryParams(form.toQueryParams());
    String url = builder.buildAndExpand(language).toString();
    model.addAttribute("pagination", new Pagination<>(articles, url));
    return "article/index";
  }
Пример #2
0
 @ModelAttribute("countPublished")
 public long countPublished(@PathVariable String language) {
   return articleService.countArticlesByStatus(Post.Status.PUBLISHED, language);
 }
Пример #3
0
 @ModelAttribute("countDraft")
 public long countDraft(@PathVariable String language) {
   return articleService.countArticlesByStatus(Post.Status.DRAFT, language);
 }
Пример #4
0
 @ModelAttribute("countScheduled")
 public long countScheduled(@PathVariable String language) {
   return articleService.countArticlesByStatus(Post.Status.SCHEDULED, language);
 }
Пример #5
0
 @ModelAttribute("countAll")
 public long countAll(@PathVariable String language) {
   return articleService.countArticles(language);
 }