Search in sources :

Example 16 with BloggerAccount

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

Example 17 with BloggerAccount

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

the class BloggerLoginController method loginWithPhoneNumber.

@RequestMapping(value = "/way=phone", method = RequestMethod.POST)
public ResultBean loginWithPhoneNumber(HttpServletRequest request, @RequestParam("phone") String phone) {
    handlePhoneCheck(phone, request);
    BloggerAccount account = accountService.getAccountByPhone(phone);
    if (account == null)
        return new ResultBean<>("", ResultBean.FAIL);
    HttpSession session = request.getSession();
    session.setAttribute(bloggerProperties.getSessionNameOfBloggerId(), account.getId());
    session.setAttribute(bloggerProperties.getSessionNameOfBloggerName(), account.getUsername());
    session.setAttribute(bloggerProperties.getSessionBloggerLoginSignal(), "login");
    // 成功登录
    return new ResultBean<>(account.getUsername());
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) HttpSession(javax.servlet.http.HttpSession) ResultBean(com.duan.blogos.restful.ResultBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with BloggerAccount

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

the class BloggerLoginController method loginWithUserName.

@RequestMapping(value = "/way=name", method = RequestMethod.POST)
public ResultBean loginWithUserName(HttpServletRequest request, @RequestParam("username") String userName, @RequestParam("password") String password) throws NoSuchAlgorithmException {
    // TODO 使用shiro
    BloggerAccount account = accountService.getAccount(userName);
    if (account != null && account.getUsername().equals(userName) && account.getPassword().equals(new BigInteger(StringUtils.toSha(password)).toString())) {
        HttpSession session = request.getSession();
        session.setAttribute(bloggerProperties.getSessionNameOfBloggerId(), account.getId());
        session.setAttribute(bloggerProperties.getSessionNameOfBloggerName(), account.getUsername());
        session.setAttribute(bloggerProperties.getSessionBloggerLoginSignal(), "login");
        // 成功登录
        return new ResultBean<>("");
    } else {
        // TODO 判断登录失败的原因
        String errorMsg = messageManager.getLoginFailMessage(new RequestContext(request), false);
        request.getServletContext().setAttribute(bloggerProperties.getSessionNameOfErrorMsg(), errorMsg);
        return new ResultBean(exceptionManager.getLoginFailException(new RequestContext(request), false));
    }
}
Also used : BloggerAccount(com.duan.blogos.entity.blogger.BloggerAccount) HttpSession(javax.servlet.http.HttpSession) BigInteger(java.math.BigInteger) RequestContext(org.springframework.web.servlet.support.RequestContext) ResultBean(com.duan.blogos.restful.ResultBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BloggerAccount (com.duan.blogos.entity.blogger.BloggerAccount)18 BloggerProfile (com.duan.blogos.entity.blogger.BloggerProfile)6 ResultBean (com.duan.blogos.restful.ResultBean)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 BloggerDTO (com.duan.blogos.dto.blogger.BloggerDTO)4 BloggerPicture (com.duan.blogos.entity.blogger.BloggerPicture)4 BloggerStatisticsDTO (com.duan.blogos.dto.blogger.BloggerStatisticsDTO)3 BloggerSetting (com.duan.blogos.entity.blogger.BloggerSetting)3 File (java.io.File)3 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 MultipartFile (org.springframework.web.multipart.MultipartFile)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BlogListItemDTO (com.duan.blogos.dto.blog.BlogListItemDTO)2 FavouriteBlogListItemDTO (com.duan.blogos.dto.blogger.FavouriteBlogListItemDTO)2 UnknownInternalException (com.duan.blogos.exception.internal.UnknownInternalException)2 BlogListItemComparatorFactory (com.duan.blogos.manager.comparator.BlogListItemComparatorFactory)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HashMap (java.util.HashMap)2 HttpSession (javax.servlet.http.HttpSession)2