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단계 - 주문 기능 구현] 디노(신종화) 미션 제출합니다. #53

Merged
merged 85 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
586bb8b
feat: 와일드카드로 CORS 우선 설정
jjongwa May 24, 2023
4770a82
refactor: CORS 설정 Config로 분리
jjongwa May 24, 2023
e3b3e2b
refactor: CORS 설정 Config로 분리
jjongwa May 24, 2023
38d1233
cors분리
youngh0 May 24, 2023
869d34b
feat: warn log파일 생성 및 warn log작성
youngh0 May 25, 2023
146bb31
feat: DB테이블 정의
May 28, 2023
53841ec
feat: swagger 사용을 위한 의존성 주입 추가
May 28, 2023
ad5fc3c
refactor: 주석제거 및 스키마제거
May 28, 2023
e91df10
refactor: 스키마 수정
May 28, 2023
2ea9348
feat: mysql 의존성 추가
May 28, 2023
87e8ba3
feat: gitignore추가
May 28, 2023
86b6137
refactor: 스키마 변경
May 28, 2023
2d74bfd
refactor: 스키마 변경
May 28, 2023
06c5e73
feat: api명세서를 위한 간단한 controller정의
May 28, 2023
9bc7070
feat: gitignore 추가
May 28, 2023
c14dd45
feat: 상품 생성 dao 구현
May 30, 2023
f3ea536
feat: 상품 전체 조회 dao 구현
May 30, 2023
2f3117d
feat: 상품 단건 조회 dao 구현
May 30, 2023
9ee6cfb
feat: 상품 수정 dao 구현
May 30, 2023
2d59f1f
test: 상품 삭제 dao 테스트 구현
May 30, 2023
3063f4e
refactor: 상품 Dao -> Repository 변경
May 30, 2023
9741e71
feat: ProductReadService 구현
May 30, 2023
31e8334
feat: ProductWriteService 구현
May 30, 2023
32a95b0
feat: ProductController 구현
May 30, 2023
bab3071
feat: MemberRepository 구현
May 31, 2023
257bfeb
feat: 개행 추가
May 31, 2023
e105112
feat: 개행 복귀
May 31, 2023
8c9e76d
feat: memberService 구현
May 31, 2023
eb8db15
feat: memberController 구현 및 Dto분리
May 31, 2023
2503e08
refactor: getMemberByEmail >isMemberExist 기능 수정
May 31, 2023
f53506f
feat: CartItemJdbcRepository 기능 구현
May 31, 2023
beb6cb7
refactor: Product Dto 분리
May 31, 2023
705e8a8
refactor: member Dto 분리 및 resolver 로직 변경
May 31, 2023
aaf12eb
refactor: cartItem Dto 분리
May 31, 2023
d9d1c1e
refactor: WebMvcConfig 생성자 주입 변경
May 31, 2023
51853a3
refactor: test fixture 수정
May 31, 2023
14538a7
feat: ExceptionHandler 예외사항 추가(NoSuchElementException)
May 31, 2023
3a38950
refactor: 사용하지 않는 클래스 삭제
May 31, 2023
c95e406
refactor: point 테이블 생성
May 31, 2023
69ed3ad
refactor: 계층에 맞는 서비스 주입
May 31, 2023
0de71a2
refactor: 사용하지 않는 서비스 제거
May 31, 2023
573b60b
refactor: CartItem dto 추가 및 cartItems 생성, api 스팩 변경
Jun 1, 2023
6f3bf45
refactor: 금액계산 controller작성
Jun 1, 2023
6a0d775
refactor: coupon api 명세 뼈대 코드 작성
Jun 1, 2023
3e96997
refactor: point api 명세 뼈대 코드 작성
Jun 1, 2023
5e7bf81
refactor: order api 명세 뼈대 코드 작성
Jun 1, 2023
21dbe81
refactor: 할인 정책 뼈대 코드 및 테이블 수정
Jun 1, 2023
9dc54e2
refactor: mysql테이블로 수정
Jun 1, 2023
4e80e2e
refactor: mysql테이블로 수정
Jun 1, 2023
2abd4f3
refactor: mysql테이블로 수정
Jun 1, 2023
c27e542
refactor: mysql테이블로 수정
Jun 1, 2023
204abfa
refactor: mysql테이블로 수정
Jun 1, 2023
464f67a
refactor: mysql테이블로 수정
Jun 1, 2023
391f3d9
test: CartItem 도메인 서비스 테스트
Jun 1, 2023
411f819
test: CartItemController 테스트 추가
Jun 1, 2023
3d5a980
feat: member별 사용 가능한 coupon 조회 기능 추가
Jun 1, 2023
7168e54
feat: point 조회 기능 및 point계산 추가
Jun 1, 2023
1e3a2d4
feat: 할인 정책 추가
Jun 1, 2023
0825fb8
feat: 장바구니 수량 유효성 검사
Jun 1, 2023
aadc4ab
chore: coupon패키지 분리
Jun 1, 2023
bbef94b
feat: 장바구니 유효성 검사
Jun 1, 2023
9791edf
feat: 주문 기능 구현
Jun 2, 2023
6473e9a
feat: 주문기능 추가 및 특정 사용자의 주문 목록 전체조회 기능 추가
Jun 2, 2023
0e607ee
feat: 주문 이력 전체 조회 기능 추가
jjongwa Jun 3, 2023
d8fc26f
feat: 주문 이력 단건 조회 기능 추가
jjongwa Jun 3, 2023
9129ff9
refactor: 쿠폰 조회 방식 변경
jjongwa Jun 3, 2023
6afafce
refactor: 테스트 격리
jjongwa Jun 3, 2023
6d484e8
refactor: 포인트 적립 로직 변경
jjongwa Jun 3, 2023
5406b1d
test: service 및 controller test 추가
jjongwa Jun 3, 2023
29eca71
refactor: data.sql 수정
jjongwa Jun 5, 2023
1398455
refactor: data.sql 수정
jjongwa Jun 5, 2023
33b024d
refactor: data.sql 수정
jjongwa Jun 5, 2023
b5e66f6
refactor: 주문 단건 조회 쿼리 로직 변경
jjongwa Jun 5, 2023
578ec44
docs: 기능 요구사항 및 구현 목록 작성
jjongwa Jun 5, 2023
121e581
refactor: 사용하지 않는 메서드 삭제, 네이밍 변경
jjongwa Jun 5, 2023
424fb5b
refactor: 테이블 이름 변경
jjongwa Jun 5, 2023
6fb696e
fix: gitignore 설정 변경 및 properties 파일 추가
jjongwa Jun 6, 2023
cc8e9d5
refactor: 개행 추가
jjongwa Jun 6, 2023
c3c0e67
refactor: 개행 추가
jjongwa Jun 6, 2023
07c3532
refactor: 클래스 구조 변경
jjongwa Jun 7, 2023
7e1f7f5
refactor: truncate를 사용해 테스트 격리 적용
jjongwa Jun 8, 2023
1cd781c
refactor: 메서드 분리 및 세부 로직 변경
jjongwa Jun 8, 2023
41bac49
refactor: 코드 컨벤션 적용
jjongwa Jun 8, 2023
9772c36
refactor: PointPolicy Enum으로 변경
jjongwa Jun 8, 2023
89b89ac
refactor: 사용하지 않는 import문 제거
jjongwa Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ out/

