From 6e0a83c55db4bae4d23a4c281946bda1d610f678 Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Sat, 14 Jun 2025 12:32:31 +0800
Subject: [PATCH] 补充前次提交的遗漏内容,前次提交SHA:a6f4dd

---
 oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java |   49 +++++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java b/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java
index c778cf8..38a2427 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java
@@ -1,13 +1,20 @@
 package com.oying.modules.pc.product.rest;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
 import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.ObjUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.oying.utils.R;
 import com.oying.modules.pc.product.domain.Product;
 import com.oying.modules.pc.product.domain.dto.ProductQueryCriteria;
+import com.oying.modules.pc.product.service.ProductImageService;
+import com.oying.modules.pc.product.service.ProductLabelService;
 import com.oying.modules.pc.product.service.ProductService;
 import com.oying.modules.pc.product.view.ProductCustomerView;
+import com.oying.modules.pc.product.view.ProductImageCustomerView;
+import com.oying.modules.pc.product.view.ProductLabelCustomerView;
 import com.oying.utils.PageResult;
+import com.oying.utils.R;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -20,11 +27,11 @@
 import java.util.stream.Collectors;
 
 /*
-*
+ *
  * @author lzp
  * @date 2025-04-30
  *
-*/
+ */
 @RestController
 @RequiredArgsConstructor
 @Api(tags = "商品(客户端)")
@@ -32,14 +39,16 @@
 public class ProductCustomerController {
 
     private final ProductService productService;
+    private final ProductImageService productImageService;
+    private final ProductLabelService productLabelService;
 
     @GetMapping(value = "/page")
     @ApiOperation("根据商品名称模糊匹配店铺内的商品")
     /*@PreAuthorize("@el.check('merchant:product:page')")*/
-    public ResponseEntity<?> query(@PathVariable Long storeId,
-                                   @RequestParam(value = "categoryId", required = false) Long categoryId,
-                                   @RequestParam(value = "secondCategoryId", required = false) Long secondCategoryId,
-                                   @RequestParam(value = "blurry", required = false) String blurry) {
+    public ResponseEntity<?> getProductsByPage(@PathVariable Long storeId,
+                                               @RequestParam(value = "categoryId", required = false) Long categoryId,
+                                               @RequestParam(value = "secondCategoryId", required = false) Long secondCategoryId,
+                                               @RequestParam(value = "blurry", required = false) String blurry) {
 
         ProductQueryCriteria criteria = new ProductQueryCriteria();
         criteria.setStoreId(storeId);
@@ -54,9 +63,7 @@
         PageResult<ProductCustomerView> viewPageResult = new PageResult<>(
                 productList.stream().map(i -> {
                     ProductCustomerView view = new ProductCustomerView();
-                    BeanUtils.copyProperties(i, view);
-                    view.setScore(5.0D);
-                    view.setSold(0);
+                    BeanUtil.copyProperties(i, view);
                     return view;
                 }).collect(Collectors.toList()),
                 productPageResult.getTotalElements());
@@ -66,16 +73,22 @@
     @GetMapping(value = "/{productId}/details")
     @ApiOperation("查询商品")
     /*@PreAuthorize("@el.check('merchant:product:byProductId')")*/
-    public ResponseEntity<?> getDetails(@PathVariable Long productId) {
+    public ResponseEntity<?> getProductDetails(@PathVariable Long productId) {
         Product product = productService.getById(productId);
         ProductCustomerView customerView = new ProductCustomerView();
-        customerView.setProductId(product.getProductId());
-        customerView.setTitle(product.getTitle());
-        customerView.setPrice(product.getPrice());
-        customerView.setScore(5.0D);
-        customerView.setSold(0);
-        customerView.setLabelList(ListUtil.empty());
-        customerView.setMainImageList(ListUtil.empty());
+        BeanUtil.copyProperties(product, customerView);
+        if (ObjUtil.isNotEmpty(product)) {
+            customerView.setImages(productImageService.queryImagesByProductId(productId).stream().map(i -> {
+                ProductImageCustomerView imageCustomerView = new ProductImageCustomerView();
+                BeanUtil.copyProperties(i, imageCustomerView, CopyOptions.create().setIgnoreNullValue(true));
+                return imageCustomerView;
+            }).collect(Collectors.toList()));
+            customerView.setLabels(productLabelService.queryLabelsByProductId(productId).stream().map(i -> {
+                ProductLabelCustomerView labelCustomerView = new ProductLabelCustomerView();
+                BeanUtil.copyProperties(i, labelCustomerView, CopyOptions.create().setIgnoreNullValue(true));
+                return labelCustomerView;
+            }).collect(Collectors.toList()));
+        }
         return ResponseEntity.ok(R.success(customerView));
     }
 

--
Gitblit v1.9.3