-
Notifications
You must be signed in to change notification settings - Fork 7
[Logan] Spring Data JPA 4~6단계 미션 #12
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
Open
yueunfive
wants to merge
45
commits into
yourssu-Lab:logan
Choose a base branch
from
yueunfive:logan-week2
base: logan
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
db45fad
fix: 의존성 충돌 해결
DWL21 d5566d2
feat: 1단계 - 로그인
yueunfive cdffb4f
feat: 2단계 - 로그인 리팩터링
yueunfive 11b44d1
feat: 3단계 - 관리자 기능
yueunfive c6b8613
refactor: resolveArgument 반환 타입 변경
yueunfive c9d4f78
Merge branch 'logan' of https://github.com/yueunfive/java-sprout into…
yueunfive 96b1a20
refactor: 쿠키 유효기간 설정 제거
yueunfive 1ae7379
refactor: RowMapper 변수 분리
yueunfive 1215822
refactor: GlobalExceptionHandler 호출을 위해 상위 @ControllerAdvice 제거
yueunfive 5de5b63
refactor: 예약 생성 로직 수정
yueunfive 15a68e8
refactor: @ExceptionHandler(Exception.class) 추가
yueunfive 9b8ad45
refactor: 예약 생성 로직 수정
yueunfive 3ba6966
refactor: DTO class to record
yueunfive 3dbf00f
feat: 4단계: JPA 전환
yueunfive 901bd5e
feat: 5단계 - 내 예약 목록 조회
yueunfive 9409618
feat: 6단계 - 예약 대기 기능
yueunfive da5e586
refactor: 예약 상태 관리 구조 개선
yueunfive 6ee806a
refactor: dao to repository
yueunfive b058fd2
refactor: merge conflict resolve
yueunfive bddf51d
refactor: remove .DS_Store
yueunfive 4dc79da
refactor: API 변경사항에 맞게 타임리프 JS 수정
yueunfive 8fc5bc8
refactor: Spring Validation 적용
yueunfive 25e7439
refactor: dto 내 정적 팩토리 메서드 추가(+a)
yueunfive e25c043
refactor: 엔티티 기본 생성자 - public to protected
yueunfive 44e36f0
refactor: schema.sql - CREATE문 제거
yueunfive 8ab2938
feat: 예약 취소 기능 구현
yueunfive b487f68
feat: admin 예약 추가 기능 구현
yueunfive e65be6d
feat: admin 예약 목록 조회 기능 구현
yueunfive d8dd999
refactor: admin 페이지 접근 관련 에외 메시지 처리
yueunfive ad56b75
refactor: 예약 삭제 권한 수정
yueunfive d0b4b25
refactor: N+1 해결 with fetch join
yueunfive 05739f8
refactor: 예약 생성시 중복체크
yueunfive df7a4d0
refactor: 이메일 중복 방지 및 형식 검증 기능 추가
yueunfive 335cc99
fix: Time 및 Theme 삭제 시 예외 처리 추가
yueunfive e064a8d
refactor: Member 역할 enum 적용 및 isAdmin 메서드 도입
yueunfive ea79c7f
fix: SQL 초기 데이터와 충돌하지 않도록 테스트 코드 수정
yueunfive 4c3e11e
fix: 예약 없는 슬롯(날짜/시간/테마)에 대한 대기 신청 방지 로직 추가
yueunfive 75b32e6
test: ReservationServiceTest 추가 및 테스트용 DB 분리
yueunfive b4c2c18
test: MemberServiceTest 추가
yueunfive 18dd7a8
test: AuthServiceTest 추가
yueunfive f2e6f8b
test: TimeServiceTest 추가
yueunfive b1e72b8
fix: 시간 중복 저장 방지 로직 추가
yueunfive f3b1434
test: ThemeServiceTest 추가
yueunfive ed6767a
fix: 테마 중복 저장 방지 로직 추가
yueunfive 01ea224
test: 중복 time_value('10:00') 회피를 위해 테스트 데이터 수정
yueunfive File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
src/main/java/com/yourssu/roomescape/auth/AuthService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
package com.yourssu.roomescape.auth; | ||
|
||
import com.yourssu.roomescape.auth.dto.LoginRequest; | ||
import com.yourssu.roomescape.exception.CustomException; | ||
import com.yourssu.roomescape.exception.ErrorCode; | ||
import com.yourssu.roomescape.jwt.TokenProvider; | ||
import com.yourssu.roomescape.member.Member; | ||
import com.yourssu.roomescape.member.MemberDao; | ||
import com.yourssu.roomescape.member.MemberRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class AuthService { | ||
|
||
private final MemberDao memberDao; | ||
private final MemberRepository memberRepository; | ||
private final TokenProvider tokenProvider; | ||
|
||
public AuthService(TokenProvider tokenProvider, MemberDao memberDao) { | ||
public AuthService(TokenProvider tokenProvider, MemberRepository memberRepository) { | ||
this.tokenProvider = tokenProvider; | ||
this.memberDao = memberDao; | ||
this.memberRepository = memberRepository; | ||
} | ||
|
||
public String login(LoginRequest loginRequest) { | ||
Member member = memberDao.findByEmailAndPassword(loginRequest.email(), loginRequest.password()); | ||
Member member = memberRepository.findByEmailAndPassword(loginRequest.email(), loginRequest.password()) | ||
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); | ||
return tokenProvider.createToken(member.getEmail()); | ||
} | ||
|
||
public Member checkLogin(String token) { | ||
String payload = tokenProvider.getPayload(token); | ||
return memberDao.findByEmail(payload); | ||
return memberRepository.findByEmail(payload) | ||
.orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...u/roomescape/auth/CheckLoginResponse.java → ...omescape/auth/dto/CheckLoginResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.yourssu.roomescape.auth; | ||
package com.yourssu.roomescape.auth.dto; | ||
|
||
public record CheckLoginResponse(String name) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...yourssu/roomescape/auth/LoginRequest.java → ...ssu/roomescape/auth/dto/LoginRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.yourssu.roomescape.auth; | ||
package com.yourssu.roomescape.auth.dto; | ||
|
||
public record LoginRequest(String email, String password) { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
src/main/java/com/yourssu/roomescape/member/MemberDao.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/com/yourssu/roomescape/member/MemberRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.yourssu.roomescape.member; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
|
||
Optional<Member> findByEmailAndPassword(String email, String password); | ||
Optional<Member> findByEmail(String email); | ||
Optional<Member> findByName(String name); | ||
boolean existsByEmail(String email); | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/java/com/yourssu/roomescape/member/MemberRequest.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/main/java/com/yourssu/roomescape/member/MemberResponse.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yourssu.roomescape.member; | ||
|
||
public enum MemberRole { | ||
ADMIN, USER | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
토큰을 만들 때 멤버의 email 정보로 만들고 있는데 , 지금 유은님 코드 상으로는 동일한 이메일로 두 개 이상의 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.
해당 부분에서 token에서 추출한 payload(email)가 DB에 중복으로 존재할 경우,
findByEmail()이 2개 이상의 결과를 반환하면서 IncorrectResultSizeDataAccessException 예외가 발생합니다.
👉 이메일 중복 문제가 발생하지 않도록 Member 엔티티의 email 필드에 @column(unique = true)를 적용하여 DB 레벨에서 중복을 방지하고, 회원가입 로직에서는 existsByEmail을 통해 사전 중복 검사를 수행한 뒤, 중복 시 CustomException을 발생시키도록 보완했습니다.