-
Notifications
You must be signed in to change notification settings - Fork 171
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
[5기 - 이세희] SpringBoot Part3 Weekly Mission 제출합니다. #965
base: Sehee-Lee-01/week3
Are you sure you want to change the base?
[5기 - 이세희] SpringBoot Part3 Weekly Mission 제출합니다. #965
Conversation
This reverts commit 35919e3.
…oucherRestController
return false; | ||
} | ||
|
||
if (menu.isIncorrect()) { |
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.
valid한 메뉴인지를 판단하는 function에서 Exit를 고르는것이 valid한 선택이고 Incorrect를 고르는게 invalid한 선택이 아닐까요?? incorrect일 때 false를 반환하는 것이 이해하기 어색하지 않을 것 같습니다!
} | ||
|
||
public Customer(String name, boolean black) { | ||
if (name == null || name.isBlank() || name.length() > 20) |
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.
validation을 메서드로 분리하면 좋을 것 같습니다.
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.
넵! 반영하겠습니다! 감사합니다ㅠㅠㅠ
public class Constant { | ||
public static final String LINE_SEPARATOR = System.lineSeparator(); | ||
public static final String COMMA_SEPARATOR = ", "; | ||
public static final int UPDATE_ONE_FLAG = 1; |
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.
1이 의미하는 바가 잘 담겨있지 않은 네이밍 인 것 같습니다. 1이 update에서 성공했다는 의미라면 그런 부분을 잘 담은 네이밍을 하는 것이 가독 측면에서 더 좋을 것 같습니다.
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.
넵! 좀 더 의미를 담도록 반영하겠습니다!
@@ -0,0 +1,20 @@ | |||
package com.programmers.vouchermanagement.util; | |||
|
|||
public class Message { |
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.
exception에 관란 메시지만 모아놓은 클래스라면 좀 더 자세한 클래스명을 쓰면 더 이해하기 좋을 것 같습니다.
return voucherService.update(voucherId, createVoucherRequest); | ||
} | ||
|
||
@GetMapping("/created-at") |
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.
query string을 이용한다면 /created-at path 없이 readAll에서도 구현할 수 있지 않을까 생각합니다.
return voucherService.readAllByCreatedAt(fromDateTime, toDateTime); | ||
} | ||
|
||
@GetMapping("type/{type}") |
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.
#965 (comment)
위의 피드백과 함께 반영하겠습니다!
return "redirect:/vouchers"; | ||
} | ||
|
||
@PutMapping("/update/{voucherId}") |
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.
update와 같은 동사가 path에 들어가지 않는 것이 더 좋을 것 같습니다.
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.
맞습니다ㅠㅠㅠ 네이밍을 어떻게 할까 고민하다가 마감이 얼마 안남아서 급하게 작성했습니다...
이 부분도 반영하겠습니다!
@Transactional(readOnly = true) | ||
public List<VoucherResponse> readAllVoucherByCustomerId(UUID customerId) { | ||
List<Voucher> vouchers = walletRepository.findAllVoucherByCustomerId(customerId); | ||
if (vouchers.isEmpty()) return Collections.emptyList(); |
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.
들여쓰기가 있으면 더 좋을 것 같습니다.
@Transactional(readOnly = true) | ||
public CustomerResponse readCustomerByVoucherId(UUID voucherId) { | ||
Optional<Customer> customerOptional = walletRepository.findCustomerByVoucherId(voucherId); | ||
Customer customer = customerOptional.orElseThrow(() -> { |
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.
해당 로직은 one line으로 써도 디미터 법칙을 위반하지 않을 것 같습니다!! 디미터 법칙은 내부 구조가 외부로 노출되지 않는다면 위반하지 않습니다!!
✅ 3 주차 코드 리뷰 반영 사항 (진행중)
CustomerThymeleafControllerTest.java
VoucherThymeleafControllerTest.java
@RestController
적용하기.ResponseEntity
적용하기. + 상태 코드 반영@Transactional(readOnly=true)
는 왜 쓰는지 알아보기.(아래에 간단하게 메모해놓겠습니다!)@Transactional(readOnly=true)
를 붙여도 안붙여도 겉으로 보여지는 기능은 비슷하게 작동한다.@ExceptionHandler
)추가 수정 사항
@Validate
적용📌 과제 설명
심화 기능은 구현하지 못하고 기본 기능만 구현했습니다!
3주차 과제 범위
ec5f94d7d411b2a23c051b2fbc2faf3cbaf328d0
) 부터 시작입니다!Profile 종류
thyme
,api
,jdbc
설정해주시면 3 주차 과제 구현 기능 확인이 가능합니다!thyme
: thymeleaf 반환하는 컨트롤러 작동console
: console 컨트롤러 작동api
: api 컨트롤러 작동memory
: VoucherInMemoryRepository작동file
: VoucherFileRepository 작동jdbc
: VoucherJDBCRepository작동👩💻 요구 사항과 구현 내용
(기본) 바우처 서비스 관리페이지 개발하기
GET /vouchers
GET /vouchers/{voucherId}
GET /vouchers/new
POST /vouchers/new
DELETE /vouchers/{voucherId}
GET /customers
GET /customers/blacklist
GET /customers/new
POST /customers/new
(기본) 바우처 서비스의 API 개발하기
Spring MVC를 적용해보세요.
바우처
GET /api/v1/vouchers
GET /api/v1/vouchers/created-at?from={YYYY-mm-dd}&to={YYYY-mm-dd}
GET /api/v1/vouchers/type/{type}
POST /api/v1/vouchers
DELETE /api/v1/vouchers/{voucherId}
GET /api/v1/vouchers/{voucherId}
고객
GET /api/v1/customers
GET /api/v1/customers/blacklist
POST /api/v1/customers
JSON과 XML을 지원하는 REST API를 개발해보세요.
(보너스) 바우처 지갑용 관리 페이지를 만들어보세요.
src/main/java/com/programmers/vouchermanagement/wallet
에 잠시 구현한 것은 있지만 안보셔도 됩니다!✅ 피드백 반영사항
✅ PR 포인트 & 궁금한 점
✅ 실행환경 및 방법
실행 환경(JDK)
Docker MySQL DB Server(애플리케이션, 테스트 코드 모두 사용) 연결 방법
haileylee/sehee_mysql:latest
(docker hub에 올렸습니다!)인텔리제이에 아래 정보로 DB 연결
src/main/resources/application.yaml
에 DataSource 설정src/main/resources/schema.sql
에서 sql 쿼리 전체 실행🚨⭐ 혹시 위 도커 이미지로 DB 서버가 실행이 잘 안된다면, 보통의 mySQL 서버에서도 실행 가능합니다!
아래 두 Config 클래스에서 DataSource 설정만 바꿔주신 후,
src/main/resources/schema.sql
에서 sql 쿼리 전체 실행해주시면 감사하겠습니다!애플리케이션 실행
thyme, api, jdbc
) 설정USER=root;PASSWORD=20231028
설정(입력란이 보이지 않는다면 위 사진에서 Modify Options를 눌러주고 환경변수 선택해주시면 됩니다!)src/main/java/com/programmers/vouchermanagement/VoucherManagementApplication.java
에서 main 메서드 실행어플리케이션 테스트 진행
USER=root;PASSWORD=20231028
설정(입력란이 보이지 않는다면 위 사진에서 Modify Options를 눌러주고 환경변수 선택해주시면 됩니다!)