@RequestMapping("/article-list")
public String doList(@RequestParam(required = false) Long categoryId, Model model) {
//
List<BlogCategory> articleCategories = blogCategoryService.getBlogCategories();
if (!articleCategories.isEmpty()) {
BlogCategory articleCategory = articleCategories.get(0);
if (categoryId != null) {
for (BlogCategory tmp : articleCategories) {
if (categoryId.longValue() == tmp.getId()) {
articleCategory = tmp;
}
}
}
//
Page<BlogPost> page = new Page<BlogPost>(10);
page = blogPostService.fetchPageByCategoryId(page, 0, articleCategory.getId());
//
model.addAttribute("articleCategories", articleCategories);
model.addAttribute("articleCategory", articleCategory);
model.addAttribute("page", page);
}