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;
}
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;
}
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;
}
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;
}
Aggregations