-
Notifications
You must be signed in to change notification settings - Fork 100
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
Changes from 69 commits
586bb8b
4770a82
e3b3e2b
38d1233
869d34b
146bb31
53841ec
ad5fc3c
e91df10
2ea9348
87e8ba3
86b6137
2d74bfd
06c5e73
9bc7070
c14dd45
f3ea536
2f3117d
9ee6cfb
2d59f1f
3063f4e
9741e71
31e8334
32a95b0
bab3071
257bfeb
e105112
8c9e76d
eb8db15
2503e08
f53506f
beb6cb7
705e8a8
aaf12eb
d9d1c1e
51853a3
14538a7
3a38950
c95e406
69ed3ad
0de71a2
573b60b
6f3bf45
6a0d775
3e96997
5e7bf81
21dbe81
9dc54e2
4e80e2e
2abd4f3
c27e542
204abfa
464f67a
391f3d9
411f819
3d5a980
7168e54
1e3a2d4
0825fb8
aadc4ab
bbef94b
9791edf
6473e9a
0e607ee
d8fc26f
9129ff9
6afafce
6d484e8
5406b1d
29eca71
1398455
33b024d
b5e66f6
578ec44
121e581
424fb5b
6fb696e
cc8e9d5
c3c0e67
07c3532
7e1f7f5
1cd781c
41bac49
9772c36
89b89ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
!**/src/main/resources/application.properties | ||
|
||
application.properties | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 적어둘 곳이 없어서 여기에 적습니다 🙇 README.md에 기능 구현 목록 혹은 주문 기능의 시나리오가 있어야할 것 같아요. (재화에 관련된 요구사항이 크루마다 달라서 더더욱 자세히 적어야 좋을 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. README 작성이 가장 기본인데.. 깜빡했습니다ㅜㅜ 바로 올리겠습니다! |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WebMvcConfig도 config라는 패키지를 만들어서 구분해주면 좋을 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. config 패키지를 만들어 CorsConfig와 WebMvcConfig을 위치했습니다! 07c3532 |
This file was deleted.
This file was deleted.
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); | ||
|
||
} |
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); | ||
|
||
} |
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); | ||
|
||
} |
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); | ||
|
||
} |
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 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); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package cart.application.service.cartitem; | ||
|
||
import cart.application.repository.CartItemRepository; | ||
import cart.application.repository.MemberRepository; | ||
import cart.application.repository.ProductRepository; | ||
import cart.application.service.cartitem.dto.CartItemCreateDto; | ||
import cart.application.service.cartitem.dto.CartItemUpdateDto; | ||
import cart.domain.Member; | ||
import cart.domain.Product; | ||
import cart.domain.cartitem.CartItem; | ||
import cart.ui.MemberAuth; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
@Service | ||
@Transactional | ||
public class CartItemWriteService { | ||
|
||
private final CartItemRepository cartItemRepository; | ||
private final MemberRepository memberRepository; | ||
private final ProductRepository productRepository; | ||
|
||
public CartItemWriteService(final CartItemRepository cartItemRepository, final MemberRepository memberRepository, final ProductRepository productRepository) { | ||
this.cartItemRepository = cartItemRepository; | ||
this.memberRepository = memberRepository; | ||
this.productRepository = productRepository; | ||
} | ||
|
||
public Long createCartItem(MemberAuth memberAuth, CartItemCreateDto cartItemCreateDto) { | ||
final Member member = memberRepository.findMemberById(memberAuth.getId()) | ||
.orElseThrow(() -> new NoSuchElementException("일치하는 사용자가 없습니다.")); | ||
final Product product = productRepository.findById(cartItemCreateDto.getProductId()) | ||
.orElseThrow(() -> new NoSuchElementException("일치하는 상품이 없습니다.")); | ||
return cartItemRepository.createCartItem(new CartItem(product, member)); | ||
} | ||
|
||
public void updateQuantity(MemberAuth memberAuth, Long cartItemId, CartItemUpdateDto cartItemUpdateDto) { | ||
final Member member = memberRepository.findMemberById(memberAuth.getId()) | ||
.orElseThrow(() -> new NoSuchElementException("일치하는 사용자가 없습니다.")); | ||
|
||
final CartItem cartItem = cartItemRepository.findById(cartItemId) | ||
.orElseThrow(() -> new IllegalArgumentException("일치하는 상품이 없습니다.")); | ||
cartItem.checkOwner(member); | ||
|
||
if (cartItemUpdateDto.getQuantity() == 0) { | ||
cartItemRepository.deleteById(cartItemId); | ||
return; | ||
} | ||
|
||
cartItem.changeQuantity(cartItemUpdateDto.getQuantity()); | ||
cartItemRepository.updateQuantity(cartItem); | ||
} | ||
|
||
public void remove(MemberAuth memberAuth, Long cartItemId) { | ||
final Member member = memberRepository.findMemberById(memberAuth.getId()) | ||
.orElseThrow(() -> new NoSuchElementException("일치하는 사용자가 없습니다.")); | ||
|
||
final CartItem cartItem = cartItemRepository.findById(cartItemId) | ||
.orElseThrow(() -> new IllegalArgumentException("일치하는 상품이 없습니다.")); | ||
cartItem.checkOwner(member); | ||
|
||
cartItemRepository.deleteById(cartItemId); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 해도 되겠군요..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트는 로컬에서도 정상적으로 돌아가야합니다! test패키지의 프로퍼티는 넣어주시면 좋을 것 같아요.
프로덕션 패키지의 application.properties도 local에서는 돌아갈 수 있게끔 설정해주시면 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막 커밋 사항을 올리지 않았네요..
적용했습니다..! 6fb696e