-
Notifications
You must be signed in to change notification settings - Fork 0
[BE] 상품과 판매 상품 간 엔티티 관계 오류 수정 및 상품 리펙토링 #310
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
Changes from all commits
e4f2749
48fe4fc
9822ddb
2bf090f
ecb7968
9a190b1
795438b
1a98ac1
af70da9
bb0c689
554e1c3
679cc0f
0c30ca3
0a5e1d3
f5d8b78
e483a0a
9092b4f
a262264
b0461d2
09b1f70
671b0fc
95d8454
21fcd08
a808c50
c7fc814
1a9d4ba
32cf1b1
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 |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ dependencies { | |
|
|
||
| // Querydsl | ||
| implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' | ||
| annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta" | ||
| annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" | ||
| annotationProcessor "jakarta.annotation:jakarta.annotation-api" | ||
| annotationProcessor "jakarta.persistence:jakarta.persistence-api" | ||
|
|
||
|
|
@@ -80,6 +80,9 @@ dependencies { | |
| implementation 'org.springframework.session:spring-session-data-redis' | ||
| implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' | ||
|
|
||
| // Apple Silicon native DNS resolver | ||
| implementation 'io.netty:netty-resolver-dns-native-macos:4.1.100.Final:osx-aarch_64' | ||
|
|
||
| // Logstash를 위한 logstash-logback-encoder | ||
| // implementation 'net.logstash.logback:logstash-logback-encoder:7.2' | ||
|
|
||
|
|
@@ -97,3 +100,13 @@ dependencyManagement { | |
| tasks.named('test') { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| def generated = 'build/generated/sources/annotationProcessor/java/main' | ||
|
|
||
| tasks.withType(JavaCompile).configureEach { | ||
| options.getGeneratedSourceOutputDirectory().set(file(generated)) | ||
| } | ||
|
|
||
| clean { | ||
| delete file(generated) | ||
| } | ||
|
Comment on lines
+104
to
+112
Contributor
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. 이게 뭔가요? 설명해주세요!
Contributor
Author
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. Querydsl을 사용함에 따라 QClass 파일이 생기는데 IDE 설정마다 해당파일이 생기는 경로가 다르게 설정됩니다. 따라서 해당경로가 생기는 위치를 통일하기 위해서 추가한 설정입니다. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,37 +29,37 @@ public static CartDetailResponse from( | |
| return new CartDetailResponse( | ||
| cartId, | ||
| product.getId(), | ||
| product.getProduct().getName(), | ||
| product.getProduct().getProductInfo().getName(), | ||
| product.getOption() != null ? product.getOption().getOptionValue() : "기본옵션", | ||
| paymentPrice, | ||
| orderPrice, | ||
| discountPrice, | ||
| quantity, | ||
| paymentPrice * quantity, | ||
| product.getProduct().getMainImage(), | ||
| product.getProduct().getBrand(), | ||
| product.getProduct().getImage().getMainImage(), | ||
| product.getProduct().getProductInfo().getBrand(), | ||
|
Comment on lines
+32
to
+40
Contributor
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. embeded로 info 만들었다면 보내실때도 객체 dto로 묶어서 보내면 어떨까요?
Contributor
Author
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. 일단 DTO를 만들어 놓겠습니다.. 추후에 원하시는 분들께서는 사용해주시면 좋을것 같습니다.. 모든 파일을 까볼수가 없기때문에 😭 |
||
| isExisted | ||
| ); | ||
| } | ||
|
|
||
| public static CartDetailResponse of(Cart cart, boolean isExisted) { | ||
| SaleProduct saleProduct = cart.getSaleProduct(); | ||
| int paymentPrice = saleProduct.getProduct().getDiscountPrice(); | ||
| int orderPrice = saleProduct.getProduct().getOriginPrice(); | ||
| int paymentPrice = saleProduct.getProduct().getProductInfo().getDiscountPrice(); | ||
| int orderPrice = saleProduct.getProduct().getProductInfo().getOriginPrice(); | ||
| int discountPrice = orderPrice - paymentPrice; | ||
|
|
||
| return new CartDetailResponse( | ||
| cart.getId(), | ||
| saleProduct.getId(), | ||
| saleProduct.getProduct().getName(), | ||
| saleProduct.getProduct().getProductInfo().getName(), | ||
| saleProduct.getOption() != null ? saleProduct.getOption().getOptionValue() : "기본옵션", | ||
| paymentPrice, | ||
| orderPrice, | ||
| discountPrice, | ||
| cart.getQuantity(), | ||
| paymentPrice * cart.getQuantity(), | ||
| saleProduct.getProduct().getMainImage(), | ||
| saleProduct.getProduct().getBrand(), | ||
| saleProduct.getProduct().getImage().getMainImage(), | ||
| saleProduct.getProduct().getProductInfo().getBrand(), | ||
| isExisted | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,15 +133,16 @@ public CartResponse getGuestCart(List<GuestCartRequest> guestCartRequests) { | |
| return new CartDetailResponse( | ||
| null, //장바구니 ID는 null (비회원이니까) | ||
| saleProduct.getId(), | ||
| saleProduct.getProduct().getName(), | ||
| saleProduct.getProduct().getProductInfo().getName(), | ||
| saleProduct.getOption() != null ? saleProduct.getOption().getOptionValue() : "기본옵션", | ||
| saleProduct.getProduct().getDiscountPrice(), | ||
| saleProduct.getProduct().getOriginPrice(), | ||
| saleProduct.getProduct().getOriginPrice() - saleProduct.getProduct().getDiscountPrice(), | ||
| saleProduct.getProduct().getProductInfo().getDiscountPrice(), | ||
| saleProduct.getProduct().getProductInfo().getOriginPrice(), | ||
| saleProduct.getProduct().getProductInfo().getOriginPrice() - | ||
| saleProduct.getProduct().getProductInfo().getDiscountPrice(), | ||
| quantity, | ||
| saleProduct.getProduct().getDiscountPrice() * quantity, | ||
| saleProduct.getProduct().getMainImage(), | ||
| saleProduct.getProduct().getBrand(), | ||
| saleProduct.getProduct().getProductInfo().getDiscountPrice() * quantity, | ||
| saleProduct.getProduct().getImage().getMainImage(), | ||
| saleProduct.getProduct().getProductInfo().getBrand(), | ||
|
Comment on lines
+136
to
+145
Contributor
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. 위와 동일합니다. |
||
| false | ||
| ); | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,17 @@ | ||
| package com.jishop.category.controller; | ||
|
|
||
| import com.jishop.category.dto.CategoryResponse; | ||
| import com.jishop.product.dto.response.ProductResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.springframework.data.web.PagedModel; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Tag(name = "카테고리 API") | ||
| public interface CategoryController { | ||
|
|
||
| PagedModel<ProductResponse> getProductListByCategory(Long CategoryId, int page); | ||
|
|
||
| @Operation(summary = "최상위 카테고리의 ID와 이름 조회") | ||
| List<CategoryResponse> getCategoryFilterInfo(); | ||
|
|
||
| @Operation(summary = "해당 카테고리의 한단계 하위카테고리 ID 조회") | ||
| List<CategoryResponse> getSubcategoriesByParentId(Long categoryId); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,42 +4,20 @@ | |
| import com.jishop.category.dto.CategoryResponse; | ||
| import com.jishop.category.repository.CategoryRepository; | ||
| import com.jishop.category.service.CategoryService; | ||
| import com.jishop.product.domain.Product; | ||
| import com.jishop.product.dto.response.ProductResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.data.domain.*; | ||
| import org.springframework.data.web.PagedModel; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @Transactional | ||
| @Transactional(readOnly = true) | ||
| @RequiredArgsConstructor | ||
| public class CategoryServiceImpl implements CategoryService { | ||
|
|
||
| private final CategoryRepository categoryRepository; | ||
| // private final CategoryRedisService categoryRedisService; | ||
|
|
||
| @Override | ||
| public PagedModel<ProductResponse> getProductsByCategory(Long categoryId, int page) { | ||
|
Contributor
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. 이 조회기능은 완전 없어진건가요??
Contributor
Author
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. 상품 조회 기능이 카테고리 디렉토리에 있는것이 이상해서 상품 디렉토리로 가져왔습니다! |
||
|
|
||
| Pageable pageable = PageRequest.of(page, 12, Sort.by(Sort.Direction.DESC, "wishListCount")); | ||
| Page<Product> productPage = categoryRepository.findProductsByCategoryWithAllDescendants(categoryId, pageable); | ||
|
|
||
| List<ProductResponse> productsResponse = productPage.getContent().stream() | ||
| .map(ProductResponse::from) | ||
| .toList(); | ||
|
|
||
| return new PagedModel<>(new PageImpl<>( | ||
| productsResponse, | ||
| pageable, | ||
| productPage.getTotalElements() | ||
| )); | ||
| } | ||
|
|
||
| @Override | ||
| public List<CategoryResponse> getCategoryFilterInfo() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,19 +2,18 @@ | |
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record GeneralOptionResponse( | ||
| List<ProductOption> options | ||
| ) { | ||
| public static GeneralOptionResponse from(final List<Map<String, Object>> productOptions) { | ||
| public static GeneralOptionResponse from(final List<SizeOption> productOptions) { | ||
| final List<ProductOption> generalOptions = new ArrayList<>(); | ||
|
|
||
| for (final Map<String, Object> option : productOptions) { | ||
| for (final SizeOption option : productOptions) { | ||
| ProductOption productOption = new ProductOption( | ||
| (Long) option.get("saleProductId"), | ||
| (String) option.get("optionValue"), | ||
| (int) option.get("optionExtra") | ||
| option.saleProductId(), | ||
| option.optionValue(), | ||
| option.optionExtra() | ||
|
Comment on lines
13
to
+16
Contributor
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. Option을 안넣고 필드로 넣으신 이유가 있을까요?
Contributor
Author
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. Option객체를 생성해서 직접 값을 주입하지 않았냐고 여쭤보시는게 맞을까요? |
||
| ); | ||
| generalOptions.add(productOption); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,8 +53,8 @@ public OrderDetail(Order order, String orderNumber, SaleProduct saleProduct, int | |
| } | ||
|
|
||
| public static OrderDetail from(Order order, SaleProduct saleProduct, int quantity){ | ||
| int orderPrice = saleProduct.getProduct().getOriginPrice(); | ||
| int paymentPrice = saleProduct.getProduct().getDiscountPrice(); | ||
| int orderPrice = saleProduct.getProduct().getProductInfo().getOriginPrice(); | ||
| int paymentPrice = saleProduct.getProduct().getProductInfo().getDiscountPrice(); | ||
|
Comment on lines
+56
to
+57
Contributor
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. 저는 이 부분이 메소드 체이닝의 문제라고 생각듭니다. 무언가가 변경되었을때 다른 곳에서도 변경이 되니까요..
Contributor
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. getProductInfo에 필드가 많아져서 또한번 embed로 만든다면?
Contributor
Author
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. 저도 이번에 embed를 분리하면서 생긴 사이드 이펙트를 겪고 주신 의견에 매우 큰 공감을 합니다.. |
||
| int discountPrice = orderPrice - paymentPrice; | ||
|
|
||
| if(saleProduct.getOption() != null){ | ||
|
|
||
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.
macOS 환경에서 Netty가 DNS를 해석하지 못하고 생기는 경고가 있었습니다. 실행에는 문제 없었으나 프로그램 실행시 나오는 경고를 해결하기 위해서 추가한 의존성입니다.