
기획의도:
Mapper
//동일 category의 제품 추천받기. 상세보는 건 제외
@Select("SELECT * FROM products "
+ "WHERE category = #{category} "
+ "AND product_code != #{product_code} "
+ "ORDER BY product_code DESC "
+ "limit 3")
List<PrdVo> rcmPrdList(@Param("category") String category,
@Param("product_code") String product_code);
Ctrl
@GetMapping("viewPrd") //상품 상세보기
public String viewPrd(Model model, PrdVo vo, ReviewVo rvo) {
...
"revListSize", reviewList.size()); // 후기 건수
// 동일 category의 제품 추천받기. 상세보는 건 제외
List<PrdVo> rcmList = prdSvc.rcmPrdList(product.getCategory(), product.getProduct_code());
model.addAttribute("rcmList", rcmList);
return "prd/viewPrd";
}
Front
<!-- 추천 -->
<div style="width: 800px; display: flex; flex-wrap: wrap; justify-content: center;">
<div class="separator-horizontal"></div> <!------------------------- 수평선 -------------------------->
<div style="width: 100%;">
<div th:if="${session.username != null and session.loginType == 'user'}">
<span th:text="${session.username} + '님,'"></span>
</div>
<h3 style="margin-top: 0px;">이런 제품이 어떨까요?</h3>
</div>
<!-- 반목문 -->
</div> <!-- allPrdCtn 끝 -->
<!-- 추천 끝 -->