[4기 - 유원우] SpringBoot Part3 Weekly Mission 제출합니다. #864
Open
wonu606 wants to merge 37 commits intoprgrms-be-devcourse:wonu606from
Open
[4기 - 유원우] SpringBoot Part3 Weekly Mission 제출합니다. #864wonu606 wants to merge 37 commits intoprgrms-be-devcourse:wonu606from
wonu606 wants to merge 37 commits intoprgrms-be-devcourse:wonu606from
Conversation
devYSK
requested changes
Jul 29, 2023
|
|
||
| public CustomerController(CustomerService service) { | ||
| this.service = service; | ||
| converterManager = new CustomerControllerConverterManager(); |
Comment on lines
+55
to
+58
| List<CustomerResult> results = service.getCustomerList(); | ||
| List<CustomerResponse> responses = results.stream() | ||
| .map(rs -> converterManager.convert(rs, CustomerResponse.class)) | ||
| .collect(Collectors.toList()); |
Comment on lines
+9
to
+20
| private final List<TypedConverter<?, ?>> converterList; | ||
|
|
||
| public CustomerControllerConverterManager() { | ||
| converterList = new ArrayList<>(); | ||
| converterList.add(new CustomerCreateParamConverter()); | ||
| converterList.add(new CustomerCreateResponseConverter()); | ||
| converterList.add(new CustomerResponseConverter()); | ||
| converterList.add(new OwnedVouchersParamConverter()); | ||
| converterList.add(new OwnedVoucherResponseConverter()); | ||
| converterList.add(new WalletDeleteParamConverter()); | ||
| converterList.add(new WalletRegisterParamConverter()); | ||
| } |
There was a problem hiding this comment.
DTO가 늘어나거나 삭제될때마다 이 코드도 수정해야 할것같아요.
1:1로 메소드로 맵핑하면 어떨까요?
Comment on lines
+62
to
+87
| @PostMapping("/owned-vouchers") | ||
| public ResponseEntity<List<OwnedVoucherResponse>> getOwnedVouchersByCustomer( | ||
| @RequestBody OwnedVouchersRequest request) { | ||
| OwnedVouchersParam param = converterManager.convert(request, OwnedVouchersParam.class); | ||
| List<OwnedVoucherResult> results = service.findOwnedVouchersByCustomer(param); | ||
|
|
||
| List<OwnedVoucherResponse> responses = results.stream() | ||
| .map(rs -> converterManager.convert(rs, OwnedVoucherResponse.class)) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| return new ResponseEntity<>(responses, HttpStatus.OK); | ||
| } | ||
|
|
||
| @PostMapping("/wallet/delete") | ||
| public ResponseEntity<Void> deleteWallet(@RequestBody WalletDeleteRequest request) { | ||
| WalletDeleteParam param = converterManager.convert(request, WalletDeleteParam.class); | ||
| service.deleteWallet(param); | ||
| return new ResponseEntity<>(HttpStatus.OK); | ||
| } | ||
|
|
||
| @PostMapping("/wallet/register") | ||
| public ResponseEntity<Void> registerToWallet(@RequestBody WalletRegisterRequest request) { | ||
| WalletRegisterParam param = converterManager.convert(request, WalletRegisterParam.class); | ||
| service.registerToWallet(param); | ||
| return new ResponseEntity<>(HttpStatus.CREATED); | ||
| } |
| @@ -0,0 +1,20 @@ | |||
| package com.wonu606.vouchermanager.controller.customer.response; | |||
|
|
|||
| public class CustomerResponse { | |||
Comment on lines
+10
to
+13
| this.uuid = uuid; | ||
| Type = type; | ||
| this.value = value; | ||
| } |
| @Transactional | ||
| public class CustomerJdbcRepository implements CustomerRepository { | ||
|
|
||
| CustomerReader reader; |
Comment on lines
+27
to
+34
|
|
||
| @Override | ||
| public void deleteByCustomerId(String email) { | ||
| String deletionSql = "DELETE FROM customer WHERE email = :email"; | ||
| Map<String, Object> params = new HashMap<>(); | ||
| params.put("email", email); | ||
| namedParameterJdbcTemplate.update(deletionSql, params); | ||
| } |
Comment on lines
+19
to
+20
| VoucherReader reader; | ||
| VoucherStore store; |
Comment on lines
+10
to
+13
| @Override | ||
| public OwnedCustomerResultSet mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| return new OwnedCustomerResultSet(rs.getString("customer_id")); | ||
| } |
|
안녕하세요 원우님 과제하느냐 고생많으셨습니다.
관점의 차이인데 개인적으로는 둘이 일치해서 같은 걸 사용하면 단점이 생길 수 있다고 생각해요. |
WooSungHwan
approved these changes
Jul 30, 2023
WooSungHwan
left a comment
There was a problem hiding this comment.
원우님 바우처 과제하시느라 수고 많으셨습니다. 끝까지 성실하게 마무리해주셔서 감사드리고 다음에는 바우처 과제에서 아쉬웠던 점과 좋았던 점을 보완하고 다음과제에서 더 좋은 모습으로 만나요~
| converterManager = new CustomerControllerConverterManager(); | ||
| } | ||
|
|
||
| @PostMapping("/create") |
Comment on lines
+15
to
+21
| public Class<OwnedVouchersRequest> getSourceType() { | ||
| return OwnedVouchersRequest.class; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<OwnedVouchersParam> getTargetType() { | ||
| return OwnedVouchersParam.class; |
There was a problem hiding this comment.
추후엔 이렇게 .class를 호출해서 Class 타입을 처리하는 리플렉션을 이용한 방법보단 쉬운 방법을 택해보시죠.
| import org.springframework.web.bind.annotation.RequestMapping; | ||
|
|
||
| @Controller | ||
| @RequestMapping("vouchers") |
There was a problem hiding this comment.
/vouchers
스프링이 알아서 붙여주긴할텐데. 어딘 붙고 어딘 안붙으면 안돼요.
Comment on lines
+10
to
+13
| this.uuid = uuid; | ||
| Type = type; | ||
| this.value = value; | ||
| } |
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.
📌 과제 설명
로직
데이터베이스 설계
👩💻 요구 사항과 구현 내용
✅ PR 포인트 & 궁금한 점
분할하니 의미 없는 convert만 처리하여 넘겨준다고 느껴졌습니다.
2 계층을 1개의 계층이라 보고 묶어도 괜찮을까요?
Reader가 뱉는 DTO가 일치하고, Store가 뱉는 DTO가 일치한다는 것을 알 수 있었습니다.
이 경우도 Reader와 Store를 나누는 것 중 이점이라고 볼 수 있을까요? 아니면 프로젝트가 작아서 생기는 우연인지 궁금합니다.