🍕MyPageController.java 클래스
@PostMapping("/secession")
public String secession(@SessionAttribute("loginMember") Member loginMember
,String memberPw
,RedirectAttributes ra
,SessionStatus status
,HttpServletResponse resp){
int memberNo = loginMember.getMemberNo();
int result = service.secession(memberNo, memberPw);
String path = "redirect:";
String message = null;
if(result > 0 ) {
message ="탈퇴 되었습니다.";
path += "/";
status.isComplete();
Cookie cookis = new Cookie("saveId", "");
cookis.setMaxAge(0);
cookis.setPath("/");
resp.addCookie(cookis);
}else {
message = "현재 비밀번호가 일치하지 않습니다.";
path += "secession";
}
ra.addFlashAttribute("message", message);
return path;
}
🍕MyPageService.java 인터페이스
int secession(int memberNo, String memberPw)
🍕MyPageServiceImpl.java 클래스
@Transactional(rollbackFor = {Exception.class})
@Override
public int secession(int memberNo, String memberPw) {
String encPw = dao.selectEncPw(memberNo);
System.out.println(encPw);
if(bcrypt.matches(memberPw,encPw)) {
return dao.secession(memberNo);
}
return 0;
}
🍕MyPageDAO.java 클래스
public int secession(int memberNo) {
return sqlSession.update("myPageMapper.secession", memberNo);
}
🍕myPage-mapper.xml
<update id="secession" parameterType="_int">
UPDATE MEMBER SET MEMBER_DEL_FL='Y' WHERE MEMBER_NO = #{memberNo}
</update>