Search in sources :

Example 1 with Member

use of com.bitcamp.mvc.model.Member in project bitcampSCOpen2017 by ryuyj.

the class MemberListXmlController method getMemberListXml.

private MemberListXml getMemberListXml() {
    List<MemberXml> memberListXml = new ArrayList<MemberXml>();
    List<Member> memberList = memberListService.selectAll();
    for (Member member : memberList) {
        memberListXml.add(new MemberXml(member.getId(), member.getEmail(), member.getName(), member.getRegisterDate()));
    }
    return new MemberListXml(memberListXml);
}
Also used : ArrayList(java.util.ArrayList) MemberListXml(com.bitcamp.mvc.model.MemberListXml) Member(com.bitcamp.mvc.model.Member) MemberXml(com.bitcamp.mvc.model.MemberXml)

Example 2 with Member

use of com.bitcamp.mvc.model.Member in project bitcampSCOpen2017 by ryuyj.

the class MemberLoginController method submit.

@RequestMapping(method = RequestMethod.POST)
public String submit(LoginRequest loginRequest, BindingResult bindingResult, HttpSession session, HttpServletResponse response, RedirectAttributes redirectAttributes) throws Exception {
    if (bindingResult.hasErrors()) {
        List<ObjectError> list = bindingResult.getAllErrors();
        for (ObjectError e : list) {
            logger.error("ObjectError : " + e);
        }
        throw new Exception("로그인 실패");
    }
    Member member = memberLoginService.login(loginRequest);
    if (loginRequest.getSaveEmail() != null) {
        // 이메일 저장시 쿠키 생성
        Cookie cookie = new Cookie("SAVEEMAIL", member.getEmail());
        cookie.setMaxAge(60 * 60);
        response.addCookie(cookie);
    } else {
        // 이메일 저장 아닐시엔 쿠키 삭제
        Cookie cookie = new Cookie("SAVEEMAIL", "");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }
    session.setAttribute("MEMBER", member.getEmail());
    // 확인용 로그 출력
    logger.info(member.toString());
    redirectAttributes.addFlashAttribute("SUCCESS_MSG", "로그인 성공");
    return "redirect:/";
}
Also used : Cookie(javax.servlet.http.Cookie) ObjectError(org.springframework.validation.ObjectError) Member(com.bitcamp.mvc.model.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Member

use of com.bitcamp.mvc.model.Member in project bitcampSCOpen2017 by ryuyj.

the class MemberMyPageController method view.

@RequestMapping(value = "/member/mypage", method = RequestMethod.GET)
public String view(Model model, HttpSession session) {
    String email = (String) session.getAttribute("MEMBER");
    Member member = memberFindByEmailService.findByEmail(email);
    model.addAttribute("loginInfo", member);
    return "member/myPage";
}
Also used : Member(com.bitcamp.mvc.model.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Member

use of com.bitcamp.mvc.model.Member in project bitcampSCOpen2017 by ryuyj.

the class MemberFindByEmailService method findByEmail.

@Transactional
public Member findByEmail(String email) {
    dao = sqlSessionTemplate.getMapper(MemberDao2.class);
    Member member = dao.selectByEmail(email);
    if (member == null) {
        throw new MemberNotFoundException("회원 없음 : " + email);
    }
    return member;
}
Also used : MemberDao2(com.bitcamp.mvc.dao.MemberDao2) Member(com.bitcamp.mvc.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Member

use of com.bitcamp.mvc.model.Member in project bitcampSCOpen2017 by ryuyj.

the class MemberDeleteService method delete.

@Transactional
public String delete(Long id) {
    dao = sqlSessionTemplate.getMapper(MemberDao2.class);
    Member member = dao.selectById(id);
    if (member == null) {
        throw new MemberNotFoundException("회원 없음 : " + id);
    }
    dao.deleteMember(id);
    return member.getPhoto();
}
Also used : MemberDao2(com.bitcamp.mvc.dao.MemberDao2) Member(com.bitcamp.mvc.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Member (com.bitcamp.mvc.model.Member)15 MemberDao2 (com.bitcamp.mvc.dao.MemberDao2)6 Transactional (org.springframework.transaction.annotation.Transactional)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 File (java.io.File)2 ObjectError (org.springframework.validation.ObjectError)2 MemberListXml (com.bitcamp.mvc.model.MemberListXml)1 MemberXml (com.bitcamp.mvc.model.MemberXml)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Cookie (javax.servlet.http.Cookie)1 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)1