Search in sources :

Example 1 with BloggerSetting

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

the class BloggerSettingPageController method pageLike.

@RequestMapping
public ModelAndView pageLike(HttpServletRequest request, @ModelAttribute @PathVariable String bloggerName) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/blogger/setting");
    BloggerAccount account = accountService.getAccount(bloggerName);
    int bloggerId;
    if (account == null) {
        mv.addObject("code", UnknownBloggerException.code);
        mv.addObject(bloggerProperties.getSessionNameOfErrorMsg(), "博主不存在!");
        mv.setViewName("error/error");
        return mv;
    } else if (!bloggerValidateManager.checkBloggerSignIn(request, bloggerId = account.getId())) {
        mv.addObject("code", BloggerNotLoggedInException.code);
        mv.addObject(bloggerProperties.getSessionNameOfErrorMsg(), "博主未登录!");
        mv.setViewName("error/error");
        return mv;
    }
    BloggerProfile profile = profileService.getBloggerProfile(bloggerId);
    if (profile.getAvatarId() == null) {
        BloggerPicture picture = pictureService.getDefaultPicture(BloggerPictureCategoryEnum.DEFAULT_BLOGGER_AVATAR);
        profile.setAvatarId(picture.getId());
    }
    mv.addObject("profile", profile);
    BloggerSetting setting = settingService.getSetting(bloggerId);
    mv.addObject("setting", setting);
    return mv;
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) BloggerPicture(com.duan.blogos.entity.blogger.BloggerPicture) BloggerSetting(com.duan.blogos.entity.blogger.BloggerSetting) ModelAndView(org.springframework.web.servlet.ModelAndView) BloggerProfile(com.duan.blogos.entity.blogger.BloggerProfile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with BloggerSetting

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

the class BloggerSettingPageController method pageSetting.

@RequestMapping
public ModelAndView pageSetting(HttpServletRequest request, @ModelAttribute @PathVariable String bloggerName) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/blogger/setting");
    BloggerAccount account = accountService.getAccount(bloggerName);
    int bloggerId;
    if (account == null) {
        request.setAttribute("code", UnknownBloggerException.code);
        mv.setViewName("/blogger/register");
        return mv;
    } else if (!bloggerValidateManager.checkBloggerSignIn(request, bloggerId = account.getId())) {
        return new ModelAndView("redirect:/login");
    }
    BloggerProfile profile = profileService.getBloggerProfile(bloggerId);
    if (profile.getAvatarId() == null) {
        BloggerPicture picture = pictureService.getDefaultPicture(BloggerPictureCategoryEnum.DEFAULT_BLOGGER_AVATAR);
        profile.setAvatarId(picture.getId());
    }
    mv.addObject("profile", profile);
    BloggerSetting setting = settingService.getSetting(bloggerId);
    mv.addObject("setting", setting);
    return mv;
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) BloggerPicture(com.duan.blogos.entity.blogger.BloggerPicture) BloggerSetting(com.duan.blogos.entity.blogger.BloggerSetting) ModelAndView(org.springframework.web.servlet.ModelAndView) BloggerProfile(com.duan.blogos.entity.blogger.BloggerProfile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with BloggerSetting

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

the class BloggerAccountServiceImpl method insertAccount.

@Override
public int insertAccount(String userName, String password) {
    String shaPwd;
    try {
        // 将密码通过sha的方式保存
        shaPwd = new BigInteger(StringUtils.toSha(password)).toString();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        throw new UnknownInternalException(e);
    }
    BloggerAccount account = new BloggerAccount();
    account.setUsername(userName);
    account.setPassword(shaPwd);
    int effect = accountDao.insert(account);
    if (effect <= 0)
        return -1;
    int bloggerId = account.getId();
    // 生成博主设置数据
    BloggerSetting setting = new BloggerSetting();
    setting.setBloggerId(bloggerId);
    setting.setMainPageNavPos(propertiesManager.getMainPageNavPos());
    settingDao.insert(setting);
    return bloggerId;
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) UnknownInternalException(com.duan.blogos.exception.internal.UnknownInternalException) BloggerSetting(com.duan.blogos.entity.blogger.BloggerSetting) BigInteger(java.math.BigInteger) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 4 with BloggerSetting

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

Aggregations

BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)4 BloggerSetting (com.duan.blogos.entity.blogger.BloggerSetting)4 BloggerProfile (com.duan.blogos.entity.blogger.BloggerProfile)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BloggerPicture (com.duan.blogos.entity.blogger.BloggerPicture)2 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)1 UnknownInternalException (com.duan.blogos.exception.internal.UnknownInternalException)1 BigInteger (java.math.BigInteger)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1