### VS Code ###
.vscode/

!**/src/main/resources/application.properties

application.properties

Choose a reason for hiding this comment

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

  • test패키지의 application.propreties까지 ignore 하신 이유가 있을까요?
  • 적어주신 application.properties - main과 실제 AWS에서 돌고있는 프로퍼티들은 다른거죠?

Copy link
Member Author

Choose a reason for hiding this comment

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

네네 실제 AWS에서는 다른 프로퍼티 파일을 사용하고 있습니다.

db 아이디와 패스워드 등의 보안 정보가 노출되기 때문에 프로퍼티는 무조건 gitIgnore 해야 한다! 라는 생각을 가지고 있었던 것 같습니다.

생각해 보니 db 설정에 대한 정보는 aws 서버에 따로 저장되어 있고, 현재 진행중인 프로젝트 패키지에서는 별다른 정보가 없어 그대로 push 해도 되겠군요..!

Choose a reason for hiding this comment

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

테스트는 로컬에서도 정상적으로 돌아가야합니다! test패키지의 프로퍼티는 넣어주시면 좋을 것 같아요.
프로덕션 패키지의 application.properties도 local에서는 돌아갈 수 있게끔 설정해주시면 좋을 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

마지막 커밋 사항을 올리지 않았네요..
적용했습니다..! 6fb696e

