Search in sources :

Example 1 with BlogMainContentDTO

use of com.duan.blogos.dto.blog.BlogMainContentDTO in project BlogSystem by DuanJiaNing.

the class BlogBrowseServiceImpl method getBlogMainContent.

@Override
public ResultBean<BlogMainContentDTO> getBlogMainContent(int blogId) {
    // 查询数据
    Blog blog = blogDao.getBlogById(blogId);
    if (blog == null)
        return null;
    String ch = dbProperties.getStringFiledSplitCharacterForNumber();
    int[] cids = StringUtils.intStringDistinctToArray(blog.getCategoryIds(), ch);
    int[] lids = StringUtils.intStringDistinctToArray(blog.getLabelIds(), ch);
    List<BlogCategory> categories = cids == null ? null : categoryDao.listCategoryById(cids);
    List<BlogLabel> labels = lids == null ? null : labelDao.listLabelById(lids);
    // 填充数据
    String sc = dbProperties.getStringFiledSplitCharacterForString();
    BlogMainContentDTO dto = dataFillingManager.blogMainContentToDTO(blog, categories, labels, sc);
    return new ResultBean<>(dto);
}
Also used : BlogLabel(com.duan.blogos.entity.blog.BlogLabel) BlogCategory(com.duan.blogos.entity.blog.BlogCategory) Blog(com.duan.blogos.entity.blog.Blog) BlogMainContentDTO(com.duan.blogos.dto.blog.BlogMainContentDTO) ResultBean(com.duan.blogos.restful.ResultBean)

Example 2 with BlogMainContentDTO

use of com.duan.blogos.dto.blog.BlogMainContentDTO in project BlogSystem by DuanJiaNing.

the class BlogReadPageController method page.

@RequestMapping
public ModelAndView page(HttpServletRequest request, @PathVariable String bloggerName, @PathVariable String blogName) {
    ModelAndView mv = new ModelAndView();
    // 博文作者博主账户
    BloggerAccount account = accountService.getAccount(bloggerName);
    if (account == null) {
        mv.setViewName("error/error");
        mv.addObject("code", 6);
        mv.addObject(bloggerProperties.getSessionNameOfErrorMsg(), "博主不存在!");
        return mv;
    }
    int blogId = blogService.getBlogId(account.getId(), blogName);
    if (blogId == -1) {
        mv.setViewName("error/error");
        mv.addObject("code", 5);
        mv.addObject(bloggerProperties.getSessionNameOfErrorMsg(), "博文不存在!");
        return mv;
    }
    // 博文浏览次数自增1
    statisticsService.updateBlogViewCountPlus(blogId);
    ResultBean<BlogMainContentDTO> mainContent = blogBrowseService.getBlogMainContent(blogId);
    ResultBean<BlogStatisticsCountDTO> statistics = statisticsService.getBlogStatisticsCount(blogId);
    mv.addObject("blogOwnerBloggerId", account.getId());
    mv.addObject("main", mainContent.getData());
    mv.addObject("stat", statistics.getData());
    // 登陆博主 id
    int loginBloggerId = sessionManager.getLoginBloggerId(request);
    ResultBean<BloggerStatisticsDTO> loginBgStat = bloggerStatisticsService.getBloggerStatistics(loginBloggerId);
    mv.addObject("loginBgStat", loginBgStat.getData());
    if (loginBloggerId != -1) {
        if (likeService.getLikeState(loginBloggerId, blogId))
            mv.addObject("likeState", true);
        if (collectBlogService.getCollectState(loginBloggerId, blogId))
            mv.addObject("collectState", true);
    }
    mv.setViewName("blogger/read_blog");
    return mv;
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) BlogStatisticsCountDTO(com.duan.blogos.dto.blog.BlogStatisticsCountDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO) BlogMainContentDTO(com.duan.blogos.dto.blog.BlogMainContentDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BlogMainContentDTO (com.duan.blogos.dto.blog.BlogMainContentDTO)2 BlogStatisticsCountDTO (com.duan.blogos.dto.blog.BlogStatisticsCountDTO)1 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)1 Blog (com.duan.blogos.entity.blog.Blog)1 BlogCategory (com.duan.blogos.entity.blog.BlogCategory)1 BlogLabel (com.duan.blogos.entity.blog.BlogLabel)1 BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)1 ResultBean (com.duan.blogos.restful.ResultBean)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1