-
Notifications
You must be signed in to change notification settings - Fork 169
[Spring JDBC] 서현진 5,6,7 단계 미션 제출합니다. #525
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
Merged
boorownie
merged 44 commits into
next-step:nonactress
from
nonactress:feature/hyeonjin2
Nov 26, 2025
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
4ea6d0e
feat : 1,2단계 미션 제출
c713260
feat : 1,2단계 미션 제출 및 테스트 코드 수정
460e494
feat : is() 메소드를 위한 import문 추가
c97ea81
refactor : record 적용
d6c310c
feat : service 계층 생성
dcdb9f1
feat : 3단계 제출
a493121
feat : 4단계 제출
f9935e5
fix(dto) : local date, local time 으로 변경
08145b9
feat(repository) : 레포지토리 구현 및 계층 구현
b7fd4b7
Merge branch 'nonactress' into nonactress
nonactress b3d2c0b
fix : 개행 정리
1ea9e34
Merge branch 'nonactress' of https://github.com/nonactress/spring-roo…
2bc21d8
fix : 개행 정리
34ccc63
fix : DAO 사용 및 레포지토리 리팩토링
efff5e4
refactor : 레포지토리에 맞게 서비스 로직 리팩토링
00a0ae5
feat : 7단계 테스트
8c4503c
fix : post 중복 예외처리
043923b
feat : 스키마 멱등성 키 생성
034ede1
refactor : 멱등성 키를 위한 addReservation
f83d52e
refactor : dto 내부에서 엔티티로 변환 메소드 추가
b710148
refactor : Reservation 정적 팩토리 메소드 적용
88e93be
refactor : 헤더에 멱등성 키가 없어서 리팩토링
841ade6
fix : 개행 정리
2a5c805
refactor : 레포지토리를 서비스에 연결
20d0881
delete : 안쓰는 dto 삭제
b6887e0
refactor : localtime,date를 위한 dto 변환
675e113
refactor : localtime,date를 위한 레포지토리 변환
9934f11
refactor : localtime,date를 위한 어노테이션 변경(notBlank->notNull)
9b0add5
refactor : 개형정리
1422774
refactor : 개형정리2
d8f03be
refactor : LocalTime,LoaclDate로 변환
da52598
feat : READ.ME
ec7292a
feat : 실패 데이터 테스트 코드
242a374
feat : 성공 데이터 테스트 코드
568a051
feat : 멱등성 키 헤더에서 강요
3b5d63c
feat : simpleJdbcInsert 생성
457f630
feat : 예외 처리 패키지 생성
9834efd
feat : 동시성 문제 해결
5701129
feat : 개행정리
754903b
feat : 테스트 코드에 멱등성 키 헤더 추가
a271a5f
feat : 멱등성 키 중복 && body가 다른 경우 예외 처리 로직 생성
646800d
현재 작업 내용 저장
0c45865
충돌 해결 완료
1b9bc17
정리 제발!
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package roomescape.advice; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public enum ErrorCode { | ||
| // 1. 공통 에러 | ||
| INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "COMMON-001", "잘못된 입력값입니다."), | ||
|
|
||
| // 2. 비즈니스 에러 | ||
| DUPLICATE_DATA(HttpStatus.CONFLICT, "BIZ-001", "이미 처리된 요청이거나 중복된 데이터입니다."), | ||
| IDEMPOTENCY_KEY_MISMATCH(HttpStatus.BAD_REQUEST, "BIZ-002", "멱등성 키 불일치: 요청 내용이 다릅니다."); | ||
|
|
||
| private final HttpStatus httpStatus; | ||
| private final String code; | ||
| private final String message; | ||
|
|
||
| public HttpStatus getHttpStatus() { | ||
| return httpStatus; | ||
| } | ||
|
|
||
| public String getCode() { | ||
| return code; | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return message; | ||
| } | ||
|
|
||
| ErrorCode(HttpStatus httpStatus, String code, String message) { | ||
| this.httpStatus = httpStatus; | ||
| this.code = code; | ||
| this.message = message; | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...pe/controller/GlobalExceptionHandler.java → ...escape/advice/GlobalExceptionHandler.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
16 changes: 16 additions & 0 deletions
16
src/main/java/roomescape/advice/IdempotencyKeyMismatchException.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,16 @@ | ||
| package roomescape.advice; | ||
|
|
||
| public class IdempotencyKeyMismatchException extends RuntimeException { | ||
|
|
||
| private final ErrorCode errorCode; | ||
|
|
||
| public IdempotencyKeyMismatchException() { | ||
| super(ErrorCode.IDEMPOTENCY_KEY_MISMATCH.getMessage()); | ||
| this.errorCode = ErrorCode.IDEMPOTENCY_KEY_MISMATCH; | ||
| } | ||
|
|
||
| public ErrorCode getErrorCode() { | ||
| return errorCode; | ||
| } | ||
| } | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package roomescape.dto; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import roomescape.advice.ErrorCode; | ||
|
|
||
| public class ErrorResponse { | ||
| private final String code; | ||
| private final String message; | ||
|
|
||
| // 핵심: ErrorCode Enum만 던져주면 알아서 ResponseEntity를 만들어줌! | ||
| public static ResponseEntity<ErrorResponse> toResponseEntity(ErrorCode errorCode) { | ||
| return ResponseEntity | ||
| .status(errorCode.getHttpStatus()) | ||
| .body(new ErrorResponse(errorCode.getCode(),errorCode.getMessage())); | ||
| } | ||
|
|
||
| public ErrorResponse(String code, String message) { | ||
| this.code = code; | ||
| this.message = message; | ||
| } | ||
| } |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/roomescape/repository/IdempotencyRepository.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,42 @@ | ||
| package roomescape.repository; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.dao.EmptyResultDataAccessException; | ||
| import org.springframework.jdbc.core.JdbcTemplate; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public class IdempotencyRepository { | ||
| private final JdbcTemplate jdbcTemplate; | ||
|
|
||
| @Autowired | ||
| public IdempotencyRepository(JdbcTemplate jdbcTemplate) { | ||
| this.jdbcTemplate = jdbcTemplate; | ||
| } | ||
|
|
||
| public boolean exists(String key) { | ||
| String sql = "SELECT count(*) FROM idempotency_keys WHERE id = ?"; | ||
| Integer count = jdbcTemplate.queryForObject(sql, Integer.class, key); | ||
| return count != null && count > 0; | ||
| } | ||
|
|
||
| public void save(String key) { | ||
| String sql = "INSERT INTO idempotency_keys (id) VALUES (?)"; | ||
| jdbcTemplate.update(sql, key); | ||
| } | ||
|
|
||
| public Long getReservationId(String key) { | ||
| try { | ||
| String sql = "SELECT reservation_id FROM idempotency_keys WHERE id = ?"; | ||
| return jdbcTemplate.queryForObject(sql, Long.class, key); | ||
| } catch (EmptyResultDataAccessException e) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| public void save(String key, Long reservationId) { | ||
| String sql = "INSERT INTO idempotency_keys (id, reservation_id) VALUES (?, ?)"; | ||
| jdbcTemplate.update(sql, key, reservationId); | ||
| } | ||
|
|
||
| } |
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.
controller 폴더에 있는건 따로 의도하신바가 있으실까요??
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.
의도한 바는 없습니다!!
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.
그렇다면 적절한 위치는 어디가 좋을까요??
전역에서 발생하는 예외를 처리하는 공통 관심사이기 때문에, 컨트롤러 보다 좋은 위치가 있지 않을까 싶어요.
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.
아아 제가 컨트롤러 폴더의 유무의 필요성에 대해 리뷰 남겨 주신 내용으로 잘못 이해한 것 같습니다.
GlobalExceptionHandler의 경우엔 당연히 controller 폴더에 있으면 안된다고 생각합니다.Advice폴더를 생성하여 위치 시켜보도록 하겠습니다!
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.
457f630
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.
Advice네이밍보다 좋은게 있을 것 같아요! 일반적인 케이스를 한번 찾아보면 더 도움이 될 것 같습니다~~