Skip to content

[5기 - 송인재] Spring Boot Part3 Weekly Mission 제출합니다. #971

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

Open
wants to merge 82 commits into
base: IjjS
Choose a base branch
from

Conversation

IjjS
Copy link

@IjjS IjjS commented Nov 5, 2023

📌 과제 설명

바우처와 고객 서비스 관리페이지를 thymeleaf를 이용하여 개발했습니다.

프로젝트 디렉터리에 Dockerfile을 추가해두었습니다. 프로젝트 디렉터리에서 도커 이미지 빌드 후 실행 부탁드립니다.

docker build -t temp .
docker run --name temp-container -p 33060 temp

테스트를 제외하고 4개의 프로파일이 있습니다.

  • 콘솔 애플리케이션

    • dev - 인메모리 레포지토리
    • file - 파일 레포지토리
    • jdbc - jdbc레포지토리
  • 웹 애플리케이션

    • web - jdbc 레포지토리

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

(기본) 바우처 서비스 관리페이지 개발하기

  • Spring MVC를 적용해서 thymeleaf 템플릿을 설정해보세요.
  • 커맨드로 지원했던 기능을 thymeleaf를 이용 해서 관리페이지를 만들고 다음 기능을 지원가능하게 해보세요
    • 조회페이지
    • 상세페이지
    • 입력페이지
    • 삭제기능

(기본) 바우처 서비스의 API 개발하기

  • Spring MVC를 적용해서 JSON과 XML을 지원하는 REST API를 개발해보세요

    • 전체 조회기능
    • 조건별 조회기능 (바우처 생성기간 및 특정 할인타입별)
    • 바우처 추가기능
    • 바우처 삭제기능
    • 바우처 아이디로 조회 기능
  • (보너스) 바우처 지갑용 관리페이지를 만들어보세요.

  • Advice

    • annotation - AdminController : 어드민 페이지용 컨트롤러를 명시하기 위한 어노테이션
    • GeneralAdvice : 어드민 페이지용 ControllerAdvice
    • RestAdvice : RestControllerAdvice
  • Configuration

    • Profiles)
    • ConsoleCondition : 콘솔 애플리케이션용 프로파일 모음 (dev, file, jdbc)
    • DBEnabledCondition : DB 사용 가능한 프로파일 모음 (jdbc, web)
    • FileEnabledCondition : 파일 사용 가능한 프로파일 모음 (file, test)
  • Customer

    • CustomerRestController
    • CustomerAdminController
  • Voucher

    • VoucherRestController
    • VoucherAdminController
    • VoucherService) findByType, findByCreatedAt 기능 추가

✅ 피드백 반영사항

  • 파일 로드 시 타입 변경) 기존: 로드 시 List -> 이후 Map으로 변환 => 변경: 로드 시 Map
  • @ParameterizedTest 활용
  • DB로 데이터 저장소 사용 시 블랙리스트 csv 기능 제거
  • 메서드 분리 (1 depth 유지)

✅ PR 포인트 & 궁금한 점

라이브 리뷰 해주실 때 여쭤보겠습니다!!

IjjS added 30 commits November 2, 2023 05:10
import java.util.UUID;

public class Voucher {
private final UUID voucherId;
private final LocalDateTime createdAt;
private final BigDecimal discountValue;

Choose a reason for hiding this comment

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

int,long으로 할수 없엇을까요?

import com.programmers.vouchermanagement.advice.annotation.AdminController;

@ControllerAdvice(annotations = AdminController.class)
public class GeneralAdvice {

Choose a reason for hiding this comment

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

공통된 애가 있으면 좋을거 같아요!

import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice(annotations = RestController.class)
public class RestAdvice {

Choose a reason for hiding this comment

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

RuntimeException으로 예상치 못한 예외를 방어해보면 어떨까요?

return "redirect:/customers/" + customer.customerId();
}

@PostMapping("/{customerId}/delete")

Choose a reason for hiding this comment

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

delete를 쓰시면 어떨까요?

return "customers/customer";
}

@PostMapping("/update")

Choose a reason for hiding this comment

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

put이여야 하지 않을까요?

}

@PostMapping
@ResponseStatus(HttpStatus.CREATED)

Choose a reason for hiding this comment

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

ResponseEntity를 찾아보시고 한번 해보시면 어떨까요?

}

@DeleteMapping("/{voucherId}")
@ResponseStatus(HttpStatus.ACCEPTED)

Choose a reason for hiding this comment

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

내려줄 응답이 없다면 no_content가 status에 맞습니다.


@GetMapping
@ResponseStatus(HttpStatus.OK)
public List<VoucherResponse> readAllVouchers(String typeName, LocalDate startDate, LocalDate endDate) {

Choose a reason for hiding this comment

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

public record CreateVoucherRequest(BigDecimal discountValue, VoucherType voucherType) {
public record CreateVoucherRequest(
@Positive(message = "Discount value must be greater than 0.") long discountValue,
@NotBlank(message = "Voucher type cannot be blank.") String voucherType

Choose a reason for hiding this comment

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

null인 경우 어떻게 될까요?

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.

2 participants