Search in sources :

Example 1 with BloggerStatisticsDTO

use of com.duan.blogos.dto.blogger.BloggerStatisticsDTO in project BlogSystem by DuanJiaNing.

the class EditBlogPageController method mainPage.

@RequestMapping
public ModelAndView mainPage(HttpServletRequest request, @RequestParam(value = "bid", required = false) Integer bloggerId, @RequestParam(value = "blogId", required = false) Integer blogId) {
    ModelAndView mv = new ModelAndView();
    if (bloggerId == null || !bloggerValidateManager.checkBloggerSignIn(request, bloggerId)) {
        mv.setViewName("/error/error");
        mv.addObject("errorMsg", "请先登录");
    } else {
        if (blogId != null) {
            ResultBean<Blog> blog = blogService.getBlog(bloggerId, blogId);
            Blog data = blog.getData();
            mv.addObject("blogId", blogId);
            mv.addObject("categoryId", data.getCategoryIds());
            mv.addObject("labelIds", data.getLabelIds());
            mv.addObject("blogTitle", data.getTitle());
            mv.addObject("blogSummary", data.getSummary());
            if (data.getState().equals(BlogStatusEnum.PRIVATE.getCode())) {
                mv.addObject("blogIsPrivate", true);
            }
            mv.addObject("blogContentMd", StringUtils.stringToUnicode(data.getContentMd()));
        }
        ResultBean<BloggerStatisticsDTO> loginBgStat = statisticsService.getBloggerStatistics(bloggerId);
        mv.addObject("loginBgStat", loginBgStat.getData());
        mv.setViewName("/blogger/edit_blog");
    }
    return mv;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO) Blog(com.duan.blogos.entity.blog.Blog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with BloggerStatisticsDTO

use of com.duan.blogos.dto.blogger.BloggerStatisticsDTO in project BlogSystem by DuanJiaNing.

the class BloggerStatisticsServiceImpl method getBloggerStatistics.

@Override
public ResultBean<BloggerStatisticsDTO> getBloggerStatistics(int bloggerId) {
    int blogCount = blogDao.countBlogByBloggerId(bloggerId, BlogStatusEnum.PUBLIC.getCode());
    List<Blog> blogs = blogDao.listAllWordCountByBloggerId(bloggerId, BlogStatusEnum.PUBLIC.getCode());
    int wordCountSum = blogs.stream().mapToInt(Blog::getWordCount).sum();
    int likeCount = blogs.stream().mapToInt(Blog::getId).map(statisticsDao::getLikeCount).sum();
    int likeGiveCount = likeDao.countLikeByLikerId(bloggerId);
    int categoryCount = categoryDao.countByBloggerId(bloggerId);
    int labelCount = labelDao.countByBloggerId(bloggerId);
    int collectCount = collectDao.countByCollectorId(bloggerId);
    int collectedCount = blogs.stream().mapToInt(Blog::getId).map(statisticsDao::getCollectCount).sum();
    int linkCount = linkDao.countLinkByBloggerId(bloggerId);
    BloggerStatisticsDTO dto = dataFillingManager.bloggerStatisticToDTO(blogCount, wordCountSum, likeCount, likeGiveCount, categoryCount, labelCount, collectCount, collectedCount, linkCount);
    return new ResultBean<>(dto);
}
Also used : BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO) Blog(com.duan.blogos.entity.blog.Blog) ResultBean(com.duan.blogos.restful.ResultBean)

Example 3 with BloggerStatisticsDTO

use of com.duan.blogos.dto.blogger.BloggerStatisticsDTO 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)

Example 4 with BloggerStatisticsDTO

use of com.duan.blogos.dto.blogger.BloggerStatisticsDTO in project BlogSystem by DuanJiaNing.

the class BloggerPageController method mainPage.

@RequestMapping("/archives")
public ModelAndView mainPage(HttpServletRequest request, @PathVariable String bloggerName) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("blogger/main");
    BloggerAccount account = accountService.getAccount(bloggerName);
    if (account == null) {
        mv.addObject("code", 6);
        mv.addObject(bloggerProperties.getSessionNameOfErrorMsg(), "博主不存在!");
        mv.setViewName("error/error");
        return mv;
    }
    mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerId(), account.getId());
    mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerName(), account.getUsername());
    int ownerId = account.getId();
    BloggerProfile profile = bloggerProfileService.getBloggerProfile(ownerId);
    mv.addObject("blogName", profile.getIntro());
    mv.addObject("aboutMe", profile.getAboutMe());
    mv.addObject("avatarId", Optional.ofNullable(profile.getAvatarId()).orElse(bloggerPictureService.getDefaultPicture(BloggerPictureCategoryEnum.DEFAULT_BLOGGER_AVATAR).getId()));
    ResultBean<BloggerStatisticsDTO> ownerBgStat = statisticsService.getBloggerStatistics(ownerId);
    mv.addObject("ownerBgStat", ownerBgStat.getData());
    int loginBgId;
    if ((loginBgId = sessionManager.getLoginBloggerId(request)) != -1) {
        ResultBean<BloggerStatisticsDTO> loginBgStat = statisticsService.getBloggerStatistics(loginBgId);
        mv.addObject("loginBgStat", loginBgStat.getData());
    }
    BloggerSetting setting = settingService.getSetting(ownerId);
    mv.addObject("setting", setting);
    return mv;
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) BloggerSetting(com.duan.blogos.entity.blogger.BloggerSetting) ModelAndView(org.springframework.web.servlet.ModelAndView) BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO) BloggerProfile(com.duan.blogos.entity.blogger.BloggerProfile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with BloggerStatisticsDTO

use of com.duan.blogos.dto.blogger.BloggerStatisticsDTO in project BlogSystem by DuanJiaNing.

the class FavouriteBlogPageController method setCommon.

private void setCommon(ModelAndView mv, HttpServletRequest request, String bloggerName) {
    mv.setViewName("/blogger/favourite_blog");
    // 登陆博主 id
    int loginBloggerId = sessionManager.getLoginBloggerId(request);
    ResultBean<BloggerStatisticsDTO> loginBgStat = statisticsService.getBloggerStatistics(loginBloggerId);
    mv.addObject("loginBgStat", loginBgStat.getData());
    BloggerAccount account = accountService.getAccount(bloggerName);
    mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerId(), account.getId());
    mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerName(), account.getUsername());
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) BloggerStatisticsDTO(com.duan.blogos.dto.blogger.BloggerStatisticsDTO)

Aggregations

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