Search in sources :

Example 1 with BlogStatisticsCountDTO

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

the class BlogStatisticsServiceImpl method getBlogStatisticsCount.

@Override
public ResultBean<BlogStatisticsCountDTO> getBlogStatisticsCount(int blogId) {
    BlogStatistics statistics = statisticsDao.getStatistics(blogId);
    if (statistics == null)
        return null;
    BlogStatisticsCountDTO dto = dataFillingManager.blogStatisticsCountToDTO(statistics);
    return new ResultBean<>(dto);
}
Also used : BlogStatisticsCountDTO(com.duan.blogos.dto.blog.BlogStatisticsCountDTO) ResultBean(com.duan.blogos.restful.ResultBean)

Example 2 with BlogStatisticsCountDTO

use of com.duan.blogos.dto.blog.BlogStatisticsCountDTO 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

BlogStatisticsCountDTO (com.duan.blogos.dto.blog.BlogStatisticsCountDTO)2 BlogMainContentDTO (com.duan.blogos.dto.blog.BlogMainContentDTO)1 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)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