use of com.myblog.model.Category in project newblogback by Zephery.
the class BlogController method editArticle.
@GetMapping(value = "/{cid}")
public ModelAndView editArticle(@PathVariable String cid, HttpServletRequest request) {
ModelAndView modelAndView = new ModelAndView();
Blog blog = blogService.getBlogDetail(Integer.parseInt(cid));
modelAndView.addObject("blog", blog);
List<Category> categories = categoryService.getAllCategory();
modelAndView.addObject("categories", categories);
modelAndView.addObject("active", "article");
modelAndView.setViewName("/admin/article_edit");
return modelAndView;
}
use of com.myblog.model.Category in project newblogback by Zephery.
the class CategoryController method index.
@GetMapping(value = "")
public ModelAndView index() {
List<Category> categories = categoryService.getAllCategory();
List<Tag> tags = tagService.getAllTags();
ModelAndView mv = new ModelAndView();
mv.addObject("categories", categories);
mv.addObject("tags", tags);
mv.setViewName("/admin/category");
return mv;
}
use of com.myblog.model.Category in project newblogback by Zephery.
the class BlogServiceImpl method getBlogDetail.
@Override
public Blog getBlogDetail(Integer blogid) {
Blog blog = blogMapper.selectByPrimaryKey(blogid);
if (blog == null) {
return null;
}
Category category = categoryMapper.selectByPrimaryKey(blog.getCategoryid());
blog.setCategory(category);
List<Tag> tags = tagMapper.getTagByBlogId(blog.getBlogid());
List<String> list = new ArrayList<>();
for (Tag tag : tags) {
list.add(tag.gettName());
}
blog.setTagforsplit(StringUtils.join(list, ","));
blog.setTags(tags.size() > 0 ? tags : null);
if (blogMapper.updatehits(blogid)) {
logger.info("read count success");
} else {
logger.info("read count failure");
}
return blog;
}
Aggregations