浏览代码

所属行业

fllmoyu 4 年之前
父节点
当前提交
5de8e59af8

+ 4 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dao/IndustryInfoDAO.java

@@ -15,4 +15,8 @@ public interface IndustryInfoDAO {
 	int delete(String id);
 	List<IndustryInfo> list();
 	List<IndustryInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+    List<IndustryInfo> findIndustryByParentId(String parentId);
+
+	List<IndustryInfo> findParentIndustry();
 }

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/CompanyInfoListDTO.java

@@ -17,6 +17,8 @@ public class CompanyInfoListDTO {
 
     private String regionName;
 
+    private String type;
+
     private String typeName;
 
     private String scaleName;

+ 15 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/IndustryInfoDTO.java

@@ -0,0 +1,15 @@
+package com.jpsoft.enterprise.modules.base.dto;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-1-6 10:55
+ */
+@Data
+public class IndustryInfoDTO {
+
+    private String value;
+
+    private String text;
+}

+ 19 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/IndustryListDTO.java

@@ -0,0 +1,19 @@
+package com.jpsoft.enterprise.modules.base.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-1-6 10:54
+ */
+@Data
+public class IndustryListDTO {
+
+    private String value;
+
+    private String text;
+
+    private List<IndustryInfoDTO> children;
+}

+ 4 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/service/IndustryInfoService.java

@@ -14,4 +14,8 @@ public interface IndustryInfoService {
 	int delete(String id);
 	List<IndustryInfo> list();
 	Page<IndustryInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+
+	List<IndustryInfo> findIndustryByParentId(String parentId);
+
+	List<IndustryInfo> findParentIndustry();
 }

+ 16 - 6
common/src/main/java/com/jpsoft/enterprise/modules/base/service/impl/IndustryInfoServiceImpl.java

@@ -29,14 +29,14 @@ public class IndustryInfoServiceImpl implements IndustryInfoService {
 	public int insert(IndustryInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return industryInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(IndustryInfo model) {
 		// TODO Auto-generated method stub
-		return industryInfoDAO.update(model);		
+		return industryInfoDAO.update(model);
 	}
 
 	@Override
@@ -49,22 +49,32 @@ public class IndustryInfoServiceImpl implements IndustryInfoService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = industryInfoDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<IndustryInfo> list() {
 		// TODO Auto-generated method stub
 		return industryInfoDAO.list();
 	}
-		
+
 	@Override
 	public Page<IndustryInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<IndustryInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             industryInfoDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public List<IndustryInfo> findIndustryByParentId(String parentId) {
+		return industryInfoDAO.findIndustryByParentId(parentId);
+	}
+
+	@Override
+	public List<IndustryInfo> findParentIndustry() {
+		return industryInfoDAO.findParentIndustry();
+	}
 }

+ 18 - 2
common/src/main/resources/mapper/base/IndustryInfo.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.enterprise.modules.base.dao.IndustryInfoDAO">
@@ -66,7 +66,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="IndustryInfoMap">
-		select 
+		select
 id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag		from base_industry_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
@@ -88,4 +88,20 @@ id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+	<select id="findIndustryByParentId" resultMap="IndustryInfoMap">
+		<![CDATA[
+		select * from base_industry_info
+		where del_flag = 0
+		and parent_id = #{parentId}
+		]]>
+	</select>
+
+	<select id="findParentIndustry" resultMap="IndustryInfoMap">
+		<![CDATA[
+		select * from base_industry_info
+		where del_flag = 0
+		and parent_id is null
+		]]>
+	</select>
 </mapper>

+ 1 - 0
web/src/main/java/com/jpsoft/enterprise/config/WebMvcConfig.java

@@ -67,6 +67,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/companyInfoApi/companyList")
 				.excludePathPatterns("/mobile/companyInfoApi/companyDetail")
 				.excludePathPatterns("/mobile/companyInfoApi/attributeList")
+				.excludePathPatterns("/mobile/companyInfoApi/industryList")
         ;
 	}
 }

