Jelajahi Sumber

bugfix 增加浏览量

JiangChongBo 2 tahun lalu
induk
melakukan
25d0ecb18d

+ 11 - 0
src/main/java/com/caimei/www/controller/unlimited/EncyclopediaController.java

@@ -88,6 +88,15 @@ public class EncyclopediaController extends BaseController {
                 baikeproduct.setPublishTimeStr(sl.format(baikeproduct.getPublishTime()));
             }
         }
+        //初始化基础浏览量(防止报错)
+        if(null!=baikeproduct&&null==baikeproduct.getPv()){
+            //如果浏览量为空 则设置为0
+            productService.initializationPV(id);
+        }
+        if(null!=baikeproduct&&null!=baikeproduct.getPublishSource()&&baikeproduct.getPublishSource()==1){
+            //供应商发布的词条取实际浏览量,管理员发布的取基础浏览量加实际浏览量
+            baikeproduct.setPv(baikeproduct.getPv()+baikeproduct.getBasePv());
+        }
         //热搜词
         List<BaikeHotSearch> hotSeracherWords=productService.getHotWords();
         model.addAttribute("hotSeracherWords", hotSeracherWords);
@@ -95,6 +104,8 @@ public class EncyclopediaController extends BaseController {
         //分类集合
         List<BaikeTypeVo> typeList = productService.geTypeList();
         model.addAttribute("TypeList", typeList);
+        //增加浏览量
+        productService.encyclopediaPv(id);
         return ENCYCLOPEDIA_DETAIL;
     }
 

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

@@ -66,4 +66,5 @@ public interface BaikeDao {
     BaikeTypeVo geTypeListByid(Integer typeId);
 
 
+    void initializationPV(Integer productId);
 }

+ 4 - 0
src/main/java/com/caimei/www/pojo/baike/BaikeProductVo.java

@@ -55,6 +55,10 @@ public class BaikeProductVo implements Serializable {
      * 浏览量
      */
     private Integer pv;
+    /**
+     * 实际浏览量
+     */
+    private Integer basePv;
 
     /**
      * 问题列表

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

@@ -114,4 +114,9 @@ public interface ProductService {
 
     BaikeTypeVo geTypeListByid(Integer typeId);
 
+    /**
+     * 初始化话基础浏览量
+     * @param productId
+     */
+    void initializationPV(Integer productId);
 }

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

@@ -388,6 +388,10 @@ public class ProductServiceImpl implements ProductService {
         BaikeTypeVo typedata = baikeDao.geTypeListByid(typeId);
         return typedata;
     }
+    @Override
+    public void initializationPV(Integer productId){
+        baikeDao.initializationPV(productId);
+    }
 
     /**
      * 获取词条详细信息

+ 5 - 0
src/main/resources/mapper/BaikeMapper.xml

@@ -154,6 +154,7 @@
 			t.name as typeName,
 			p.publishSource,
 			p.shopId,
+			p.basePv,
 			p.seoKeyword
 		from cm_baike_product p
 				 left join cm_baike_type t on p.typeId=t.id
@@ -214,4 +215,8 @@
 		select  id as typeId,name,pcBanner,appBanner,bannerLink from cm_baike_type
 		where status=1 and id=#{typeId}
 	</select>
+
+	<update id="initializationPV">
+		update cm_baike_product set basePv=0 where id=#{productId}
+	</update>
 </mapper>