[2기-C] 정다현 SpringBoot Part1 Weekly Mission 제출합니다.#218
[2기-C] 정다현 SpringBoot Part1 Weekly Mission 제출합니다.#218ksy90101 merged 14 commits intoprgrms-be-devcourse:mainfrom
Conversation
build.gradle
Outdated
|
|
||
| group = 'org.prgrms' | ||
| version = '0.0.1-SNAPSHOT' | ||
| sourceCompatibility = '16' |
| jar { | ||
| manifest { | ||
| attributes 'Main-Class': 'org.prgrms.springbootbasic.CommandLineApplication' | ||
| } | ||
| from { | ||
| configurations.runtimeClasspath.collect { | ||
| it.isDirectory() ? it : zipTree(it) | ||
| } | ||
| } | ||
| duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
| } |
There was a problem hiding this comment.
gradle에서는 jar 파일을 생성하기 위해서 해당 코드가 필요해서 추가하였습니다.
There was a problem hiding this comment.
없어도 jar 파일이 만들어 지긴 하는데, 제가 의도한 대로 동작하지 않습니다. 제가 따로 콘솔용으로 클래스를 만들고 해당 클래스를 동작시키기 위해 해당 설정을 했습니다. 해당 설정을 통해서 어떤 main 클래스를 사용할 것이고, 그리고 의존하는 라이브러리도 같이 묶어주었습니다.
| import java.util.UUID; | ||
|
|
||
|
|
||
| public class CommandLineApplication { |
There was a problem hiding this comment.
| import java.util.UUID; | |
| public class CommandLineApplication { | |
| import java.util.UUID; | |
| public class CommandLineApplication { |
| public static final String AVAILABLE_COMMANDS = "=== Voucher Program ===\nType exit to exit the program.\nType create to create a new voucher.\nType list to list all vouchers.\n"; | ||
| public static final String AVAILABLE_VOUCHERS = "Which type do you want, FixedAmountVoucher(Fixed) or PercentDiscountVoucher(Percent)?"; | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
여기에서는 단순히 애플리케이션을 실행하는 run메서드 하나만 넣어주세요.
지금 view와 로직이 엄청 섞여있네요.
view도 모두 다 분리해주세요.
There was a problem hiding this comment.
console 패키지를 따로 만들어서 뷰 관련한 코드를 넣었고 voucherService에는 로직이 실행되도록 하였습니다
| public Voucher getVoucher(UUID voucherId) { | ||
| return voucherRepository | ||
| .findById(voucherId) | ||
| .orElseThrow(() -> new RuntimeException(MessageFormat.format("Can not find a voucher for {0}", voucherId))); |
There was a problem hiding this comment.
과연 RuntimeException이 맞을까요?
좀 더 의미잇는 메서드를 사용해주세요.
There was a problem hiding this comment.
해당 메서드는 이번 과제에서 사용하는 메서드가 아니라서 삭제했습니다
| StringBuffer stringBuffer = new StringBuffer(); | ||
|
|
||
| for(UUID voucherId :storage.keySet()) { | ||
| stringBuffer.append(storage.get(voucherId).toString() + "\n"); |
| stringBuffer.append(storage.get(voucherId).toString() + "\n"); | ||
| } | ||
|
|
||
| return stringBuffer.toString(); |
There was a problem hiding this comment.
단순히 findAll은 string이 아니라, 자료구조인 List가 나와야 하지 않을까요?
|
|
||
| import java.util.UUID; | ||
|
|
||
| public class FixedAmountVoucher implements Voucher { |
|
|
||
| @Override | ||
| public long discount(long beforeDiscount) { | ||
| return beforeDiscount * (percent / 100); |
src/main/resources/logback.xml
Outdated
| <!-- encoders are assigned the type | ||
| ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> |
|
2주차에서 다시 전체적으로 볼게요. 2단계 진행 해주세요 :) |
Revert main Branch #218
📌 과제 설명
바우처 관리 애플리케이션 1주차 과제입니다.
👩💻 요구 사항과 구현 내용
✅ PR 포인트 & 궁금한 점