+ 93 - 7
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/CompanyInfoApiController.java

@@ -2,14 +2,13 @@ package com.jpsoft.enterprise.modules.mobile.controller;
 
 import cn.hutool.core.date.DateUtil;
 import com.github.pagehelper.Page;
-import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
-import com.jpsoft.enterprise.modules.base.dto.CompanyInfoListDTO;
-import com.jpsoft.enterprise.modules.base.dto.NewsInfoDTO;
-import com.jpsoft.enterprise.modules.base.dto.NewsInfoListDTO;
+import com.jpsoft.enterprise.modules.base.dto.*;
 import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
+import com.jpsoft.enterprise.modules.base.entity.IndustryInfo;
 import com.jpsoft.enterprise.modules.base.entity.NewsInfo;
 import com.jpsoft.enterprise.modules.base.entity.NewsType;
 import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
+import com.jpsoft.enterprise.modules.base.service.IndustryInfoService;
 import com.jpsoft.enterprise.modules.base.service.NewsInfoService;
 import com.jpsoft.enterprise.modules.base.service.NewsTypeService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
@@ -56,6 +55,9 @@ public class CompanyInfoApiController {
     @Autowired
     private NewsTypeService newsTypeService;
 
+    @Autowired
+    private IndustryInfoService industryInfoService;
+
     @PostMapping("companyNum")
     @ApiOperation(value = "注册公司数量(公开接口)")
     public MessageResult<Map> companyNum() {
@@ -108,6 +110,67 @@ public class CompanyInfoApiController {
         return messageResult;
     }
 
+    @PostMapping("industryList")
+    @ApiOperation(value = "行业列表(公开接口)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", required = false, paramType = "form")
+    })
+    public MessageResult<Map> industryList(String id) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            Map<String, Object> map = new HashMap<>();
+            List<IndustryListDTO> list = new ArrayList<>();
+            if (StringUtils.isBlank(id)){
+                List<IndustryInfo> industryInfoList = industryInfoService.findParentIndustry();
+                if (industryInfoList.size()>0){
+                    for (IndustryInfo industryInfo : industryInfoList){
+                        IndustryListDTO industryListDTO = new IndustryListDTO();
+                        industryListDTO.setValue(industryInfo.getId());
+                        industryListDTO.setText(industryInfo.getIndustryName());
+                        List<IndustryInfo> industryInfoList1 = industryInfoService.findIndustryByParentId(industryInfo.getId());
+                        List<IndustryInfoDTO> industryInfoDTOList = new ArrayList<>();
+                        if (industryInfoList1.size()>0){
+                            for (IndustryInfo industryInfo1 : industryInfoList1){
+                                IndustryInfoDTO industryInfoDTO = new IndustryInfoDTO();
+                                industryInfoDTO.setValue(industryInfo1.getId());
+                                industryInfoDTO.setText(industryInfo1.getIndustryName());
+                                industryInfoDTOList.add(industryInfoDTO);
+                            }
+                        }
+                        industryListDTO.setChildren(industryInfoDTOList);
+                        list.add(industryListDTO);
+                    }
+                }
+            }else {
+                List<IndustryInfo> industryInfoList = industryInfoService.findIndustryByParentId(id);
+                if (industryInfoList.size()>0){
+                    for (IndustryInfo industryInfo : industryInfoList){
+                        IndustryListDTO industryListDTO = new IndustryListDTO();
+                        industryListDTO.setValue(industryInfo.getId());
+                        industryListDTO.setText(industryInfo.getIndustryName());
+                        list.add(industryListDTO);
+                    }
+                }
+            }
+
+
+            map.put("list",list);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
     @PostMapping("companyList")
     @ApiOperation(value = "企业列表(公开接口)")
     @ApiImplicitParams({
@@ -149,7 +212,19 @@ public class CompanyInfoApiController {
                     companyInfoListDTO.setRegionName(dataDictionaryService.findNameByCatalogNameAndValue("区域", companyInfo.getRegion()));
                     companyInfoListDTO.setTypeName(dataDictionaryService.findNameByCatalogNameAndValue("企业类型", companyInfo.getType()));
                     companyInfoListDTO.setScaleName(dataDictionaryService.findNameByCatalogNameAndValue("企业规模", companyInfo.getScale()));
-                    companyInfoListDTO.setIndustryName(dataDictionaryService.findNameByCatalogNameAndValue("所属行业", companyInfo.getIndustry()));
+
+                    //子行业
+                    IndustryInfo industryInfo = industryInfoService.get(companyInfo.getIndustry());
+                    String industryName = industryInfo.getIndustryName();
+                    //父行业
+                    if (StringUtils.isNotBlank(industryInfo.getParentId())){
+                        IndustryInfo industryInfo1 = industryInfoService.get(industryInfo.getParentId());
+                        if (industryInfo1 != null){
+                            industryName = industryInfo1.getIndustryName()+"/"+industryName;
+                        }
+
+                    }
+                    companyInfoListDTO.setIndustryName(industryName);
                     list.add(companyInfoListDTO);
 
                 }
@@ -199,12 +274,23 @@ public class CompanyInfoApiController {
             BeanUtils.copyProperties(companyInfo, companyInfoDetailDTO);
             companyInfoDetailDTO.setTypeName(dataDictionaryService.findNameByCatalogNameAndValue("企业类型", companyInfo.getType()));
             companyInfoDetailDTO.setScaleName(dataDictionaryService.findNameByCatalogNameAndValue("企业规模", companyInfo.getScale()));
-            companyInfoDetailDTO.setIndustryName(dataDictionaryService.findNameByCatalogNameAndValue("所属行业", companyInfo.getIndustry()));
+
+            //子行业
+            IndustryInfo industryInfo = industryInfoService.get(companyInfo.getIndustry());
+            String industryName = industryInfo.getIndustryName();
+            //父行业
+            if (StringUtils.isNotBlank(industryInfo.getParentId())){
+                IndustryInfo industryInfo1 = industryInfoService.get(industryInfo.getParentId());
+                if (industryInfo1 != null){
+                    industryName = industryInfo1.getIndustryName()+"/"+industryName;
+                }
+
+            }
+            companyInfoDetailDTO.setIndustryName(industryName);
 
             //企业风采
             List<NewsInfoListDTO> newsInfoDTOList = new ArrayList<>();
             Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("newsTypeName","企业风采");
             searchParams.put("companyId",companyInfo.getId());
 
             List<Sort> sortList = new ArrayList<>();

+ 9 - 3
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/NewsInfoApiController.java

@@ -116,7 +116,7 @@ public class NewsInfoApiController {
     @PostMapping("newsList")
     @ApiOperation(value = "新闻列表(公开接口)")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "目录id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "id", value = "目录id", required = false, paramType = "form"),
             @ApiImplicitParam(name = "companyId", value = "公司id", required = false, paramType = "form")
     })
     public MessageResult<Map> newsList(String id,String companyId,@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,@RequestParam(value="pageSize",defaultValue="10") int pageSize) {
@@ -129,7 +129,11 @@ public class NewsInfoApiController {
 
 
             Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("newsTypeId",id);
+
+            if (StringUtils.isNotBlank(id)){
+                searchParams.put("newsTypeId",id);
+            }
+
             if (StringUtils.isNotBlank(companyId)){
                 searchParams.put("companyId",companyId);
             }
@@ -140,7 +144,9 @@ public class NewsInfoApiController {
              newsInfos = page.getResult();
             if (newsInfos.size()==0){
                 Map<String,Object> searchParams2 = new HashMap<>();
-                searchParams2.put("newsTypeParentId",id);
+                if (StringUtils.isNotBlank(id)){
+                    searchParams2.put("newsTypeParentId",id);
+                }
                 if (StringUtils.isNotBlank(companyId)){
                     searchParams2.put("companyId",companyId);
                 }