瀏覽代碼

商品分类接口添加

Aslee 4 年之前
父節點
當前提交
40cf2a33f4

+ 6 - 0
product/src/main/java/com/caimei/module/product/dao/ProductModuleDao.java

@@ -94,4 +94,10 @@ public interface ProductModuleDao {
     BrandVo getBrand(Integer brandID);
 
     Integer findProductNormalNumById(Integer shopID);
+
+    Integer getBigTypeIdBySmallTypeId(Integer typeId);
+
+    Integer getBigTypeIdByTinyTypeId(Integer typeId);
+
+    BigtypeVo getBigTypeByBigTypeId(Integer bigTypeID);
 }

+ 6 - 0
product/src/main/java/com/caimei/module/product/service/ProductModuleService.java

@@ -18,6 +18,12 @@ public interface ProductModuleService {
      */
     List<BigtypeVo> getClassify(String domain, String typeSort, String source);
 
+    /**
+     * 根据分类ID获取分类列表
+     * @return
+     */
+    BigtypeVo getClassifyByTypeId(String domain, Integer typeId, Integer idType, String source);
+
     /**
      * 根据一级分类ID获取二三级分类
      */

+ 37 - 0
product/src/main/java/com/caimei/module/product/service/impl/ProductModuleServiceImpl.java

@@ -64,6 +64,43 @@ public class ProductModuleServiceImpl implements ProductModuleService {
         return bigTypeList;
     }
 
+    /**
+     * 根据分类ID获取二三级分类
+     * bigTypeID 一级分类ID
+     * source 请求来源:www,crm
+     * @return
+     */
+    @Override
+    public BigtypeVo getClassifyByTypeId(String domain, Integer typeId, Integer idType, String source) {
+        Integer bigTypeID = 0;
+        if (idType == 1) {
+            bigTypeID = typeId;
+        } else if (idType == 2 ) {
+            bigTypeID = productModuleDao.getBigTypeIdBySmallTypeId(typeId);
+        } else if (idType == 3 ) {
+            bigTypeID = productModuleDao.getBigTypeIdByTinyTypeId(typeId);
+        }
+        BigtypeVo bigType = productModuleDao.getBigTypeByBigTypeId(bigTypeID);
+        List<SmalltypeVo> smallTypeList = productModuleDao.getSmallType(bigTypeID,source);
+        for (SmalltypeVo smallType : smallTypeList) {
+            String caiMeiImage = ProductUtils.getImageURL("caiMeiImage", null, 0, domain);
+            smallType.setWwwIcon(StringUtils.isEmpty(smallType.getWwwIcon())?caiMeiImage:smallType.getWwwIcon());
+            smallType.setCrmIcon(StringUtils.isEmpty(smallType.getCrmIcon())?caiMeiImage:smallType.getCrmIcon());
+            List<TinytypeVo> tinytypeList = productModuleDao.getTinytype(smallType.getSmallTypeID(), source);
+            if (!CollectionUtils.isEmpty(tinytypeList)) {
+                for (TinytypeVo tinyType : tinytypeList) {
+                    tinyType.setWwwIcon(StringUtils.isEmpty(tinyType.getWwwIcon())?caiMeiImage:tinyType.getWwwIcon());
+                    tinyType.setCrmIcon(StringUtils.isEmpty(tinyType.getCrmIcon())?caiMeiImage:tinyType.getCrmIcon());
+                }
+                smallType.setTinytypeList(tinytypeList);
+            }
+            if (!CollectionUtils.isEmpty(smallTypeList)) {
+                bigType.setSmalltypeList(smallTypeList);
+            }
+        }
+        return bigType;
+    }
+
     /**
      * 根据一级分类ID获取二三级分类
      * bigTypeID 一级分类ID

+ 17 - 0
product/src/main/resources/com-caimei-module-product/ProductModuleMapper.xml

@@ -570,4 +570,21 @@
     <select id="getBrand" resultType="com.caimei.module.base.entity.vo.BrandVo">
         SELECT * FROM cm_brand WHERE id = #{brandID}
     </select>
+
+    <select id="getBigTypeIdBySmallTypeId" resultType="java.lang.Integer">
+        select bigTypeID from smalltype where smallTypeID = #{typeId}
+    </select>
+
+    <select id="getBigTypeIdByTinyTypeId" resultType="java.lang.Integer">
+        select bigTypeID from smalltype
+        where smallTypeID =
+        (SELECT smallTypeID from  tinytype where  tinyTypeID = #{typeId})
+    </select>
+
+    <select id="getBigTypeByBigTypeId" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
+        select
+        <include refid="BigType_Column_List" />
+        from bigtype
+        where bigTypeID = #{bigTypeID}
+    </select>
 </mapper>