From 8e8986ee4e94a6b2f6c2420fa511fa3679758e52 Mon Sep 17 00:00:00 2001 From: SoohoLee Date: Wed, 14 Jun 2023 15:31:53 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20redis=20=EC=9C=84=EC=B9=98=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trendpick_pro/domain/common/base/rq/Rq.java | 11 ----------- .../domain/product/controller/ProductController.java | 10 +++++++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/project/trendpick_pro/domain/common/base/rq/Rq.java b/src/main/java/project/trendpick_pro/domain/common/base/rq/Rq.java index 5fbd150c..b0a8ec4e 100644 --- a/src/main/java/project/trendpick_pro/domain/common/base/rq/Rq.java +++ b/src/main/java/project/trendpick_pro/domain/common/base/rq/Rq.java @@ -181,17 +181,6 @@ public Optional CheckLogin() { } } - public RsData RsCheckLogin() { - - String username = SecurityContextHolder.getContext().getAuthentication().getName(); // 둘다 테스트 해보기 - Optional member = memberService.findByEmail(username); - - if (memberService.findByEmail(member.get().getEmail()).isPresent()) { - return RsData.of("F-1", "로그인된 상태가 아닙니다.", member.get()); - } - return RsData.of("S-1", "추천 카테고리입니다.", member.get()); - } - public boolean checkLogin(){ String username = SecurityContextHolder.getContext().getAuthentication().getName(); // 둘다 테스트 해보기 Optional member = memberService.findByEmail(username); diff --git a/src/main/java/project/trendpick_pro/domain/product/controller/ProductController.java b/src/main/java/project/trendpick_pro/domain/product/controller/ProductController.java index 9fedf3d2..6fa21f5b 100644 --- a/src/main/java/project/trendpick_pro/domain/product/controller/ProductController.java +++ b/src/main/java/project/trendpick_pro/domain/product/controller/ProductController.java @@ -7,6 +7,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @@ -21,6 +22,7 @@ import project.trendpick_pro.domain.common.base.rq.Rq; import project.trendpick_pro.domain.member.entity.Member; import project.trendpick_pro.domain.member.exception.MemberNotFoundException; +import project.trendpick_pro.domain.member.service.MemberService; import project.trendpick_pro.domain.product.entity.Product; import project.trendpick_pro.domain.product.entity.dto.request.ProductSaveRequest; import project.trendpick_pro.domain.product.entity.dto.response.ProductListResponseBySeller; @@ -45,6 +47,7 @@ public class ProductController { private final ProductService productService; private final RecommendService recommendService; + private final MemberService memberService; private final TagNameService tagNameService; private final BrandService brandService; @@ -147,8 +150,9 @@ public String showAllProduct(@RequestParam(value = "page", defaultValue = "0") i mainCategory = "상의"; } if (mainCategory.equals("추천")) { - RsData member = rq.RsCheckLogin(); - if (member.isFail()) { + String username = SecurityContextHolder.getContext().getAuthentication().getName(); + Optional member = memberService.findByEmail(username); + if (member.isPresent()) { model.addAttribute("subCategoryName", subCategory); model.addAttribute("mainCategoryName", mainCategory); model.addAttribute("productResponses", productService.showAll(offset, mainCategory, subCategory)); @@ -156,7 +160,7 @@ public String showAllProduct(@RequestParam(value = "page", defaultValue = "0") i } else { model.addAttribute("subCategoryName", subCategory); model.addAttribute("mainCategoryName", mainCategory); - model.addAttribute("productResponses", recommendService.getFindAll(member.getData(), offset)); + model.addAttribute("productResponses", recommendService.getFindAll(member.get(), offset)); model.addAttribute("subCategories", subCategoryService.findAll(mainCategory)); } } else if(mainCategory.equals("전체")){