Browse Source

首页基础数据

chao 3 years ago
parent
commit
ebf9f43305

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

@@ -81,6 +81,19 @@ public class ProductPageApi {
         return pageService.getHomeData(userId, source);
     }
 
+    /**
+     * 首页基础数据(小程序)
+     *
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @ApiOperation("首页楼层数据(旧:/home/init)")
+    @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+    @GetMapping("/home/init")
+    public ResponseJson<Map<String, Object>> getHomeInit(Integer source) {
+        return pageService.getHomeInit(source);
+    }
+
+
     /**
      * 活动专题楼层数据(美博会)
      *

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

@@ -3,6 +3,7 @@ package com.caimei365.commodity.mapper;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -99,4 +100,27 @@ public interface PageMapper {
     List<ProductListVo> getAutoProductRecommends(Integer productId);
     /** 页面数据 */
     CmPageVo findCmPageById(Integer pageId);
+    /**
+     * 获取搜索热门关键字
+     */
+    List<String> getSearchKeyword();
+
+    /**
+     * 获取头部菜单
+     */
+    List<TopMenuVo> getTopMenus(Integer source);
+    /**
+     * 获取底部链接分类
+     */
+    List<BaseLinkVo> getHelpPageTypes();
+
+    /**
+     * 根据分类获取底部链接
+     */
+    List<BaseLinkVo> getHelpPagesByType(@Param("typeId") Integer typeId);
+
+    /**
+     * 获取友情链接
+     */
+    List<BaseLinkVo> getFriendLinks();
 }

+ 23 - 0
src/main/java/com/caimei365/commodity/model/vo/BaseLinkVo.java

@@ -0,0 +1,23 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/27
+ */
+@Data
+public class BaseLinkVo implements Serializable{
+    private static final long serialVersionUID = 1L;
+	private Integer id;
+	private Integer typeId;
+	private String name;
+	private String link;
+	private Double sort;
+	private List<BaseLinkVo> linkList;
+}

+ 56 - 0
src/main/java/com/caimei365/commodity/model/vo/TopMenuVo.java

