Search in sources :

Example 6 with Category

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;
}
Also used : Category(com.myblog.model.Category) ModelAndView(org.springframework.web.servlet.ModelAndView) Blog(com.myblog.model.Blog)

Example 7 with Category

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;
}
Also used : Category(com.myblog.model.Category) ModelAndView(org.springframework.web.servlet.ModelAndView) Tag(com.myblog.model.Tag)

Example 8 with Category

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;
}
Also used : Category(com.myblog.model.Category) ArrayList(java.util.ArrayList) Tag(com.myblog.model.Tag) Blog(com.myblog.model.Blog)

Aggregations

Category (com.myblog.model.Category)8 Blog (com.myblog.model.Blog)5 Tag (com.myblog.model.Tag)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 PageInfo (com.github.pagehelper.PageInfo)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1