Skip to content

Commit

Permalink
KAN-713 refactor: 통계관련 응답객체 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Koo-Tae-Ho committed Aug 3, 2024
1 parent 1b30b9a commit 7893311
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ public static class ProductOrderCount {

@Getter
@Builder
public static class OfGenderRank {
public static class OfStatisticsProduct {
private Long productId;
private String productName;
private String categoryName;
private String image;
private Long orderCount;
private double averageScore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public interface ProductManagementService {
ProductManagementResponse.OfRetrieveProductOrder retrieveProductInformation(Long productId);
Map<Long, ProductManagementResponse.OfRetrieveProductOrder> bulkRetrieveProductInformation(List<Long> productIdList);
List<ProductManagementResponse.OfOrderInformation> retrieveOrderInformation(StockUsageRequest.IncreaseStockUsageList increaseStockUsageList);
List<ProductManagementResponse.OfGenderRank> retrieveTopProductsByCondition(Long customerId, Gender gender, Integer ageRange, OrderType orderType);
List<ProductManagementResponse.OfStatisticsProduct> retrieveTopProductsByCondition(Long customerId, Gender gender, Integer ageRange, OrderType orderType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void uploadCertificationImage(Long productId, String imageUrl, ProductMan
*/
@Override
@Transactional
public List<ProductManagementResponse.OfGenderRank> retrieveTopProductsByCondition(Long customerId, Gender gender, Integer ageRange, OrderType orderType) {
public List<ProductManagementResponse.OfStatisticsProduct> retrieveTopProductsByCondition(Long customerId, Gender gender, Integer ageRange, OrderType orderType) {

ResponseEntity<ApiResponse<List<ProductManagementResponse.ProductOrderCount>>> productOrderCounts = null;
List<ProductManagementResponse.ProductOrderCount> productOrderCountList = null;
Expand All @@ -368,15 +368,16 @@ public List<ProductManagementResponse.OfGenderRank> retrieveTopProductsByConditi
}

//반환값 (상품 정보)
List<ProductManagementResponse.OfGenderRank> genderRanks = new ArrayList<>();
List<ProductManagementResponse.OfStatisticsProduct> genderRanks = new ArrayList<>();

for(ProductManagementResponse.ProductOrderCount productOrderCount : productOrderCountList){
Product targetProduct = productRepository.findById(productOrderCount.getProductId())
.orElseThrow(() -> new ProductException(PRODUCT_NOT_FOUND, HttpStatus.NOT_FOUND));

ProductManagementResponse.OfGenderRank genderRank = ProductManagementResponse.OfGenderRank.builder()
ProductManagementResponse.OfStatisticsProduct genderRank = ProductManagementResponse.OfStatisticsProduct.builder()
.productId(productOrderCount.getProductId())
.productName(targetProduct.getProductName())
.categoryName(targetProduct.getProductDetailCategory().getDetailCategoryName())
.image(targetProduct.getProductImage())
.orderCount(productOrderCount.getOrderCount())
.averageScore(targetProduct.getAverageScore())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ public ResponseEntity<ApiResponse> bulkRetrieveProductInformation(@RequestParam
.build(), HttpStatus.OK);
}

@Operation(summary = "고객의 성별 및 연령별 TOP3 상품정보 조회", description = "고객의 성별 및 연령별 TOP3 상품을 조회하는 기능입니다.")
@Operation(summary = "고객의 상품 통계정보 조회", description = "고객의 상품들의 통계정보를 조회하는 기능입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "상품 정보 조회 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "상품 정보 조회 실패")
})
@GetMapping("/ranking/gender-product")
@GetMapping("/ranking/statistics-product")
public ResponseEntity<ApiResponse> getProductByCondition(@RequestParam Long customerId,
@RequestParam(required = false) Gender gender,
@RequestParam(required = false) Integer ageRange,
Expand Down

0 comments on commit 7893311

Please sign in to comment.