Skip to content

Commit

Permalink
Merge pull request #210 from Troth-Cam/fix/product
Browse files Browse the repository at this point in the history
fix(#125) : 로그 삭제
  • Loading branch information
aeeazip authored Aug 22, 2023
2 parents d773993 + 9fe739c commit cf434ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,18 @@ public BaseResponse<ProductsPagingListResDto> getProducts(@PathVariable String t

/* 메인 화면 페이징 처리 - 로그인0 */
@GetMapping("/{webId}/product-ranking/{type}/{page}")
public BaseResponse<ProductsPagingListResDto> getProducts(@PathVariable String webId, @PathVariable String type, @PathVariable int page) {
//log.info("Member: " + member.toString());
log.info("프론트 요청 webId: " + webId);
log.info("프론트 요청 webtype: " + type);
log.info("api 요청 들어옴");
// if(!member.getWebId().equals(webId)) {
// throw new BaseException(MEMBER_NOT_FOUND);
// }
//
// if(type.equals("top") && page >= 0) {
// log.info("top 조건 해당");
// return BaseResponse.onSuccess(productService.getProductsLikedTop(page, member));
// } else if (type.equals("latest") && page >= 0) {
// return BaseResponse.onSuccess(productService.getProductsLikedLatest(page, member));
// } else {
// throw new BaseException(REQUEST_ERROR);
// }
return BaseResponse.onSuccess(null);
public BaseResponse<ProductsPagingListResDto> getProducts(@PathVariable String webId, @PathVariable String type, @PathVariable int page, @AuthenticationPrincipal Member member) {
if(!member.getWebId().equals(webId)) {
throw new BaseException(MEMBER_NOT_FOUND);
}

if(type.equals("top") && page >= 0) {
return BaseResponse.onSuccess(productService.getProductsLikedTop(page, member));
} else if (type.equals("latest") && page >= 0) {
return BaseResponse.onSuccess(productService.getProductsLikedLatest(page, member));
} else {
throw new BaseException(REQUEST_ERROR);
}
}

/* view all */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,13 @@ public ProductsPagingListResDto getProductsLatest(int page) {
@Transactional
public ProductsPagingListResDto getProductsLikedTop(int page, Member member) {
try {
log.info("service 들어옴");
PageRequest pageRequest = PageRequest.of(page, 8);
log.info("pageRequest 멀라");
Page<ProductRepository.ProductTop> productTops = productRepository.findRankPagingDto(pageRequest);
log.info("productTops 조회");
List<ProductPagingResDto> topPagingLikedDto = productTops.stream()
.map(t -> {
Member owner = memberRepository.findById(t.getBuyerId()).orElseThrow(() -> new BaseException(MEMBER_NOT_FOUND));
log.info("멤버 받아옴");
Image image = imageRepository.findById(t.getImageId()).orElseThrow(() -> new BaseException(IMAGE_NOT_FOUND));
log.info("이미지 받아옴");
Optional<LikeProduct> like = likeProductRepository.findByProductIdAndMemberId(t.getProductId(), member.getId());
log.info("좋아요 검사함");

boolean liked = false;
if(like.isPresent()) {
Expand All @@ -285,7 +279,6 @@ public ProductsPagingListResDto getProductsLikedTop(int page, Member member) {
liked = false;
}

log.info("리턴 직전");
return new ProductPagingResDto(t.getHistoryId(), t.getProductId(), owner.getWebId(), owner.getWebToken(), owner.getName(),
image.getMember().getWebId(), image.getMember().getWebToken(), t.getTitle(), t.getTags(), image.getImageUrl(),
t.getPrice(), t.getSoldAt(), liked);
Expand Down

0 comments on commit cf434ce

Please sign in to comment.