-
Notifications
You must be signed in to change notification settings - Fork 10
강수빈 2주차 과제 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
강수빈 2주차 과제 #4
Conversation
/** | ||
* 회원 탈퇴 시 회원 정보를 삭제한다. | ||
*/ | ||
@DeleteMapping("/members/{memberId}/delete") | ||
public void deleteMember(@PathVariable Long memberId) { | ||
memberService.deleteMember(memberId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete Method 사용해주시는 부분 RESTful하게 좋습니다.
저도 종종 delete 관련 메소드 짤 때, 아래처럼 짜기도 하는데 아래처럼 짜면 api 형식이 깔끔해져서 좋더라구요. 참고해보시면 좋을 것 같습니다.
/** | |
* 회원 탈퇴 시 회원 정보를 삭제한다. | |
*/ | |
@DeleteMapping("/members/{memberId}/delete") | |
public void deleteMember(@PathVariable Long memberId) { | |
memberService.deleteMember(memberId); | |
} | |
/** | |
* 회원 탈퇴 시 회원 정보를 삭제한다. | |
*/ | |
@DeleteMapping("/members/{memberId}") | |
public void deleteMember(@PathVariable Long memberId) { | |
memberService.deleteMember(memberId); | |
} |
// 이건 좀 어렵네요...답지를 참고했습니다 자동생성으로 알려주긴 한데 없었으면 못 썼을 거 같습니다.... | ||
return AuthLoginResponse.from(member); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 부분은 원래 안 익숙해서 그러실 수 있습니다!!
Effective Java 생성자 대신 Static Factory Method를 사용하자 한번 읽어보시는 거 추천!
// 얘도 답지 없었으면 못 구현했음........... | ||
return member.stream() | ||
.map(MemberResponse::from) | ||
.toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
답지 보더라도 구현해내시느라 고생하셨씁니다 ㅎㅎ..
stream 부분은 나름 최신 문법이라 수업에서도 잘 안다루긴 합니다ㅜ
요 부분 기본으로 구현하는 방법은 문소현님 코드 참고하셔서 확ㅇ니해보시면 좋을 것 같습니다!
// Member member = memberRepository.findById(memberId); | ||
// if (member.isEmpty()) { | ||
// throw new IllegalArgumentException("존재 안함 ㅠㅠ"); | ||
// } | ||
// 이렇게 쓰면 되는데 왜 위처럼 쓰면 안되지ㅣ.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JpaRepository에서 findById는 기본적으로 Optional이라는 형태로 나오게 됩니다. 이 클래스는 isEmpty() 등의 메소드를 가지고 있어서 주석처럼 사용될 수 있습니다. 하지만 Member 클래스는 기본 클래스로 isEmpty() 메소드를 갖고 있지 않습니다!
Java Optional 바르게 쓰기 글 읽어보시면 좋을 것 가탕요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전반적으로 잘 수행해내셨습니다! 고생하셨습니다
로그인 성공 화면
비밀번호 불일치로 로그인 실패 화면