Sfoglia il codice sorgente

1.3.3采美百科与词条详情功能优化

JiangChongBo 2 anni fa
parent
commit
28bb63781a

+ 21 - 4
src/main/java/com/caimei/www/controller/unlimited/EncyclopediaController.java

@@ -2,6 +2,7 @@ package com.caimei.www.controller.unlimited;
 
 import com.caimei.www.controller.BaseController;
 import com.caimei.www.pojo.baike.BaikeProductVo;
+import com.caimei.www.pojo.baike.BaikeTypeVo;
 import com.caimei.www.service.page.ProductService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -36,11 +38,17 @@ public class EncyclopediaController extends BaseController {
     /*
      * 百科首页
      * */
-    @GetMapping("/list.html")
-    public String getEncyclopediaList(final Model model) {
-        String entryName=null;
-        List<BaikeProductVo> authUserList = productService.getAuthUserList(entryName);
+    @GetMapping("/list-{typeId}.html")
+    public String getEncyclopediaList(final Model model,@PathVariable("typeId") Integer typeId) {
+        //词条信息
+        List<BaikeProductVo> authUserList = productService.getAuthUserList(typeId);
+        //分类集合
+        List<BaikeTypeVo> TypeList = productService.geTypeList();
+        //热搜词
+        List<String> hotSeracherWords=productService.getHotWords(typeId);
         model.addAttribute("authUserList", authUserList);
+        model.addAttribute("TypeList", TypeList);
+        model.addAttribute("hotSeracherWords", hotSeracherWords);
         return ENCYCLOPEDIA_LIST;
     }
 
@@ -50,6 +58,9 @@ public class EncyclopediaController extends BaseController {
     @GetMapping("/detail-{id}.html")
     public String getEncyclopediaDetail(final Model model, @PathVariable("id") Integer id) {
         BaikeProductVo baikeproduct = productService.getEncyclopediaDetail(id);
+        //热搜词
+        List<String> hotSeracherWords=productService.getHotWords(null);
+        model.addAttribute("hotSeracherWords", hotSeracherWords);
         model.addAttribute("baikeproduct", baikeproduct);
         return ENCYCLOPEDIA_DETAIL;
     }
@@ -59,6 +70,9 @@ public class EncyclopediaController extends BaseController {
      * */
     @GetMapping("/search.html")
     public String getEncyclopediaSearch(final Model model) {
+        //热搜词
+        List<String> hotSeracherWords=productService.getHotWords(null);
+        model.addAttribute("hotSeracherWords", hotSeracherWords);
         return ENCYCLOPEDIA_SEARCH;
     }
 
@@ -67,6 +81,9 @@ public class EncyclopediaController extends BaseController {
      * */
     @GetMapping("/about.html")
     public String getEncyclopediaAbout(final Model model) {
+        //热搜词
+        List<String> hotSeracherWords=productService.getHotWords(null);
+        model.addAttribute("hotSeracherWords", hotSeracherWords);
         return ENCYCLOPEDIA_ABOUT;
     }
 }

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

@@ -43,7 +43,10 @@ public interface BaikeDao {
     List<BaikeProduct> getAutoRecommendList(Integer publishSource, @Param("shopId") Integer shopId, @Param("typeId") Integer typeId, @Param("productId") Integer productId);
 
 
-    List<BaikeProductVo> getAuthUserList(String entryName);
+    List<BaikeProductVo> getAuthUserList(Integer typeId);
+
+    List<String> getHotWords(Integer typeId);
+
 
     BaikeProductVo getEntryInfoById(Integer id);
 
@@ -58,5 +61,8 @@ public interface BaikeDao {
 
     List<CmBaikeReferenceInfo> getReferenceListById(Integer id);
 
+    List<BaikeTypeVo> geTypeList();
+
+
 
 }

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

@@ -116,7 +116,7 @@ public class BaikeProductVo implements Serializable {
     /**
      * 分类集合
      */
-//    private List<BaikeTypeVo> typeList;
+    private List<BaikeTypeVo> typeList;
     /**
      * 视频列表
      */

+ 22 - 0
src/main/java/com/caimei/www/pojo/baike/BaikeTypeVo.java

@@ -0,0 +1,22 @@
+package com.caimei.www.pojo.baike;
+
+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 typeId;
+    private String name;
+    private List<BaikeProductVo> productList;
+
+}

+ 7 - 1
src/main/java/com/caimei/www/service/page/ProductService.java

@@ -6,6 +6,7 @@ import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.baike.BaikeProduct;
 import com.caimei.www.pojo.baike.BaikeProductVo;
 import com.caimei.www.pojo.baike.BaikeType;
+import com.caimei.www.pojo.baike.BaikeTypeVo;
 import com.caimei.www.pojo.page.Parameter;
 import com.caimei.www.pojo.page.ProductDetail;
 import com.caimei.www.pojo.page.ProductList;
@@ -105,7 +106,12 @@ public interface ProductService {
     List<ProductList> getProductLists(Integer productId);
 
 
-    List<BaikeProductVo> getAuthUserList(String entryName);
+    List<BaikeProductVo> getAuthUserList(Integer typeId);
+
+    List<String> getHotWords(Integer typeId);
+
 
     BaikeProductVo getEncyclopediaDetail(Integer id);
+
+    List<BaikeTypeVo> geTypeList();
 }

+ 34 - 2
src/main/java/com/caimei/www/service/page/impl/ProductServiceImpl.java

@@ -333,12 +333,44 @@ public class ProductServiceImpl implements ProductService {
         baikeDao.encyclopediaPv(id);
         return JsonModel.success();
     }
+
+    /**
+     * 获取词条信息
+     * @param typeId
+     * @return
+     */
+    @Override
+    public List<BaikeProductVo> getAuthUserList(Integer typeId){
+        List<BaikeProductVo> authUserList = baikeDao.getAuthUserList(typeId);
+        return authUserList;
+    }
+
+    /**
+     * 获取热搜词
+     * @param typeId
+     * @return
+     */
     @Override
-    public List<BaikeProductVo> getAuthUserList(String entryName){
-        List<BaikeProductVo> authUserList = baikeDao.getAuthUserList(entryName);
+    public List<String> getHotWords(Integer typeId){
+        List<String> authUserList = baikeDao.getHotWords(typeId);
         return authUserList;
     }
 
+    /**
+     * 获取分类信息
+     * @return
+     */
+    @Override
+    public List<BaikeTypeVo> geTypeList(){
+        List<BaikeTypeVo> TypeList = baikeDao.geTypeList();
+        return TypeList;
+    }
+
+    /**
+     * 获取词条详细信息
+     * @param id
+     * @return
+     */
     @Override
     public BaikeProductVo getEncyclopediaDetail(Integer id){
         //获取词条基本信息

+ 19 - 3
src/main/resources/mapper/BaikeMapper.xml

@@ -109,13 +109,25 @@
 		p.discription,
 		p.actualPv as pv,
 		p.publishTime,
+		p.typeId,
 		p.image
 		from cm_baike_product p
 		left join cm_baike_type t on p.typeId=t.id
-		where 1=1
-		<if test="null !=name and '' != name">
-			and  p.name like concat('%',#{entryName},'%')
+		where
+		  p.typeId =#{typeId}
+		order by p.publishTime desc
+	</select>
+
+	<select id="getHotWords" resultType="java.lang.String">
+		select
+			p.name
+		from cm_baike_product p
+				 left join cm_baike_type t on p.typeId=t.id
+		where
+		<if test="null != typeId and '' !=typeId">
+			p.typeId =#{typeId}
 		</if>
+		order by p.actualPv desc limit 10
 	</select>
 
 	<select id="getEntryInfoById" resultType="com.caimei.www.pojo.baike.BaikeProductVo">
@@ -186,4 +198,8 @@
 		from cm_baike_product_file
 		where productId = #{id}
 	</select>
+
+	<select id="geTypeList"  resultType="com.caimei.www.pojo.baike.BaikeTypeVo">
+		select  id as typeId,name from cm_baike_type
+	</select>
 </mapper>