55 changes: 55 additions & 0 deletions README.md

Choose a reason for hiding this comment

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

추가적으로 여쭤볼게 있습니다..! 우테코 활동을 기록하기 위한 리포지터리를 작성하고 있는데 리뷰어 부분에 빙봉의 깃허브 주소를 태그해도 될까요? https://github.com/jjongwa/woowacourse 이 부분입니다..!

넵~ 하셔도 됩니다 🙂

Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
# jwp-shopping-order

## 기능 요구 사항

## 할인 정책 : 쿠폰, 포인트

### 주문

- [x] 장바구니에 담긴 상품만 주문이 가능하다.
- [x] 주문할 품목, 사용할 쿠폰, 사용할 포인트를 요청으로 받는다.
- [x] 주문 시 사용한 쿠폰 목록을 저장한다.
- [x] 주문 시 사용한 쿠폰은 사용처리 한다.
- [x] 주문 시 주문한 장바구니 품목은 장바구니에서 삭제한다.
- [x] 주문 시 사용한 포인트와 적립된 포인트를 포인트 이력에 저장한다.


### 쿠폰

- [x] 쿠폰은 정률 할인, 정액 할인 2종류가 존재한다.
- [x] 동시에 여러 쿠폰을 적용할 때에는 정률 할인을 정액 할인보다 우선으로 두고 할인률이 더 높은 쿠폰을 우선으로 적용한다.
- [x] 최소 주문 금액을 충족해야 쿠폰 적용이 가능하다.
- [x] 사용자가 사용할 수 있는 쿠폰 목록을 반환한다.


### 포인트

- [x] 현재 사용자의 잔여 포인트를 반환한다.
- [x] 포인트는 결제 금액을 초과하여 사용할 수 없다.
- [x] 포인트는 결제 금액의 1% 씩 적립된다.
- [x] 포인트는 쿠폰 적용 후 남은 금액에 적용된다.

## 기능 목록
- product
- [x] 새로운 상품을 생성한다.
- [x] 전체 상품 목록을 반환한다.
- [x] 특정 상품 정보를 반환한다.
- [x] 특정 상품 정보를 수정한다.
- [x] 특정 상품을 삭제한다.

- coupon
- [x] 특정 사용자가 가지고 있는 쿠폰 목록을 조회한다.

- point
- [x] 특정 사용자가 보유한 포인트를 반환한다.

- cart-item
- [x] 사용자의 장바구니에 물건을 추가한다.
- [x] 해당 사용자의 장바구니 목록을 반환한다.

- order
- [x] 사용자의 장바구니 목록 중 선택한 물건을 주문한다.
- [x] 사용자의 주문 목록을 조회한다.
- [x] 특정 주문의 상세 정보를 조회한다.


