[4기 - 박세연] SpringBoot Part3 Weekly Mission 제출합니다.#836
Closed
parksey wants to merge 28 commits intoprgrms-be-devcourse:parkseyfrom
Closed
[4기 - 박세연] SpringBoot Part3 Weekly Mission 제출합니다.#836parksey wants to merge 28 commits intoprgrms-be-devcourse:parkseyfrom
parksey wants to merge 28 commits intoprgrms-be-devcourse:parkseyfrom
Conversation
…예외 처리하는 ApiAdvisor클래스 추가
joseph-100
reviewed
Jul 20, 2023
joseph-100
left a comment
There was a problem hiding this comment.
과제 하시느라 고생하셨습니다.
주차 별로 코드가 개선되는 느낌을 받아 좋습니다.
패키지 구성이 api, web, voucher, customer가 동등레벨로 구성되어 있는데 조금 애매한 느낌을 받습니다.
이 부분은 한번 더 고민 해주시고 PR 올려 주세요.
| @@ -11,6 +11,7 @@ | |||
|
|
|||
| @Service | |||
| public class VoucherService { | |||
| } | ||
|
|
||
| @PostMapping("/customer") | ||
| public ResponseEntity<CustomerResponse> create(@RequestBody CustomerCreationRequest creationRequest) { |
There was a problem hiding this comment.
CustomerCreationRequest 유효성 체크는 필요 없을까요?
Author
There was a problem hiding this comment.
말씀듣고 Dto에 대해서도 유효성 검사가 필요할 것 같아 추가하였습니다.
|
|
||
| private final String printMessage; | ||
|
|
||
| private final static Map<String, VoucherMenu> VOUCHER_MENU_MAP; |
Comment on lines
3
to
4
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; |
There was a problem hiding this comment.
미사용 import문은 꼭 지워주세요. 코드를 건든 곳은 습관적으로 최적화 해주면 좋습니다.
| "10,1: 1" | ||
| }, delimiter = ':') | ||
| void 바우처가_이미_존재하면_예외발생(String userInput, String no) { | ||
| void 바우처가_이미_존재하면_예외발생(String userInput, String no) { |
Author
There was a problem hiding this comment.
표현 자체가 적절하지 못했던 것 같습니다. 테스트 메서드 명을 변경하였습니다
There was a problem hiding this comment.
실패하는 테스트가 있습니다.
사용하지 않는 코드는 정리해주세요.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 과제 설명
바우처 서비스 관리 페이지 및 API 개발
👩💻 요구 사항과 구현 내용
(기본) 바우처 서비스 관리페이지 개발하기
(기본) 바우처 서비스의 API 개발하기
추가
[ API 전용 예외 처리 추가 ]
✅ 피드백 반영사항
whiel문의 not이 들어 가는 경우 가독성 저하 -> 변경하여 해결
사용하지 않는 return값 리팩토링
Autowired에 대한 의미 설명
오타 및 수정하지 않는 부분 리팩토링
바우처 값 계산하는 메서드의 내용 설명 추가 (주석)
테스트의 독립성을 유지하기 위해 Order삭제 및 테스트 코드 리팩토링
생성자 내에서 validate를 할 수 있도록 리팩토링
메서드 안의 많은 책임
enum 클래스에 대한 if문을 switch로 변경하여 가독성을 증가
모든 응답 객체를 Response라는 인터페이스로 동일한 동작을 하게 했지만, 오히려 요청시 혼란이 올 수 있기에 리팩토링
find transcation(readOnly=true)추가
자신만의 컨벤션 지키면서 개발
ConditionalOnProperty 설명 추가 : [PR답변]
✅ PR 포인트 & 궁금한 점
[PR 포인트]
계속 지적 받던 클린코드 문제가 아직 많은 것 같습니다. 이 부분부터 고쳐보도록 노력하겠습니다.
Thymeleaf와 RequestDto
[질문]
[현 상황]
여기서
VoucherCreationRequest클래스에서 내부적으로DiscountType enum클래스와VoucherInfoRequest 클래스를 가지고 있습니다.[상황 인식]
Thymeleaf에서 form-data를 통해
VoucherCreationRequest에 데이터를 바인딩을 해야 했습니다. 이때 VoucherInfoRequest에서는 전체 필드 값에 대한 생성자만 있었는데, 해당 생성자를 통한 바인딩이 안되어서기본 생성자를 추가해 줘야 했습니다.
이렇게 사용하다 보니, 로직에서는 사용하지 않는 기본 생성자가 mapping을 위해 사용되게 되는데
이러면
로직에서 의도치 않은 접근이 허용돼서 잘못된 코드를 작성할 수 있겠다라고 생각이 되었습니다.따라서 위의 질문처럼
기본 생성자를 생성하는 것이 올바른 방향인지, 아님 설계를 변경해야 하는 것인지 궁금합니다!*추가
docker폴더 하위에
docker-compose.yml을 넣었습니다!