From 6d31d535d737ed26c4d9d61cd4e0b5483cb9b0ba Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Wed, 17 Sep 2025 19:44:00 +0800
Subject: [PATCH] Merge branch 'refs/heads/master' into xin
---
oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java b/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java
index dafd176..a0a2299 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java
@@ -1,6 +1,5 @@
package com.oying.modules.pc.product.rest;
-import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oying.annotation.Log;
@@ -12,12 +11,13 @@
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.utils.PageResult;
import com.oying.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
-import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -58,7 +58,7 @@
@GetMapping(value = "/batch")
@ApiOperation("查询商品(批量)")
// @PreAuthorize("@el.check('product:list')")
- public ResponseEntity<?> getProductsByIds(@RequestBody List<Long> ids) {
+ public ResponseEntity<?> getProductsByIds(@RequestParam(value = "ids") List<Long> ids) {
return ResponseEntity.ok(R.success(productService.listByIds(ids)));
}
@@ -67,10 +67,16 @@
// @PreAuthorize("@el.check('product:list')")
public ResponseEntity<?> getProductsByPage(ProductQueryCriteria criteria) {
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
- return ResponseEntity.ok(R.success(productService.queryAll(criteria, page)));
+ PageResult<Product> pageResult = productService.queryAll(criteria, page);
+ pageResult.getContent().forEach(product -> {
+ Long productId = product.getProductId();
+ product.setImages(productImageService.queryImagesByProductId(productId));
+ product.setLabels(productLabelService.queryLabelsByProductId(productId));
+ });
+ return ResponseEntity.ok(R.success(pageResult));
}
- @GetMapping(value = "/{productId}}")
+ @GetMapping(value = "/{productId}")
@ApiOperation("查询商品")
// @PreAuthorize("@el.check('product:list')")
public ResponseEntity<?> getProduct(@PathVariable Long productId) {
@@ -81,8 +87,8 @@
return ResponseEntity.ok(R.success(product));
}
- @GetMapping(value = "/{productId}}/details")
- @ApiOperation("查询商品")
+ @GetMapping(value = "/{productId}/details")
+ @ApiOperation("查询商品详情")
// @PreAuthorize("@el.check('product:list')")
public ResponseEntity<?> getProductDetails(@PathVariable Long productId) {
Product product = productService.getById(productId);
@@ -93,16 +99,16 @@
return ResponseEntity.ok(R.success(product));
}
- @GetMapping(value = "/{productId}}/images")
- @ApiOperation("查询商品")
+ @GetMapping(value = "/{productId}/images")
+ @ApiOperation("查询商品图片")
// @PreAuthorize("@el.check('product:list')")
public ResponseEntity<?> getProductImages(@PathVariable Long productId) {
return ResponseEntity.ok(R.success(productImageService.queryImagesByProductId(productId)));
}
- @GetMapping(value = "/{productId}}/labels")
- @ApiOperation("查询商品")
+ @GetMapping(value = "/{productId}/labels")
+ @ApiOperation("查询商品标签信息")
// @PreAuthorize("@el.check('product:list')")
public ResponseEntity<?> getProductLabels(@PathVariable Long productId) {
return ResponseEntity.ok(R.success(productLabelService.queryLabelsByProductId(productId)));
@@ -112,20 +118,16 @@
@Log("新增商品")
@ApiOperation("新增商品")
//@PreAuthorize("@el.check('merchant:product:add')")
- public ResponseEntity<?> createProduct(@PathVariable Long storeId,
- @Validated @RequestBody ProductMerchantCreateRequest request) {
- request.setStoreId(ObjectUtils.defaultIfNull(request.getStoreId(), storeId));
+ public ResponseEntity<?> createProduct(@Validated @RequestBody ProductMerchantCreateRequest request) {
productAdminService.create(request);
- return ResponseEntity.noContent().build();
+ return ResponseEntity.status(HttpStatus.CREATED).build();
}
@PutMapping
@Log("修改商品")
@ApiOperation("修改商品")
// @PreAuthorize("@el.check('product:edit')")
- public ResponseEntity<?> updateProduct(@PathVariable Long productId,
- @Validated @RequestBody ProductMerchantUpdateRequest request) {
- request.setProductId(ObjectUtils.defaultIfNull(request.getProductId(), productId));
+ public ResponseEntity<?> updateProduct(@Validated @RequestBody ProductMerchantUpdateRequest request) {
productAdminService.update(request);
return ResponseEntity.noContent().build();
}
--
Gitblit v1.9.3