Search in sources :

Example 6 with Member

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

the class MemberFindByIdService method findById.

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

Example 7 with Member

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

the class MemberLoginService method login.

@Transactional
public Member login(LoginRequest req) {
    dao = sqlSessionTemplate.getMapper(MemberDao2.class);
    Member member = dao.selectByEmail(req.getEmail());
    if (member == null) {
        throw new MemberNotFoundException("회원 없음 : " + req.getEmail());
    }
    if (!member.checkPassword(req.getPassword())) {
        throw new IdPasswordNotMatchingException("비밀번호 다름");
    }
    return member;
}
Also used : MemberDao2(com.bitcamp.mvc.dao.MemberDao2) Member(com.bitcamp.mvc.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Member

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

the class MemberRegisterController method submit.

@RequestMapping(method = RequestMethod.POST)
public String submit(RegisterRequest registerRequest, BindingResult bindingResult, RedirectAttributes redirectAttributes, HttpServletRequest request) throws Exception {
    if (bindingResult.hasErrors()) {
        List<ObjectError> list = bindingResult.getAllErrors();
        for (ObjectError e : list) {
            logger.error("ObjectError : " + e);
        }
        throw new Exception("회원가입 실패");
    }
    // 업로드 폴더 시스템 물리적 경로 찾기
    String uploadURI = "/uploadfile/memberphoto";
    String dir = request.getSession().getServletContext().getRealPath(uploadURI);
    // 업로드 파일의 물리적 저장
    if (!registerRequest.getPhotofile().isEmpty()) {
        registerRequest.getPhotofile().transferTo(new File(dir, registerRequest.getEmail()));
        registerRequest.setPhoto(registerRequest.getEmail());
    }
    Member member = memberRegisterService.register(registerRequest);
    // 가입 축하 메일 전송
    mailHelper.sendMail(member);
    redirectAttributes.addFlashAttribute("SUCCESS_MSG", "회원가입 성공");
    return "redirect:/member/login";
}
Also used : ObjectError(org.springframework.validation.ObjectError) File(java.io.File) Member(com.bitcamp.mvc.model.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Member

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

the class MemberMyPageController method viewById.

// @PathVariable : 경로의 특정 위치 값이 고정되지 않고 달라질 때 사용하는 것
@RequestMapping(value = "/member/mypage/{id}", method = RequestMethod.GET)
public String viewById(@PathVariable("id") Long memId, Model model) {
    Member member = memberFindByIdService.findById(memId);
    model.addAttribute("loginInfo", member);
    return "member/myPage";
}
Also used : Member(com.bitcamp.mvc.model.Member) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Member

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

the class MemberRegisterService method register.

@Transactional
public Member register(RegisterRequest req) {
    dao = sqlSessionTemplate.getMapper(MemberDao2.class);
    Member member = dao.selectByEmail(req.getEmail());
    if (member != null) {
        throw new AlreadyExistingMemberException("이메일 중복 : " + req.getEmail());
    }
    member = req.toMember();
    dao.insertMember(member);
    return member;
}
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