瀏覽代碼

修改获取物业信息返回数据,industryCode -> industryName

云殇忆 2 年之前
父節點
當前提交
6bca6bdc6c

+ 4 - 0
benyun-core/src/main/java/com/benyun/core/dao/CategoryMapper.java

@@ -17,4 +17,8 @@ public interface CategoryMapper {
     List<Category> searchBigManage();
     List<Category> searchMidManageByBig(String bigCategory);
     List<Category> searchSubManageByMid(String midCategory);
+    List<Category> searchBigIndustry();
+    List<Category> searchMidIndustryByBig(String bigCategory);
+    List<Category> searchSubIndustryByMid(String midCategory);
+    Category searchSubIndustryByCode(String industryCode);
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/entity/bo/BrandProperty.java

@@ -4,7 +4,7 @@ import lombok.Data;
 
 @Data
 public class BrandProperty {
-    private String industryCode;
+    private String industryName;
     private Float perCapitaConsumption;
     private Long commentCount;
     private Float score;

+ 1 - 0
benyun-core/src/main/java/com/benyun/core/service/CategoryService.java

@@ -9,4 +9,5 @@ public interface CategoryService {
     List<Category> getTypeByCategory();
     List<Category> getWdTypeCategory();
     List<Category> getManageCategory();
+    List<Category> getIndustryCategory();
 }

+ 9 - 2
benyun-core/src/main/java/com/benyun/core/service/impl/BrandServiceImpl.java

@@ -31,6 +31,8 @@ public class BrandServiceImpl implements BrandService {
     EnterpriseMapper enterpriseMapper;
     @Autowired
     AttentionPoolDao attentionPoolDao;
+    @Autowired
+    CategoryMapper categoryMapper;
 
     @Override
     public List<BrandSearch> searchByLikeName(String text) {
@@ -76,12 +78,17 @@ public class BrandServiceImpl implements BrandService {
         Brand brand = brandMapper.searchById(brandId);
         BrandProperty bp = new BrandProperty();
         if (brand != null){
-            bp.setIndustryCode(brand.getIndustryCode());
+            if (brand.getIndustryCode() == null || brand.getIndustryCode().equals(""))
+                bp.setIndustryName("");
+            else{
+                Category category = categoryMapper.searchSubIndustryByCode(brand.getIndustryCode());
+                bp.setIndustryName(category.getName());
+            }
             bp.setPerCapitaConsumption(brand.getPerCapitaConsumption());
             bp.setCommentCount(brand.getCommentCount());
             bp.setScore(brand.getScore());
         }else {
-            bp.setIndustryCode("****");
+            bp.setIndustryName("****");
             bp.setPerCapitaConsumption(null);
             bp.setCommentCount(null);
             bp.setScore(null);

+ 31 - 0
benyun-core/src/main/java/com/benyun/core/service/impl/CategoryServiceImpl.java

@@ -4,6 +4,7 @@ import com.benyun.core.entity.Category;
 import com.benyun.core.dao.CategoryMapper;
 import com.benyun.core.service.CategoryService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -107,4 +108,34 @@ public class CategoryServiceImpl implements CategoryService {
         }
         return bigs;
     }
+
+    @Override
+    public List<Category> getIndustryCategory() {
+        List<Category> bigs = categoryMapper.searchBigIndustry();
+        if (bigs.isEmpty())
+            return null;
+        for (Category big : bigs){
+            big.setType("bigCategory");
+            List<Category> mids = categoryMapper.searchMidIndustryByBig(big.getName());
+            if (mids.isEmpty())
+                big.setChildren(null);
+            else {
+                for (Category mid : mids){
+                    mid.setType("midCategory");
+                    List<Category> subs = categoryMapper.searchSubIndustryByMid(mid.getName());
+                    if (subs.isEmpty())
+                        mid.setChildren(null);
+                    else{
+                        for (Category sub : subs){
+                            sub.setType("subCategory");
+                            sub.setChildren(null);
+                        }
+                        mid.setChildren(subs);
+                    }
+                }
+                big.setChildren(mids);
+            }
+        }
+        return bigs;
+    }
 }

+ 24 - 0
benyun-core/src/main/resources/mapper/CategoryMapper.xml

@@ -43,6 +43,18 @@
         <result property="code" column="wd_type_code"/>
         <result property="name" column="wd_type_name"/>
     </resultMap>
+    <resultMap type="com.benyun.core.entity.Category" id="BigIndustryResult">
+        <result property="code" column="industry_code"/>
+        <result property="name" column="big_category"/>
+    </resultMap>
+    <resultMap type="com.benyun.core.entity.Category" id="MidIndustryResult">
+        <result property="code" column="industry_code"/>
+        <result property="name" column="mid_category"/>
+    </resultMap>
+    <resultMap type="com.benyun.core.entity.Category" id="SubIndustryResult">
+        <result property="code" column="industry_code"/>
+        <result property="name" column="sub_category"/>
+    </resultMap>
     <select id="searchProvince" resultMap="ProvinceResult">
         select * from `ddt_addr_category` where city = ''
     </select>
@@ -73,4 +85,16 @@
     <select id="searchSubManageByMid" resultMap="SubManageResult">
         select * from `ddt_manage_type` where mid_category <![CDATA[<>]]> '' and sub_category <![CDATA[<>]]> '' and mid_category = #{midCategory}
     </select>
+    <select id="searchBigIndustry" resultMap="BigIndustryResult">
+        select * from `ddt_industry_category` where mid_category = ''
+    </select>
+    <select id="searchMidIndustryByBig" resultMap="MidIndustryResult">
+        select * from `ddt_industry_category` where mid_category <![CDATA[<>]]> '' and sub_category = '' and big_category = #{bigCategory}
+    </select>
+    <select id="searchSubIndustryByMid" resultMap="SubIndustryResult">
+        select * from `ddt_industry_category` where mid_category <![CDATA[<>]]> '' and sub_category <![CDATA[<>]]> '' and mid_category = #{midCategory}
+    </select>
+    <select id="searchSubIndustryByCode" resultMap="SubIndustryResult">
+        select * from `ddt_industry_category` where industry_code = #{industryCode}
+    </select>
 </mapper>