@@ -0,0 +1,56 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/27
+ */
+@Data
+public class TopMenuVo implements Serializable {
+    private Integer id;
+
+    /**
+     * 菜单名称
+     */
+    private String name;
+
+    /**
+     * 一级导航栏类型 0启用二级导航跳转 1启用链接跳转(已废弃)
+     */
+    private String type;
+
+    /**
+     * 跳转链接
+     */
+    private String link;
+
+    /**
+     * 图标
+     */
+    private String icon;
+
+    /**
+     * 排序
+     */
+    private String sort;
+
+    /**
+     * 链接类型 -1未知类型 1二级页面 2项目仪器 3直播页面 4自由页面 5商品详情 6项目仪器详情
+     * 7供应商主页 8专题活动页 9二手市场介绍 10二手商品列表 11二手商品发布 12商品搜索 13信息详情
+     * 14品牌招商介绍页 15维修保养介绍页 16首页 17注册页 18信息中心 19供应商列表
+     */
+    private Integer linkType;
+
+    /**
+     * 链接包含的参数
+     */
+    private Map<String, Object> linkParam;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -40,6 +40,12 @@ public interface PageService {
      */
     ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source);
 
+    /**
+     * 首页基础数据(小程序)
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getHomeInit(Integer source);
+
     /**
      * 活动专题楼层数据(美博会)
      *

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

@@ -25,6 +25,7 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Description
@@ -158,6 +159,52 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(map);
     }
 
+    /**
+     * 首页基础数据(小程序)
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getHomeInit(Integer source) {
+        Map<String, Object> map = new HashMap<>(4);
+        // 搜索热门关键字
+        List<String> searchHotWord = pageMapper.getSearchKeyword();
+        if (!CollectionUtils.isEmpty(searchHotWord) && searchHotWord.size() > 8) {
+            searchHotWord.parallelStream()
+                    .filter(str -> !StringUtils.isEmpty(str)).limit(8)
+                    .collect(Collectors.toList());
+        }
+        map.put("searchHotWord", searchHotWord);
+        // 头部菜单
+        List<TopMenuVo> menuList = pageMapper.getTopMenus(source);
+        menuList.forEach(item -> {
+            String link = item.getLink();
+            if (StringUtils.isNotBlank(link)) {
+                if (source == 1) {
+                    if (link.contains("?")) {
+                        link = link + "&name=" + item.getName();
+                    } else {
+                        link = link + "?name=" + item.getName();
+                    }
+                }
+                item.setLinkType(AppletsLinkUtil.getLinkType(link));
+                item.setLinkParam(AppletsLinkUtil.getLinkParam(item.getLinkType(), link));
+                item.setLink(link);
+            }
+        });
+        map.put("topMenuList", menuList);
+        // 底部帮助页
+        List<BaseLinkVo> helpPages = pageMapper.getHelpPageTypes();
+        helpPages.forEach(item -> {
+            List<BaseLinkVo> pageList = pageMapper.getHelpPagesByType(item.getId());
+            item.setLinkList(pageList);
+        });
+        map.put("helpPages", helpPages);
+        // 友情链接
+        List<BaseLinkVo> friendLinks = pageMapper.getFriendLinks();
+        map.put("friendLinks", friendLinks);
+        return ResponseJson.success(map);
+    }
+
     /**
      * 活动专题楼层数据(美博会)
      *

+ 16 - 2
src/main/java/com/caimei365/commodity/utils/AppletsLinkUtil.java

@@ -111,6 +111,7 @@ public class AppletsLinkUtil {
      * 20分类详情
      */
     public static final Pattern pattern35 = Pattern.compile("/cmpage/info-5");
+    public static final Pattern pattern35_1 = Pattern.compile("/product/type");
     /**
      * 21美博会专题页
      */
@@ -119,6 +120,15 @@ public class AppletsLinkUtil {
      * 22美体会专题页
      */
     public static final Pattern pattern38 = Pattern.compile("/cmpage/info-5-301");
+    /**
+     * 23活动专题
+     */
+    public static final Pattern pattern39 = Pattern.compile("/cmpage/info-6");
+    public static final Pattern pattern39_1 = Pattern.compile("/activity/activityTopic");
+    /**
+     * 24美博会优惠券页
+     */
+    public static final Pattern pattern40 = Pattern.compile("/user/beautyfair");
 
     /**
      * 根据链接判断链接类型
@@ -164,13 +174,17 @@ public class AppletsLinkUtil {
                 return 18;
             } else if (pattern32.matcher(link).find()) {
                 return 19;
-            } else if (pattern35.matcher(link).find()) {
+            } else if (pattern35.matcher(link).find() || pattern35_1.matcher(link).find()) {
                 if (pattern38.matcher(link).find()) {
                     return 22;
                 }
                 return 20;
             } else if (pattern37.matcher(link).find()) {
                 return 21;
+            } else if (pattern39.matcher(link).find() || pattern39_1.matcher(link).find()) {
+                return 23;
+            } else if (pattern40.matcher(link).find()) {
+                return 24;
             } else {
                 return -1;
             }
@@ -199,7 +213,7 @@ public class AppletsLinkUtil {
                 split3 = split1[split1.length - 1].split("\\.");
             }
         }
-        if (linkType == 3 || linkType == 5 || linkType == 20 || linkType == 22) {
+        if (linkType == 3 || linkType == 5 || linkType == 20 || linkType == 22 || linkType == 23) {
             //-{id}.html
             if (split3 != null && split3.length == 2) {
                 map.put("id", split3[0]);

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

@@ -248,6 +248,51 @@
             headText
         from cm_page where id = #{pageId} and enabledStatus = '1'
     </select>
+    <select id="getSearchKeyword" resultType="java.lang.String">
+        select name from keyword
+        where validFlag=1
+        order by sortIndex desc
+    </select>
+    <select id="getTopMenus" resultType="com.caimei365.commodity.model.vo.TopMenuVo">
+		select
+            id,
+            navigationName as name,
+            type,
+            link,
+            icon,
+            sort
+		from new_page_first_navigation
+		where delFlag = 0
+		<if test="source == 1">
+            and wwwEnabledStatus = 1
+        </if>
+        <if test="source == 2">
+            and crmEnabledStatus = 1
+        </if>
+		order by -sort desc,createDate desc
+		limit 8
+    </select>
+    <select id="getHelpPageTypes" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select
+		c_helpPageTypeID as id,
+		c_helpPageTypeName as name
+		from c_helpPageType
+    </select>
+    <select id="getHelpPagesByType" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select
+            helpPageID as id,
+            helpPageTypeID as typeId,
+            title as name
+		from helpPage
+		where validFlag = 1
+		and helpPageTypeID = #{typeId}
+		order by sortIndex
+    </select>
+    <select id="getFriendLinks" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select id,name,link
+		from new_page_friendship_link
+		where delFlag = 0 order by id
+    </select>
 
 
 </mapper>