Skip to content
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 Part1 Weekly Mission 제출합니다. #919

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

ParkJuhan94
Copy link

📌 과제 설명

(기본) 바우처 관리 애플리케이션

  • Maven / Gradle 로 프로젝트를 실제로 구성하고 이때 Spring Boot CLI를 개발PC에 설치해서 명령어들을 사용해보고 프로젝트를 만든다. 그리고 IDE (IntelliJ)에서 실행시켜 본다.

  • 바우처 관리 Command-line Application을 만들어본다.

    • 참고: https://dzone.com/articles/interactive-console-applications-in-java
    • 스프링부트 애플리케이션으로 만든다. (Web기능이 없이 만듭니다. 즉, 서버가 띄지 않고 커맨드라인 애플리케이션으로 동작해야한다.)
    • 프로그램이 시작하면 다음과 같이 지원가능한 명령어를 알려준다.
    === Voucher Program ===
    Type **exit** to exit the program.
    Type **create** to create a new voucher.
    Type **list** to list all vouchers.
    • create / list 커맨드를 지원한다.
      • create 커맨드를 통해 바우처를 생성할수 있다. (FixedAmountVoucher, PercentDiscountVoucher)
      • list 커맨드를 통해 만들어진 바우처를 조회할 수 있다.
      • this바우처 정보를 메모리에 관리한다. 어플리케이션이 종료가 되어 데이터가 모두 사라져도 괜찮습니다. (나중에 영속성을 가지도록 변경할거에요 걱정마세요!)
  • 적절한 로그를 기록하고 logback 설정을 해서 에러는 파일로 기록된다.

  • 실행가능한 jar 파일을 생성한다.

(심화) 파일을 통한 데이터관리 기능과 고객 블랙 리스트 명단 관리기능

  • 메모리 관리가 아닌 파일로 관리가 되는 Repository를 한번 만들어보세요.
    • 기존 메모리 레포지토리는 지우지 말고 개발 프로파일에서만 동작하게 해보세요.
  • 고객 블랙 리스트 명단을 작성한다.
    • customer_blacklist.csv 파일을 만들고 스프링 애플리케이션에서 해당 파일을 읽을 수 있고 블랙 리스트조회 할 수있다 (추가할 필요는 없어요. 블랙리스트는 파일로만 관리된다고 가정합니다.)
  • YAML 프라퍼티를 만들고 어떤 설정을 만들수 있을지 고민해본다.

👩‍💻 요구 사항과 구현 내용

  • app, customer, voucher 가 상위 디렉토리에 위치합니다.
  • app 에서는 입출력, 메시지 enum 이 있습니다.
  • �customer, voucher 는 각각 controller, service, repository를 가집니다.

✅ PR 포인트 & 궁금한 점

  • voucherController 가 무거운 것 같아서 피드백 부탁드립니다.
  • menu 에서 BLACK을 선택했을때는 CustomerController / 그 외에는 VoucherController 에서 처리하도록 하고싶습니다.
    • startMenu가 controller 를 모르도록 만들었더니 menu 시작을 VoucherController에서 하도록 했습니다.
    • VoucherController 가 CustomerController 의 getBlackList() 를 호출하도록 했습니다.
    • 이것을 KdtApplication 에서 적어놓은 주석처럼 처리해도 되는지 궁금합니다.�(메뉴 입력에 따른 Controller의 분배)
    • KdtApplication 이 괜찮은지 궁금합니다. KdtApplication의 로직을 다른 클래스로 분리하는게 나을지 궁금합니다.

Copy link

@hoon-space hoon-space left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

첫 과제 리뷰가 많이 늦어졌네요.
몇 가지 코멘트 남겼습니다. ~

import java.io.IOException;

@SpringBootApplication
//@ComponentScan(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안쓰는 코드는 지워주는 것이 좋아요 ~

Comment on lines 13 to 19
@Override
public PropertySource<?> createPropertySource(String s, EncodedResource encodedResource) throws IOException {
var yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
yamlPropertiesFactoryBean.setResources(encodedResource.getResource());

var properties = yamlPropertiesFactoryBean.getObject();
return new PropertiesPropertySource(encodedResource.getResource().getFilename(), properties);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드로 프로퍼티를 받는 건 어떤 이유인가요 ???

Comment on lines 7 to 9
public interface CustomerRepository {

List<Customer> readFile(String filePath);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring data 스펙에 맞춰서 네이밍하는 것이 다음 과제 진행할때 편할 것 같아요

Comment on lines 27 to 32
private final String EXIT = "exit";
private final String CREATE = "create";
private final String LIST = "list";
private final String FIXED = "fixed";
private final String PERCENT = "percent";
private final String BLACK = "black";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 정도 개수라면 Enum 으로 분리해도 좋을 것 같아요

Comment on lines 6 to 13
@SpringBootTest
class KdtApplicationTests {

@Test
void contextLoads() {
}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳이 사용하지 않는 테스트는 제거해주셔도 좋을 것 같아요

Comment on lines 19 to 23
@Controller
public class VoucherController {

private final InputHandler inputHandler;
private final OutputHandler outputHandler;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컨트롤러에 너무 로직이 많은 것 같아요.
컨트롤러는 서비스와 맵핑만 해주는게 바람직해보입니다.

private final OutputHandler outputHandler;
private final StartMenu startMenu;
private final VoucherService voucherService;
private final CustomerController customerController;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컨트롤러가 컨트롤러를 참조하는게 어색해요

Comment on lines 5 to 9
public class FixedAmountVoucherDto {
private final UUID voucherId;
private final long amount;

public FixedAmountVoucherDto(UUID voucherId, long amount) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO 는 record 클래스 사용해도 좋을 것 같아요

Comment on lines 5 to 9
public interface InputHandler {

String inputString() throws IOException;

int inputInt() throws IOException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인터페이스로 선언했을때 장점이 궁금합니다. ~

pom.xml Outdated
Comment on lines 1 to 9
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.1</version>
<relativePath/> <!-- lookup parent from repository -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그레이들이 아닌 메이븐을 사용하신 이유가 궁금해요 ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants