-
Notifications
You must be signed in to change notification settings - Fork 171
[4기 - 황창현] Week2-3 JdbcTemplate을 활용한 바우처 CRUD 기능 구현 #774
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
Changes from 60 commits
15ece18
86816d3
f4aa980
898f2d3
7a0fa27
6fdbded
d578612
2ed58be
3c9ab64
1b660c2
5aea65c
5b0f1ab
a85cc85
dfb345f
36065d5
353ffe3
1fec818
00f3125
7fc19a1
96ca0b2
5d4d001
291c3fe
a7b04d4
a822307
362211a
541e39b
b5d1f7f
c637baa
b87e826
376e76e
7670cdf
7f7b3df
187cd8e
95e8501
a5afc12
6932ea4
8e3ce37
ef13556
067d1a7
3d86778
b74388d
cffd8ee
6eb4633
f12e8e0
bc5afc3
22b9fd0
a2de8e3
06efeff
020a355
80f67ef
10d560b
f5c5a21
866297d
bbbaee9
ad97318
c448834
c0a59ae
f4ae3f5
6ca5617
de8ee99
76bde6c
fe1eecf
410e4c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,65 @@ | ||
# SpringBoot Basic Weekly Mission | ||
|
||
## 📌 과제 설명 | ||
|
||
### **바우처 관리 애플리케이션** | ||
|
||
### 1주차 미션 | ||
|
||
- **기본** | ||
- [x] SpringBoot CLI를 이용해서 프로젝트를 생성한다. | ||
- [x] SpringBoot CLI를 이용해서 프로젝트를 생성한다. | ||
- [x] CLI로 제작한다. | ||
- [x] 스프링 부트 애플리케이션으로 만든다. | ||
- [x] 프로그램이 시작하면 다음과 같이 지원 가능한 명령어를 알려준다. | ||
|
||
``` shell | ||
=== Voucher Program === | ||
Type exit to exit the program. | ||
Type create to create a new voucher. | ||
Type list to list all vouchers. | ||
``` | ||
|
||
- [x] create, list 커맨드를 지원한다. | ||
- [x] create 커맨드를 통해 바우처를 생성할 수 있다.(FixedAmountVoucher, PercentDiscountVoucher) | ||
- [x] list 커맨드를 통해 만들어진 바우처를 조회할 수 있다. | ||
- [x] 바우처 정보를 메모리에 관리한다. | ||
- [x] create 커맨드를 통해 바우처를 생성할 수 있다.(FixedAmountVoucher, PercentDiscountVoucher) | ||
- [x] list 커맨드를 통해 만들어진 바우처를 조회할 수 있다. | ||
- [x] 바우처 정보를 메모리에 관리한다. | ||
- [x] 적절한 로그를 기록하고 logback 설정을해서 에러는 파일로 기록된다. | ||
- [x] 실행가능한 jar 파일을 생성한다. | ||
- **심화** | ||
- [x] 메모리 관리가 아닌 파일로 관리가 되는 Repository 생성 | ||
- [x] 기존 메모리 레파지토리는 지우지 말고 개발 프로파일에서만 동작하게 설정 | ||
- [x] 기존 메모리 레파지토리는 지우지 말고 개발 프로파일에서만 동작하게 설정 | ||
- [x] 고객 블랙 리스트 명단을 작성한다. | ||
- [x] customer_blacklist.csv 파일을 만들고 스프링 애플리케이션에서 해당 파일을 읽을 수 있고 블랙 리스트를 조회 할 수 있다. | ||
- [x] YAML 프로퍼티를 만들고 어떤 설정을 만들 수 있을지 고민해본다. | ||
- [x] customer_blacklist.csv 파일을 만들고 스프링 애플리케이션에서 해당 파일을 읽을 수 있고 블랙 리스트를 조회 할 수 있다. | ||
- [x] YAML 프로퍼티를 만들고 어떤 설정을 만들 수 있을지 고민해본다. | ||
|
||
### 2주차 미션 | ||
|
||
**기본** | ||
|
||
**2-1** | ||
|
||
- [x] 바우처 관리 애플리케이션에 단위테스트를 작성해보세요. | ||
- [x] 가능한 많은 단위 테스트코드를 작성하려고 노력해보세요. | ||
- [x] 엣지 케이스(예외 케이스)를 고려해서 작성해주세요.. | ||
|
||
**2-2** | ||
|
||
- [x] 바우처 관리 애플리케이션에서도 과정에서 다루었던 고객을 적용해보세요. | ||
- [x] customers 테이블 정의 및 추가 | ||
- [x] CustomerRepository 추가 및 JdbcTemplate을 사용해서 구현 | ||
|
||
**2-3** | ||
|
||
- [x] (1주차엔 파일로 관리하게 했다.) 바우처 정보를 DB로 관리해보세요. | ||
- [x] 바우처에 엔터티에 해당하는 vouchers 테이블을 한번 정의해보세요. | ||
- [x] 바우처 레포지토리를 만들어보세요. (JdbcTemplate을 사용해서 구현) | ||
- [x] 기존의 파일에서 바우처를 관리한 것을 vouchers 테이블을 통해서 CRUD가 되게 해보세요. | ||
|
||
**심화** | ||
|
||
**2-4** | ||
|
||
- [ ] 특정 고객에게 바우처를 할당할 수 있습니다. | ||
- [ ] 고객이 어떤 바우처를 보유하고 있는지 조회할 수 있어야 합니다. | ||
- [ ] 고객이 보유한 바우처를 제거할 수 있어야 합니다. | ||
- [ ] 특정 바우처를 보유한 고객을 조회할 수 있어야 합니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.1.0' | ||
id 'io.spring.dependency-management' version '1.1.0' | ||
id 'java' | ||
id 'org.springframework.boot' version '3.1.0' | ||
id 'io.spring.dependency-management' version '1.1.0' | ||
} | ||
|
||
group = 'com.programmers' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
java { | ||
sourceCompatibility = '17' | ||
sourceCompatibility = '17' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
implementation 'org.springframework.boot:spring-boot-starter' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
implementation 'org.springframework.boot:spring-boot-starter-jdbc' | ||
|
||
compileOnly 'org.projectlombok:lombok:1.18.28' | ||
annotationProcessor 'org.projectlombok:lombok:1.18.28' | ||
runtimeOnly 'com.h2database:h2' | ||
|
||
testCompileOnly 'org.projectlombok:lombok:1.18.28' | ||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.28' | ||
compileOnly 'org.projectlombok:lombok:1.18.28' | ||
annotationProcessor 'org.projectlombok:lombok:1.18.28' | ||
|
||
testCompileOnly 'org.projectlombok:lombok:1.18.28' | ||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.28' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,81 @@ | ||||||
package com.programmers.springweekly; | ||||||
|
||||||
import com.programmers.springweekly.controller.CustomerController; | ||||||
import com.programmers.springweekly.domain.CustomerMenu; | ||||||
import com.programmers.springweekly.dto.customer.request.CustomerUpdateRequest; | ||||||
import com.programmers.springweekly.dto.customer.response.CustomerListResponse; | ||||||
import com.programmers.springweekly.view.Console; | ||||||
import java.util.UUID; | ||||||
import lombok.RequiredArgsConstructor; | ||||||
import org.springframework.stereotype.Component; | ||||||
|
||||||
@Component | ||||||
@RequiredArgsConstructor | ||||||
public class ConsoleCustomer { | ||||||
|
||||||
private final CustomerController customerController; | ||||||
private final Console console; | ||||||
|
||||||
public void run() { | ||||||
console.outputCustomerMenuGuide(); | ||||||
CustomerMenu customerMenu = CustomerMenu.from(console.inputMessage()); | ||||||
|
||||||
switch (customerMenu) { | ||||||
case CREATE -> createCustomer(); | ||||||
case UPDATE -> updateCustomer(); | ||||||
case DELETE -> deleteCustomer(); | ||||||
case SELECT -> selectCustomer(); | ||||||
case BLACKLIST -> getBlackList(); | ||||||
default -> throw new IllegalArgumentException("Input :" + customerMenu + "찾으시는 고객 메뉴가 없습니다."); | ||||||
} | ||||||
} | ||||||
|
||||||
private void selectCustomer() { | ||||||
CustomerListResponse customerList = customerController.findAll(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
네이밍에 진심인지라 ㅎ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 이거를 되게 고민을 많이했는데 뭔가 콘솔에서는 명시적으로 customerListResponse보다는 customerList라는 것이 더 이해하기 쉬울 것이라 생각했던 것 같습니다! 다시 생각해보면 요청에 대한 응답 결과를 반환시켜주는거니까 Response가 붙는게 더 자연스럽운 것 같네요! 감사합니다!! 적용 커밋 : 76bde6c |
||||||
|
||||||
if (customerList.getCustomerList().isEmpty()) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 리스트가 비어있는걸 사용할땐 npe에 주의하기위해 유틸을 사용하곤 하는것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. npe도 항상 고려하여 CollectionUtils.isEmpty()를 사용하도록 하겠습니다!! 적용 커밋 : 76bde6c |
||||||
console.outputErrorMessage("고객이 저장되어 있지 않습니다."); | ||||||
return; | ||||||
} | ||||||
|
||||||
console.outputGetCustomerList(customerList); | ||||||
} | ||||||
|
||||||
private void deleteCustomer() { | ||||||
console.outputUUIDGuide(); | ||||||
UUID customerId = console.inputUUID(); | ||||||
|
||||||
customerController.deleteById(customerId); | ||||||
console.outputCompleteGuide(); | ||||||
} | ||||||
|
||||||
private void updateCustomer() { | ||||||
console.outputUUIDGuide(); | ||||||
UUID customerId = console.inputUUID(); | ||||||
|
||||||
console.outputCustomerUpdateGuide(); | ||||||
CustomerUpdateRequest customerUpdateRequest = console.inputCustomerUpdate(customerId); | ||||||
|
||||||
customerController.update(customerUpdateRequest); | ||||||
console.outputCompleteGuide(); | ||||||
} | ||||||
|
||||||
private void createCustomer() { | ||||||
console.outputCustomerCreateGuide(); | ||||||
|
||||||
customerController.save(console.inputCustomerCreate()); | ||||||
console.outputCompleteGuide(); | ||||||
} | ||||||
|
||||||
private void getBlackList() { | ||||||
CustomerListResponse customerBlacklist = customerController.getBlackList(); | ||||||
|
||||||
if (customerBlacklist.getCustomerList().isEmpty()) { | ||||||
console.outputErrorMessage("블랙 리스트인 고객이 없습니다."); | ||||||
return; | ||||||
} | ||||||
|
||||||
console.outputGetCustomerList(customerBlacklist); | ||||||
} | ||||||
|
||||||
} |
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.
콘솔 어플리케이션이라는 클래스에서 직접 적인 실행을 시키므로 말씀하신 대로 menu가 더 어울릴 것 같습니다! 감사합니다!! 👍
적용 커밋 : 76bde6c