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

[2단계 - 주문 기능 구현] 제이(이재윤) 미션 제출합니다. #9

Merged
merged 135 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
05ee3b9
feat: CORS 정책
sosow0212 May 23, 2023
bc5da27
feat: CORS 정책
sosow0212 May 23, 2023
54b3f92
refactor: CORS 정책 수정
sosow0212 May 24, 2023
589c52a
style: 패키지 구조 변경
sosow0212 May 24, 2023
037f38c
fix: ArgumentResolver 작동 안하는 문제 해결
sosow0212 May 24, 2023
11c8c04
fix: CORS 안되는 문제 해결
sosow0212 May 24, 2023
bf33575
refactor: MethodArgumentResolver를 어노테이션화
sosow0212 May 24, 2023
88d6c8b
refactor: 테스트코드 @DirtiesContext 제거로 매번 다른 컨텍스트를 띄우지 않도록 변경
sosow0212 May 24, 2023
0dfed2e
fix: CORS 해결
sosow0212 May 24, 2023
69b4d7c
fix: CORS 해결
sosow0212 May 24, 2023
7153c57
fix: CORS 해결
sosow0212 May 24, 2023
ad22e26
fix: CORS 해결
sosow0212 May 24, 2023
add38ec
fix: CORS 해결
sosow0212 May 24, 2023
19f7776
fix: CORS 해결
sosow0212 May 24, 2023
31f88c2
fix: CORS 해결
sosow0212 May 24, 2023
13b69b1
fix: CORS 해결
sosow0212 May 24, 2023
5ac0c42
fix: CORS 해결
sosow0212 May 24, 2023
b0a612a
fix: CORS 해결
sosow0212 May 24, 2023
023cb86
fix: CORS 해결
sosow0212 May 24, 2023
8d94578
fix: CORS 해결
sosow0212 May 24, 2023
7573c51
fix: CORS 해결
sosow0212 May 24, 2023
ee6ec52
fix: CORS 해결
sosow0212 May 24, 2023
c922b27
fix: CORS 해결
sosow0212 May 24, 2023
37a0038
fix: CORS 해결
sosow0212 May 24, 2023
76555b3
docs: 2단계 기능 구현 목록 작성
sosow0212 May 26, 2023
f3af406
feat: Email & Password 원시값 포장 및 예외 기능 추가
sosow0212 May 26, 2023
e9949d5
refactor: Member 도메인에서 필드 값을 원시값 포장한 객체로 변경
sosow0212 May 26, 2023
7f1744a
refactor: 기능구현목록에 맞게 sql 수정
sosow0212 May 26, 2023
3ea0c53
refactor: log, validation 종속성 추가
sosow0212 May 26, 2023
4b842ba
feat: 인메모리 db 사용 설정 및 sql 추가
sosow0212 May 27, 2023
cff9932
feat: 패스워드가 일치하는지 확인하는 기능 추가
sosow0212 May 27, 2023
811fe15
refactor: Product CRUD 기능 구조 변경
sosow0212 May 27, 2023
ab58bf5
refactor: Member CRUD 기능 구조 변경
sosow0212 May 27, 2023
b989bf9
refactor: CartItem CRUD 기능 구조 변경
sosow0212 May 27, 2023
0457e4c
feat: Cart 기능 추가
sosow0212 May 27, 2023
04631bd
fix: 조건을 반대로 사용해서 깨지는 문제 해결
sosow0212 May 27, 2023
3388547
refactor: 분기 오류 해결 및 기존 테스트코드를 통과할 수 있도록 일부 변경
sosow0212 May 27, 2023
80021ad
refactor: 타인의 장바구니 품목을 수정 및 삭제할 수 없도록 변경
sosow0212 May 27, 2023
5a59106
chore: mysql, Rest Docs 종속성 추가
sosow0212 May 27, 2023
a4a4f58
refactor: 기존 예외 리팩토링 진행
sosow0212 May 27, 2023
b6a7368
style: 계층형 패키지 구조로 디렉토리 이동
sosow0212 May 27, 2023
a8de52f
refactor: CartController에 사용자 입력 값에 대한 예외 기능 추가
sosow0212 May 27, 2023
dbf42ab
refactor: CartController에 사용자 입력 값에 대한 예외 기능 추가
sosow0212 May 27, 2023
85b84b8
refactor: ProductController 사용자 입력 값에 대한 예외 기능 추가
sosow0212 May 27, 2023
69a3c78
refactor: CartService @Transactional 어노테이션 추가 및 final 키워드 통일
sosow0212 May 27, 2023
b3cc2ce
refactor: Coupon과 Policy 테이블 생성
sosow0212 May 28, 2023
ee589a1
feat: 할인 정책을 의미하는 Policy 인터페이스와, 각 정책에 맞는 구현체 생성
sosow0212 May 28, 2023
7b6cce7
feat: 쿠폰 생성 및 가격 계산 로직 추가
sosow0212 May 28, 2023
808a81b
docs: 기능 구현 목록 수정
sosow0212 May 28, 2023
e8dd004
feat: Order, Payment API 틀잡기 (Controller, Service, DTO)
sosow0212 May 28, 2023
c9e1693
feat: Policy에 할인 value 정책을 변경하는 로직 추가
sosow0212 May 28, 2023
b05b8f2
feat: Product에 세일 적용 및 가격 조회 기능 추가
sosow0212 May 28, 2023
d5a80bc
refactor: Product에 세일 정보 포함
sosow0212 May 28, 2023
e34fcbd
refactor: 상품 추가시에 기본 할인 정책 추가 (default : 0%)
sosow0212 May 28, 2023
f88fafb
feat: 상품에 세일을 적용하는 Query 작성
sosow0212 May 28, 2023
36ca195
fix: 잘못된 목업 데이터 변경
sosow0212 May 28, 2023
9cc3216
feat: 상품 할인 및 할인 제거하는 기능 추가, 조회시 프론트와 협의한 내용 반환할 수 있도록 DTO 일부 변경
sosow0212 May 28, 2023
830f92a
refactor: 쿠폰 적용 가격 로직 변경 (쿠폰이 적용 안되어도 쿠폰 적용된 가격을 조회한다면 원래 금액이 나온다.)
sosow0212 May 28, 2023
9440652
feat: 쿠폰 적용시 금액 확인하는 기능 일부 구현
sosow0212 May 28, 2023
a87deb1
refactor: 도메인 의존 관계 변경 Cart가 Member를 가지는 게 아닌 Member가 Cart를 가지도록 변경
sosow0212 May 28, 2023
f9b1e8b
feat: 결제 금액 로직 구현 완료
sosow0212 May 28, 2023
cf3f571
refactor: Member와 Cart 객체의 연관관계를 끊도록 구조 변경
sosow0212 May 28, 2023
be1285b
feat: 결제 테이블, 구매 내역 테이블 추가
sosow0212 May 28, 2023
9b9819d
feat: 결제 내역 확인을 위한 기능 추가
sosow0212 May 28, 2023
8b5f05d
fix: DTO 이름이 반대로 되어있던 것 해결
sosow0212 May 28, 2023
ada2060
refactor: 코드 정리
sosow0212 May 28, 2023
f1b2a0d
fix: 구매 내역에서 수량도 포함할 수 있도록 변경
sosow0212 May 29, 2023
62e6c0b
refactor: 결제금액 로직 변경 (수량까지 포함)
sosow0212 May 29, 2023
4cbd043
feat: 주문을 관리하는 Order 객체 생성
sosow0212 May 29, 2023
e75bf6e
refactor: Cart API 코드 리팩토링
sosow0212 May 29, 2023
01de5f4
refactor: Product API 리팩토링 (프론트엔드의 요구 사항에 맞게 반환 필드명 변경, 코드 정리)
sosow0212 May 29, 2023
8f6dcbb
refactor: Payment API 코드 메서드 분리 및 리팩토링 진행
sosow0212 May 29, 2023
adac2be
feat: 쿠폰을 사용할 땐 쿠폰까지 받아서 init해주는 ArgumentResolver 추가
sosow0212 May 29, 2023
0855992
refactor: 프론트엔드 요구사항에 맞춰 반환에 imgUrl 필드 추가
sosow0212 May 29, 2023
c02c4a5
refactor: 프론트엔드 요구사항에 맞춰 반환에 imgUrl 필드 추가
sosow0212 May 29, 2023
ff21922
test: 기존 도메인에서 누락된 테스트 추가
sosow0212 May 29, 2023
9fdc9f8
refactor: 메서드 분리
sosow0212 May 29, 2023
ec8a9e2
test: ProductController 단위테스트 및 Rest Docs 적용
sosow0212 May 29, 2023
196d83d
refactor: 중복 이름 변경
sosow0212 May 29, 2023
250cd5b
test: ProductService 단위, 통합 테스트 작성
sosow0212 May 29, 2023
64cede1
test: PaymentController 단위 테스트 작성
sosow0212 May 29, 2023
116cfa0
test: PaymentController 통합테스트 작성
sosow0212 May 29, 2023
0bb5e05
test: Order 서비스 단위 & 통합테스트 작성
sosow0212 May 29, 2023
2631cf6
test: Product API 통합 테스트 작성
sosow0212 May 29, 2023
0c72422
test: Payment API 통합 테스트 작성
sosow0212 May 29, 2023
2047998
test: Order API 통합 테스트 작성
sosow0212 May 29, 2023
1bf9d15
refactor: 프론트 요구사항에 맞게 쿠폰으로 값 조회시 쿼리파라미터로 쿠폰 ID를 넘겨 받을 수 있또록 변경
sosow0212 May 30, 2023
b925020
feat: 타인이 주문 내역을 보면 예외를 발생시킨다.
sosow0212 May 30, 2023
7fb9deb
refactor: 쿠폰을 가지고 있지 않은데 구매할 때 없는 쿠폰으로 구매할 수 있는 문제 해결 및 벌크연산으로 리팩토링
sosow0212 May 30, 2023
b6a8acb
test: OrderController 단위 테스트 및 AsciiDocs 추가
sosow0212 May 30, 2023
bf98637
test: PaymentController 단위 테스트 및 RestDocs 추가
sosow0212 May 30, 2023
3d84b50
fix: 테스트 깨지는 문제 해결
sosow0212 May 30, 2023
67c6d6a
fix: 테스트 깨지는 문제 해결
sosow0212 May 30, 2023
ecff7c9
feat: Rest Docs 추가
sosow0212 May 30, 2023
effdc2d
refactor: 메서드 분리 및 패키지 이동
sosow0212 May 30, 2023
871eaa5
docs: 기능 구현 목록 수정
sosow0212 May 30, 2023
6c5b87f
style: 개행 및 안쓰는 메서드 제거
sosow0212 May 30, 2023
8ff90de
refactor: 프론트 요구사항에 맞게 imageUrl로 필드명 통일
sosow0212 May 31, 2023
ab1e900
refactor: URI 표현식을 명확한 네이밍으로 변경
sosow0212 Jun 1, 2023
9752cc9
refactor: Optional에서 값이 확실히 있기 때문 `.get()`으로 변경
sosow0212 Jun 1, 2023
f1924a1
refactor: 불필요한 코드 제거
sosow0212 Jun 1, 2023
89cf4c2
refactor: 단수이지만 복수로 네이밍한 부분 변경
sosow0212 Jun 1, 2023
33f7809
refactor: 헷갈리는 클래스명을 변경
sosow0212 Jun 1, 2023
7ea5407
refactor: 상품 세일 로직 변경 (중간 테이블 하나 추가하므로 중복 및 의존도 제거)
sosow0212 Jun 1, 2023
2dd75c3
refactor: Member와 Coupon 사이에 중간 테이블 생성으로 DB 중복 최소화
sosow0212 Jun 1, 2023
e8912b9
refactor: Member와 Coupon 사이에 중간 테이블 생성으로 DB 중복 최소화
sosow0212 Jun 1, 2023
7cc7258
feat: Coupon API 생성
sosow0212 Jun 1, 2023
285aa8e
refactor: Transactional 어노테이션 추가
sosow0212 Jun 1, 2023
b2c82fa
feat: Member API 추가
sosow0212 Jun 1, 2023
ee5a5b4
refactor: 안쓰는 메서드 삭제
sosow0212 Jun 1, 2023
6d73dcc
fix: 인자를 잘못 넘기는 문제 해결
sosow0212 Jun 1, 2023
57342b6
docs: RestDocs 문서 업데이트
sosow0212 Jun 1, 2023
b044def
refactor: 불필요한 출력문 제거 및 메서드 분리, 상수처리
sosow0212 Jun 1, 2023
4ffd7e6
feat: 유저의 장바구니를 모두 삭제하는 기능 추가
sosow0212 Jun 1, 2023
e42ab19
test: Cart API 테스트 작성
sosow0212 Jun 3, 2023
d1a9c80
refactor: Rest Docs Description 변경
sosow0212 Jun 3, 2023
8908282
refactor: CartService의 서비스 코드를 살리고 중복 도메인 로직을 제거
sosow0212 Jun 3, 2023
c55e4b9
refactor: Service 코드를 살리고 중복 도메인 로직 제거
sosow0212 Jun 3, 2023
9919fbc
refactor: Service 코드를 살리고 중복 도메인 로직 제거
sosow0212 Jun 3, 2023
fdf5c6e
refactor: Service 코드를 살리고 중복 도메인 로직 제거
sosow0212 Jun 3, 2023
4dedad5
refactor: 안쓰는 변수, 메서드 정리
sosow0212 Jun 3, 2023
87526f9
Merge remote-tracking branch 'origin/step2' into step2
sosow0212 Jun 3, 2023
2d13e4a
refactor: member와 coupon을 같이 받도록 변경
sosow0212 Jun 3, 2023
a6d7797
refactor: 모호한 메서드명 변경
sosow0212 Jun 4, 2023
abc991f
refactor: Cart 서비스에서 로직을 더욱 자연스럽게 변환
sosow0212 Jun 4, 2023
c172509
refactor: request 객체에서 기본 생성자의 접근 제어자 private로 변경
sosow0212 Jun 4, 2023
56c19ed
refactor: Param명 변경 (복수에 맞게)
sosow0212 Jun 4, 2023
c16b7f3
refactor: * 예외 정보에 요청한 정보를 포함해서 디버깅 용이하게 변경
sosow0212 Jun 4, 2023
f30a5ef
refactor: 주문 시간의 자료형을 String -> Date로 변경 (@JsonFormat 어노테이션을 이용해서 원하는…
sosow0212 Jun 6, 2023
cabdfc5
refactor: Policy와 Product의 관계 제거 (할인 정책, 쿠폰 정책 두 가지를 못 하게 변경)
sosow0212 Jun 6, 2023
918a8d0
refactor: 할인 정책 로직 변경
sosow0212 Jun 6, 2023
65c66c2
docs: 문서 변경
sosow0212 Jun 6, 2023
1508f8c
refactor: 생성일의 필드 타입을 LocalDateTime으로 변경
sosow0212 Jun 7, 2023
773aa72
refactor: SalePrice 원시값 포장으로 객체 역할 위임
sosow0212 Jun 7, 2023
89c47b6
test: SalePrice 테스트 작성
sosow0212 Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# jwp-shopping-order

## API 명세서

http://localhost:8080/docs/index.html

Choose a reason for hiding this comment

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

문서에서 example이 description으로 오기되어 있는 부분이 있습니다 ㅎㅎ 수정해주셔요 (description 추가)
사실 백엔드 입장에선 가벼운 실수지만 협업자나 기획자는 해당 문서만 보고 시스템을 파악해야합니다. 상대 입장에서 생각해보면 API가 고장나있는 것 만큼의 스트레스를 주겠죠.
image

Choose a reason for hiding this comment

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

그리고 장바구니 API가 문서에 없어서 슬펐습니다 ㅠ ㅠ

Copy link
Author

Choose a reason for hiding this comment

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

장바구니 API는 협의가 완료돼서 추가하겠습니다..!


---

## 기능 구현 목록

### 기획

- 재화
- 사용자는 장바구니 페이지에서 쿠폰을 사용할 수 있다.
- 사용자가 쿠폰을 여러 개 사용할 수 있다.

- 판매 상품에 세일을 적용할 수 있다.

- 주문
- 사용자는 주문을 완료하면 주문 목록을 확인할 수 있다.
- 주문 목록에서 하나를 선택하면 구입 가격 및 사용한 쿠폰들을 보여준다.

### 재화 플로우

- 재화
- 회의
- 마켓컬리, yes24 등 여러가지 서비스의 결제 과정을 프론트엔드 팀과 확인을 했습니다.
<br> 프론트엔드 팀은 상태 관리를 하면서 사용자가 쿠폰을 사용할 때마다 가격 갱신이 되는 것을 보여주고 싶어했습니다.
<br> 백엔드 팀에서도 적절하다고 생각했기에, 다음과 같은 전략을 구상했습니다.
- 전략
- 사용자가 쿠폰을 선택하면 프론트엔드 서버에서 쿠폰 종류와, id 값들을 보내준다.
- 서버에서는 계산을 하고 `originalPrice & discountPrice`를 보내준다. (`discountPrice`는 할인 받는 금액을 의미합니다. 즉 1000원 할인 쿠폰이라면 1000원을
의미합니다.)
- 프론트엔드 서버에서 상태 관리를 하면서 사용자가 실시간으로 얼마를 지불해야하는지 보여준다.

- 세일
- 상품 세일은 관리자 페이지에서 해줄 수 있다.
- 프론트엔드 서버에서 메인 페이지에 할인 상품에 표시를 해주기 위해서 서버측에서는 `isOnSale`같은 boolean 타입과 가격을 보내준다. 혹은 `salePrice` 필드를 0원 혹은 x원으로
보내주어, 0원이면 프론트 서버에서 처리한다.

- 쿠폰
- 배달료 감면 쿠폰은 %할인이 아니라 x원 할인이다. 또한 이름의 시작은 `DELIVERY_XX`로 시작한다.

### 도메인

- Member(id, Email, Password, Coupons)
- email & password 원시값포장 및 유효성 검사를 진행한다.

- Cart(id, CartItems, DeliveryFee)

- CartItems(List<CartItem>)

- CartItem(id, Product, quantity)
- 수량이 양수인지 확인한다.

- Product(id, name, price, imageUrl, salePrice)
- 상품 이름이 공백 혹은 빈 값인지 확인한다.
- 가격이 양수인지 확인한다.
- 상품 할인은 정책상 %할인 밖에 안된다.

- Coupons(List<Coupon>)

- Coupon(id, name, Policy)
- 쿠폰 이름이 공백 혹은 빈 값이 아닌지 확인한다.

- Order (Member, Cart)
- 장바구니와 멤버를 이어주며, 구매시 구매 내역을 반환한다.
37 changes: 36 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,61 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.9'
id 'org.springframework.boot' version '2.7.10'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'

id "org.asciidoctor.jvm.convert" version "3.3.2"
}

configurations {
asciidoctorExt
}

asciidoctor {
dependsOn test
configurations 'asciidoctorExt'
}

tasks.register('copyApiDocument', Copy) {
dependsOn asciidoctor
doFirst {
delete file("src/main/resources/static/docs")
}
from asciidoctor.outputDir
into file("src/main/resources/static/docs")
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
mavenCentral()
}

build {
dependsOn copyApiDocument
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

implementation 'net.rakugakibox.spring.boot:logback-access-spring-boot-starter:2.7.1'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.slf4j:slf4j-api:1.7.31'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:4.4.0'

runtimeOnly 'mysql:mysql-connector-java:8.0.28'
runtimeOnly 'com.h2database:h2'

testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
}

tasks.named('test') {
useJUnitPlatform()
}