Search in sources :

Example 11 with BloggerProfile

use of com.duan.blogos.entity.blogger.BloggerProfile 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) {
        request.setAttribute("code", UnknownBloggerException.code);
        mv.setViewName("/blogger/register");
        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 12 with BloggerProfile

use of com.duan.blogos.entity.blogger.BloggerProfile in project BlogSystem by DuanJiaNing.

the class BloggerProfileController method get.

/**
 * 获取资料
 */
@RequestMapping(method = RequestMethod.GET)
public ResultBean<BloggerProfile> get(HttpServletRequest request, @PathVariable Integer bloggerId) {
    handleAccountCheck(request, bloggerId);
    BloggerProfile profile = bloggerProfileService.getBloggerProfile(bloggerId);
    if (profile == null)
        handlerEmptyResult(request);
    return new ResultBean<>(profile);
}
Also used : ResultBean(com.duan.blogos.restful.ResultBean) BloggerProfile(com.duan.blogos.entity.blogger.BloggerProfile)

Aggregations

BloggerProfile (com.duan.blogos.entity.blogger.BloggerProfile)12 BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)8 BloggerPicture (com.duan.blogos.entity.blogger.BloggerPicture)6 BloggerDTO (com.duan.blogos.dto.blogger.BloggerDTO)5 BloggerSetting (com.duan.blogos.entity.blogger.BloggerSetting)3 ResultBean (com.duan.blogos.restful.ResultBean)3 ArrayList (java.util.ArrayList)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BlogListItemDTO (com.duan.blogos.dto.blog.BlogListItemDTO)2 FavouriteBlogListItemDTO (com.duan.blogos.dto.blogger.FavouriteBlogListItemDTO)2 BlogListItemComparatorFactory (com.duan.blogos.manager.comparator.BlogListItemComparatorFactory)2 HashMap (java.util.HashMap)2 BlogCommentDTO (com.duan.blogos.dto.blog.BlogCommentDTO)1 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)1 BlogComment (com.duan.blogos.entity.blog.BlogComment)1