소스 검색

采美百科数据part1

Aslee 3 년 전
부모
커밋
9b91f9f3a9

+ 15 - 0
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import javax.ws.rs.GET;
 import java.util.List;
 import java.util.Map;
 
@@ -373,4 +374,18 @@ public class ProductPageApi {
         }
         return pageService.getAuthProductDetails(productId);
     }
+
+    /**
+     * 采美百科产品仪器页面数据
+     */
+    @ApiOperation("采美百科产品仪器分类数据")
+    @ApiImplicitParam(required = false, name = "commodityType", value = "商品类型:1产品,2仪器")
+    @GetMapping("/baike/type")
+    public ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType){
+        if (null == commodityType) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return pageService.getBaikeTypeData(commodityType);
+    }
+
 }

+ 16 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -331,4 +331,20 @@ public interface PageMapper {
      * 查询正品联盟商品参数
      */
     List<BrandProductParamPo> getAuthProductParams(Integer productId);
+    /**
+     * 查询首页置顶百科
+     */
+    List<BaikeProductVo> getSidebarBaike();
+    /**
+     * 查询采美百科分类列表
+     */
+    List<BaikeTypeVo> getBaikeTypeList(Integer commodityType);
+    /**
+     * 根据百科分类id查询对应商品
+     */
+    List<BaikeProductVo> getBaikeTypeProducts(Integer id);
+    /**
+     * 根据商品id查询问题列表
+     */
+    List<String> getBaikeQuestionList(Integer productId);
 }

+ 51 - 0
src/main/java/com/caimei365/commodity/model/vo/BaikeProductVo.java

@@ -0,0 +1,51 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/11/25
+ */
+@Data
+public class BaikeProductVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer productId;
+
+    /**
+     * 产品/仪器图片
+     */
+    private String image;
+
+    /**
+     * 产品/仪器名称
+     */
+    private String name;
+
+    /**
+     * 概述
+     */
+    private String discription;
+
+    /**
+     * 发布时间
+     */
+    private Date publishTime;
+
+    /**
+     * 浏览量
+     */
+    private Integer pv;
+
+    /**
+     * 问题列表
+     */
+    private List<String> questionList;
+}

+ 22 - 0
src/main/java/com/caimei365/commodity/model/vo/BaikeTypeVo.java

@@ -0,0 +1,22 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2020/11/25
+ */
+@Data
+public class BaikeTypeVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    private String name;
+    private List<BaikeProductVo> productList;
+
+}

+ 6 - 0
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -199,4 +199,10 @@ public interface PageService {
      * @return
      */
     ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId);
+
+    /**
+     * 采美百科产品仪器页面数据
+     * @param commodityType 商品类型:1产品,2仪器
+     */
+    ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType);
 }

+ 20 - 0
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -284,6 +284,9 @@ public class PageServiceImpl implements PageService {
         // 直播宣传图
         String liveAdvertisingImage = pageMapper.getLiveAdvertisingImage();
         map.put("liveImage", liveAdvertisingImage);
+        // 热门百科导航
+        List <BaikeProductVo> baikeList = pageMapper.getSidebarBaike();
+        map.put("baikeList", baikeList);
         return ResponseJson.success(map);
     }
 
@@ -1214,4 +1217,21 @@ public class PageServiceImpl implements PageService {
         authProduct.setParamList(pageMapper.getAuthProductParams(productId));
         return ResponseJson.success(authProduct);
     }
+
+    @Override
+    public ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType) {
+        // 分类列表
+        List<BaikeTypeVo> baikeTypeList = pageMapper.getBaikeTypeList(commodityType);
+        baikeTypeList.forEach(baikeType->{
+            // 产品/仪器列表
+            List<BaikeProductVo> productList = pageMapper.getBaikeTypeProducts(baikeType.getId());
+            productList.forEach(product ->{
+                // 问题列表
+                List<String> questionList = pageMapper.getBaikeQuestionList(product.getProductId());
+                product.setQuestionList(questionList);
+            });
+            baikeType.setProductList(productList);
+        });
+        return ResponseJson.success(baikeTypeList);
+    }
 }

+ 20 - 0
src/main/resources/mapper/PageMapper.xml

@@ -696,5 +696,25 @@
         from cm_brand_product_param
         where productId = #{productId}
     </select>
+    <select id="getSidebarBaike" resultType="com.caimei365.commodity.model.vo.BaikeProductVo">
+        select id as productId, name, image
+        from cm_baike_product
+        WHERE topPosition IN (1, 2, 3)
+        order by topPosition
+    </select>
+    <select id="getBaikeTypeList" resultType="com.caimei365.commodity.model.vo.BaikeTypeVo">
+        select id, name
+        from cm_baike_type
+        where if(#{commodityType} = 1, typeSort = 1, typeSort = 2) and status = 1
+        order by -sort desc,addTime desc
+    </select>
+    <select id="getBaikeTypeProducts" resultType="com.caimei365.commodity.model.vo.BaikeProductVo">
+        select id as productId, name, discription, publishTime, (basePv + actualPv) as pv
+        from cm_baike_product
+        where typeId = #{id}
+    </select>
+    <select id="getBaikeQuestionList" resultType="java.lang.String">
+        select question from cm_baike_product_question where productId = #{productId}
+    </select>
 
 </mapper>

+ 1 - 0
src/main/resources/mapper/SearchMapper.xml

@@ -261,6 +261,7 @@
         <include refid="Article_Joins"/>
         where a.id = #{articleId}
         and a.enabledStatus = 1
+        and a.auditStatus = 2
     </select>
     <select id="findLabelIdsByName" resultType="java.lang.Integer">
         select id