[API 명세 Swagger 페이지 바로가기](https://zlzon-dino.store/swagger-ui/index.html#/)
2 changes: 2 additions & 0 deletions build.gradle

Choose a reason for hiding this comment

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

적어둘 곳이 없어서 여기에 적습니다 🙇

README.md에 기능 구현 목록 혹은 주문 기능의 시나리오가 있어야할 것 같아요. (재화에 관련된 요구사항이 크루마다 달라서 더더욱 자세히 적어야 좋을 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

README 작성이 가장 기본인데.. 깜빡했습니다ㅜㅜ 바로 올리겠습니다!

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ 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 'org.springdoc:springdoc-openapi-ui:1.6.6'

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

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

tasks.named('test') {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/cart/WebMvcConfig.java

Choose a reason for hiding this comment

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

WebMvcConfig도 config라는 패키지를 만들어서 구분해주면 좋을 것 같습니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

config 패키지를 만들어 CorsConfig와 WebMvcConfig을 위치했습니다! 07c3532

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cart;

import cart.dao.MemberDao;
import cart.application.service.member.MemberReadService;
import cart.ui.MemberArgumentResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
Expand All @@ -10,14 +10,15 @@

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
private final MemberDao memberDao;
private final MemberReadService memberReadService;

public WebMvcConfig(MemberDao memberDao) {
this.memberDao = memberDao;
public WebMvcConfig(MemberReadService memberReadService) {
this.memberReadService = memberReadService;
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new MemberArgumentResolver(memberDao));
resolvers.add(new MemberArgumentResolver(memberReadService));
}

}
53 changes: 0 additions & 53 deletions src/main/java/cart/application/CartItemService.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/cart/application/ProductService.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/cart/application/repository/CartItemRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cart.application.repository;

import cart.domain.cartitem.CartItem;
import cart.domain.cartitem.CartItems;

import java.util.Optional;

public interface CartItemRepository {
Long createCartItem(CartItem cartItem);

CartItems findAllCartItemsByMemberId(Long memberId);

Optional<CartItem> findById(Long id);

void deleteById(Long id);

void updateQuantity(CartItem cartItem);

}
25 changes: 25 additions & 0 deletions src/main/java/cart/application/repository/CouponRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cart.application.repository;

import cart.domain.coupon.Coupon;
import cart.domain.discountpolicy.CouponPolicy;

import java.util.List;
import java.util.Optional;

public interface CouponRepository {

Coupon findById(final Long id);

List<Coupon> findByMemberId(final Long memberId);

List<Coupon> findAllByOrderId(final Long orderId);

Optional<CouponPolicy> findPercentCouponById(final Long memberCouponId);

Optional<CouponPolicy> findAmountCouponById(final Long memberCouponId);

void convertToUseMemberCoupon(final Long memberCouponId);

long createOrderedCoupon(final Long orderId, final Long memberCouponId);

}
20 changes: 20 additions & 0 deletions src/main/java/cart/application/repository/MemberRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cart.application.repository;

import cart.domain.Member;

import java.util.List;
import java.util.Optional;

public interface MemberRepository {

Long createMember(Member member);

List<Member> findAllMembers();

Optional<Member> findMemberById(Long id);

Optional<Member> findMemberByEmail(final String email);

Boolean isMemberExist(String email, String password);

}
12 changes: 12 additions & 0 deletions src/main/java/cart/application/repository/PointRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cart.application.repository;

import cart.domain.Point;
import cart.domain.PointHistory;

public interface PointRepository {

Point findPointByMemberId(Long memberId);

Long createPointHistory(final Long memberId, final PointHistory pointHistory);

}
20 changes: 20 additions & 0 deletions src/main/java/cart/application/repository/ProductRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cart.application.repository;

import cart.domain.Product;

import java.util.List;
import java.util.Optional;

public interface ProductRepository {

Long createProduct(final Product product);

List<Product> findAll();

Optional<Product> findById(final Long productId);

void updateProduct(final Product product);

void deleteProduct(final Long productId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cart.application.repository.order;

import cart.domain.order.Order;

import java.util.List;

public interface OrderRepository {

Long createOrder(Order order);

List<Order> findAllByMemberId(Long memberId);

Order findById(Long memberid, Long id);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cart.application.repository.order;

import cart.domain.order.OrderItem;

import java.util.List;

public interface OrderedItemRepository {

void createOrderItems(final Long orderId, final List<OrderItem> orderItems);

List<OrderItem> findOrderItemsByOrderId(final Long orderId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cart.application.service.cartitem;

import cart.application.repository.CartItemRepository;
import cart.application.repository.MemberRepository;
import cart.application.service.cartitem.dto.CartResultDto;
import cart.domain.Member;
import cart.domain.cartitem.CartItems;
import cart.ui.MemberAuth;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.NoSuchElementException;

@Service
@Transactional(readOnly = true)
public class CartItemReadService {

private final CartItemRepository cartItemRepository;
private final MemberRepository memberRepository;

public CartItemReadService(CartItemRepository cartItemRepository, final MemberRepository memberRepository) {
this.cartItemRepository = cartItemRepository;
this.memberRepository = memberRepository;
}

public CartResultDto findByMember(final MemberAuth memberAuth) {
final Member member = memberRepository.findMemberById(memberAuth.getId())
.orElseThrow(() -> new NoSuchElementException("일치하는 사용자가 없습니다."));

final CartItems cartItems = cartItemRepository.findAllCartItemsByMemberId(member.getId());
final int totalPrice = cartItems.calculateTotalPrice();

return CartResultDto.of(cartItems.getCartItems(), totalPrice);
}

}
Loading