浏览代码

Merge remote-tracking branch 'origin/developerA' into developerA

喻文俊 3 年之前
父节点
当前提交
2a2c3527f4

+ 28 - 15
src/main/java/com/caimei/www/controller/unlimited/EncyclopediaController.java

@@ -2,19 +2,24 @@ package com.caimei.www.controller.unlimited;
 
 import com.alibaba.fastjson.JSONArray;
 import com.caimei.www.controller.BaseController;
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.BaikeProduct;
 import com.caimei.www.pojo.baike.BaikeType;
 import com.caimei.www.pojo.page.ImageLink;
 import com.caimei.www.service.page.BaseService;
 import com.caimei.www.service.page.ProductService;
+import com.google.gson.JsonArray;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 采美文库
@@ -23,6 +28,7 @@ import java.util.List;
  * @date : 2021/11/23
  */
 @Controller
+@RequestMapping("/encyclopedia")
 public class EncyclopediaController extends BaseController {
 
     private static final String PRODUCT_LIST = "encyclopedia/product";
@@ -53,7 +59,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 产品列表
      */
-    @GetMapping("/encyclopedia/product.html")
+    @GetMapping("/product.html")
     public String getProductList(final Model model) {
         Integer commodityType = 1;
         // 搜索热门关键字
@@ -74,7 +80,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 产品详情
      */
-    @GetMapping("/encyclopedia/product-{id}.html")
+    @GetMapping("/product-{id}.html")
     public String getProductDetail(final Model model, @PathVariable("id") Integer productId) {
         BaikeProduct baikeProduct = productService.getBaikeProductDetail(productId);
         if (baikeProduct == null) {
@@ -87,7 +93,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 仪器列表
      */
-    @GetMapping("/encyclopedia/instrument.html")
+    @GetMapping("/instrument.html")
     public String getInstrumentList(final Model model) {
         Integer commodityType = 2;
         // 搜索热门关键字
@@ -108,7 +114,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 仪器详情
      */
-    @GetMapping("/encyclopedia/instrument-{id}.html")
+    @GetMapping("/instrument-{id}.html")
     public String getInstrumentDetail(final Model model, @PathVariable("id") Integer productId) {
         BaikeProduct baikeInstrument = productService.getBaikeProductDetail(productId);
         if (baikeInstrument == null) {
@@ -121,20 +127,17 @@ public class EncyclopediaController extends BaseController {
     /**
      * 查看更多
      */
-    @GetMapping("/encyclopedia/more.html")
-    public String getMoreList(final Model model) {
-        ArrayList<Object> list = new ArrayList<>();
-        for (int i=0; i< 1000 ; i++){
-            list.add(new Object());
-        }
-        model.addAttribute("list", list);
+    @GetMapping("/more-{typeId}-{pageNum}-{pageSize}.html")
+    public String getMoreList(final Model model, @PathVariable("typeId") Integer typeId, @PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
+        Map<String, Object> moreData = productService.getBaikeMoreJson(typeId, pageNum, pageSize);
+        model.addAttribute("moreData", moreData);
         return MORE_LIST;
     }
 
     /**
      * 搜索列表
      */
-    @GetMapping("/encyclopedia/search.html")
+    @GetMapping("/search.html")
     public String getSearchPage() {
         return SEARCH_PAGE;
     }
@@ -142,7 +145,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 联系我们
      */
-    @GetMapping("/encyclopedia/contact.html")
+    @GetMapping("/contact.html")
     public String getContact() {
         return CONTACT;
     }
@@ -150,7 +153,7 @@ public class EncyclopediaController extends BaseController {
     /**
      * 关于我们
      */
-    @GetMapping("/encyclopedia/about.html")
+    @GetMapping("/about.html")
     public String getAboutUs() {
         return ABOUT_US;
     }
@@ -158,8 +161,18 @@ public class EncyclopediaController extends BaseController {
     /**
      * 关于我们位置定位
      */
-    @GetMapping("/encyclopedia/map.html")
+    @GetMapping("/map.html")
     public String getMap() {
         return MAP;
     }
+
+    /**
+     * 增加浏览量
+     */
+    @GetMapping("/pv")
+    @ResponseBody
+    public JsonModel encyclopediaPv(Integer id) {
+        return productService.encyclopediaPv(id);
+    }
+
 }

+ 2 - 0
src/main/java/com/caimei/www/mapper/BaikeDao.java

@@ -39,4 +39,6 @@ public interface BaikeDao {
     List<String> findImageList(@Param("productId") Integer productId, @Param("imageType") int imageType);
 
     List<BaikeProductQuestion> findQuestionList(Integer productId);
+
+    void encyclopediaPv(Integer id);
 }

+ 1 - 1
src/main/java/com/caimei/www/pojo/baike/BaikeProduct.java

@@ -64,7 +64,7 @@ public class BaikeProduct implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date marketTime;
     /**
-     * 公司/供应
+     * 公司/
      */
     private String company;
     /**

+ 17 - 0
src/main/java/com/caimei/www/service/page/ProductService.java

@@ -2,6 +2,7 @@ package com.caimei.www.service.page;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.BaikeProduct;
 import com.caimei.www.pojo.page.ProductDetail;
 
@@ -68,4 +69,20 @@ public interface ProductService {
      * 获取采美百科产品/仪器详情数据
      */
     BaikeProduct getBaikeProductDetail(Integer productId);
+
+    /**
+     * 增加采美百科浏览量
+     * @param id  产品/仪器id
+     * @return
+     */
+    JsonModel encyclopediaPv(Integer id);
+
+    /**
+     * 更多页面数据
+     * @param typeId    分类id
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    Map<String, Object> getBaikeMoreJson(Integer typeId, Integer pageNum, Integer pageSize);
 }

+ 21 - 0
src/main/java/com/caimei/www/service/page/impl/ProductServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.www.mapper.BaikeDao;
 import com.caimei.www.mapper.ProductDao;
+import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.BaikeProduct;
 import com.caimei.www.pojo.baike.BaikeProductParam;
 import com.caimei.www.pojo.baike.BaikeProductQuestion;
@@ -191,6 +192,20 @@ public class ProductServiceImpl implements ProductService {
         }
     }
 
+    @Override
+    public Map<String, Object> getBaikeMoreJson(Integer typeId, Integer pageNum, Integer pageSize) {
+        String dataUrl = coreServer + "/commodity/baike/type?typeId=" + typeId + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
+        try {
+            String moreResult = RequestUtil.sendGet(dataUrl);
+            log.debug(moreResult);
+            Map<String, Object> moreMap = JSONObject.parseObject(moreResult, Map.class);
+            return JSONObject.parseObject(String.valueOf(moreMap.get("data")), Map.class);
+        } catch (Exception e) {
+            log.error("try-catch:",e);
+            return null;
+        }
+    }
+
     @Override
     public BaikeProduct getBaikeProductDetail(Integer productId) {
         BaikeProduct baikeProduct = baikeDao.getBaikeProductDetail(productId);
@@ -210,4 +225,10 @@ public class ProductServiceImpl implements ProductService {
         }
         return baikeProduct;
     }
+
+    @Override
+    public JsonModel encyclopediaPv(Integer id) {
+        baikeDao.encyclopediaPv(id);
+        return JsonModel.success();
+    }
 }

+ 4 - 1
src/main/resources/mapper/BaikeMapper.xml

@@ -1,7 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.www.mapper.BaikeDao">
-    <select id="getBaikeProductDetail" resultType="com.caimei.www.pojo.baike.BaikeProduct">
+	<update id="encyclopediaPv">
+		update cm_baike_product set actualPv = actualPv + 1 where id = #{id}
+	</update>
+	<select id="getBaikeProductDetail" resultType="com.caimei.www.pojo.baike.BaikeProduct">
 		select a.id              AS "id",
 			   a.commodityType   AS "commodityType",
 			   a.name            AS "name",