From 4b4e21c52a50b4a2ac9c750c523c00db0e09d4d5 Mon Sep 17 00:00:00 2001
From: chen-xin-zhi <3588068430@qq.com>
Date: Fri, 8 Nov 2024 18:44:37 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=88=86=E9=A1=B5?=
 =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AE=A2=E5=8D=95=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../controller/good/CartRecordController.java |  2 ++
 .../controller/good/GoodController.java       | 21 +++++++++++++++++++
 .../model/dto/cart/CartRecordAddRequest.java  |  6 ++++++
 .../heritage/model/entity/CartRecord.java     |  5 +++++
 .../heritage/model/vo/CartRecordVO.java       |  8 +++++--
 .../good/impl/CartRecordServiceImpl.java      |  3 ++-
 6 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java b/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java
index d05ecdc..e250a98 100644
--- a/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java
+++ b/src/main/java/com/cultural/heritage/controller/good/CartRecordController.java
@@ -110,4 +110,6 @@ public class CartRecordController {
         List<CartRecordVO> cartRecordVOList = cartRecordService.transformToCartRecordVOList(list);
         return ResultUtils.success(cartRecordVOList);
     }
+
+
 }
diff --git a/src/main/java/com/cultural/heritage/controller/good/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java
index 5fe2018..76e962f 100644
--- a/src/main/java/com/cultural/heritage/controller/good/GoodController.java
+++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java
@@ -144,4 +144,25 @@ public class GoodController {
 
 
 
+
+
+    /**
+     * 根据id查询商品
+     * @param getByIdRequest  根据id查询请求体
+     * @return  商品信息
+     */
+    @PostMapping("/getById")
+    @Operation(summary = "根据id查询商品", description = "参数:商品根据id查询请求体,权限:管理员(admin, boss), 方法名:getGoodById")
+    public BaseResponse<Good> getGoodById(@RequestBody CommonRequest getByIdRequest) {
+        if (getByIdRequest == null || getByIdRequest.getId() <= 0) {
+            throw new BusinessException(ErrorCode.PARAMS_ERROR);
+        }
+        Long id = getByIdRequest.getId();
+        Good good = goodService.getById(id);
+        ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR);
+        return ResultUtils.success(good);
+    }
+
+
+
 }
diff --git a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java
index 7dfcda9..390037f 100644
--- a/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java
+++ b/src/main/java/com/cultural/heritage/model/dto/cart/CartRecordAddRequest.java
@@ -34,6 +34,12 @@ public class CartRecordAddRequest implements Serializable {
     @Schema(description = "小计(商品单价 * 数量)", example = "60")
     private Double subtotal;
 
+    /**
+     * 是否是常规类商品
+     */
+    @Schema(description = "是否是常规类商品", example = "1")
+    private Integer isGoodType;
+
 
 
     @Serial
diff --git a/src/main/java/com/cultural/heritage/model/entity/CartRecord.java b/src/main/java/com/cultural/heritage/model/entity/CartRecord.java
index 63483df..2831368 100644
--- a/src/main/java/com/cultural/heritage/model/entity/CartRecord.java
+++ b/src/main/java/com/cultural/heritage/model/entity/CartRecord.java
@@ -52,6 +52,11 @@ public class CartRecord implements Serializable {
      */
     private Date updateTime;
 
+    /**
+     * 是否为商品类型
+     */
+    private Integer isGoodType;
+
 
     @Serial
     private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/cultural/heritage/model/vo/CartRecordVO.java b/src/main/java/com/cultural/heritage/model/vo/CartRecordVO.java
index 25e19f6..3c85668 100644
--- a/src/main/java/com/cultural/heritage/model/vo/CartRecordVO.java
+++ b/src/main/java/com/cultural/heritage/model/vo/CartRecordVO.java
@@ -4,8 +4,6 @@ import lombok.Data;
 
 import java.io.Serial;
 import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
 
 @Data
 public class CartRecordVO implements Serializable {
@@ -42,6 +40,12 @@ public class CartRecordVO implements Serializable {
      */
     private GoodVO goodVO;
 
+    /**
+     * 是否是常规类商品
+     */
+    private Integer isGoodType;
+
+
 
     @Serial
     private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java b/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java
index c7af1ef..7689b84 100644
--- a/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java
+++ b/src/main/java/com/cultural/heritage/service/good/impl/CartRecordServiceImpl.java
@@ -16,7 +16,6 @@ import jakarta.annotation.Resource;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
 import java.util.List;
 
 @Service
@@ -51,6 +50,8 @@ public class CartRecordServiceImpl extends ServiceImpl<CartRecordMapper, CartRec
         return true;
     }
 
+
+
     /**
      * 封装用户购物车中的商品信息
      */