Przeglądaj źródła

管理端功能开发,调整

xiao547607 4 lat temu
rodzic
commit
0113c262bc
18 zmienionych plików z 416 dodań i 25 usunięć
  1. 3 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/dao/IndustryInfoDAO.java
  2. 1 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/dao/NewsTypeDAO.java
  3. 1 1
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/CompanyInfo.java
  4. 5 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/IndustryInfo.java
  5. 2 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsInfo.java
  6. 2 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsType.java
  7. 3 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/IndustryInfoService.java
  8. 1 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/NewsTypeService.java
  9. 11 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/impl/IndustryInfoServiceImpl.java
  10. 6 0
      common/src/main/java/com/jpsoft/enterprise/modules/base/service/impl/NewsTypeServiceImpl.java
  11. 15 8
      common/src/main/resources/mapper/base/CompanyInfo.xml
  12. 35 6
      common/src/main/resources/mapper/base/IndustryInfo.xml
  13. 7 2
      common/src/main/resources/mapper/base/NewsInfo.xml
  14. 10 1
      common/src/main/resources/mapper/base/NewsType.xml
  15. 13 3
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/CompanyInfoController.java
  16. 270 0
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/IndustryInfoController.java
  17. 7 0
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsInfoController.java
  18. 24 4
      web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsTypeController.java

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

@@ -14,9 +14,12 @@ public interface IndustryInfoDAO {
 	IndustryInfo get(String id);
 	int delete(String id);
 	List<IndustryInfo> list();
+	List<IndustryInfo> parentList();
 	List<IndustryInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
 
     List<IndustryInfo> findIndustryByParentId(String parentId);
 
 	List<IndustryInfo> findParentIndustry();
+
+	IndustryInfo findByName(String name);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dao/NewsTypeDAO.java

@@ -15,6 +15,7 @@ public interface NewsTypeDAO {
 	NewsType get(String id);
 	int delete(String id);
 	List<NewsType> list();
+	List<NewsType> parentList();
 	List<NewsType> search(Map<String,Object> searchParams,List<Sort> sortList);
 
     List<NewsType> findByParentId(String parentId);

+ 1 - 1
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/CompanyInfo.java

@@ -40,7 +40,7 @@ public class CompanyInfo {
     @ApiModelProperty(value = "所属行业(1:计算机/IT,2:食品加工,3:服务业)")
     private String industry;
     @ApiModelProperty(value = "字典:所属行业")
-    private String industryN;
+    private String industryName;
     @ApiModelProperty(value = "所在地区(1:荆州区,2:沙市区,3:开发区,4:石首市)")
     private String region;
     @ApiModelProperty(value = "字典:区域")

+ 5 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/IndustryInfo.java

@@ -36,4 +36,9 @@ public class IndustryInfo {
     private Date updateTime;
         @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
+    @ApiModelProperty(value = "父名称")
+    private String parentName;
+    @ApiModelProperty(value = "排序号")
+    private Integer sortNo;
+
 }

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsInfo.java

@@ -51,4 +51,6 @@ public class NewsInfo {
     private Boolean delFlag= false;
     @ApiModelProperty(value = "是否主页展示(轮播图)")
     private Boolean topFlag = false;
+    @ApiModelProperty(value = "排序号")
+    private Integer sortNo;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/NewsType.java

@@ -43,4 +43,6 @@ public class NewsType {
     private String code;
     @ApiModelProperty(value = "新闻中心是否展示")
     private Boolean showFlag;
+    @ApiModelProperty(value = "排序号")
+    private Integer sortNo;
 }

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

@@ -13,9 +13,12 @@ public interface IndustryInfoService {
 	int update(IndustryInfo model);
 	int delete(String id);
 	List<IndustryInfo> list();
+	List<IndustryInfo> parentList();
 	Page<IndustryInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 
 	List<IndustryInfo> findIndustryByParentId(String parentId);
 
 	List<IndustryInfo> findParentIndustry();
+
+	IndustryInfo findByName(String name);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/service/NewsTypeService.java

@@ -13,6 +13,7 @@ public interface NewsTypeService {
 	int update(NewsType model);
 	int delete(String id);
 	List<NewsType> list();
+	List<NewsType> parentList();
 	Page<NewsType> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 
     List<NewsType> findByParentId(String parentId);

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

@@ -59,6 +59,12 @@ public class IndustryInfoServiceImpl implements IndustryInfoService {
 		return industryInfoDAO.list();
 	}
 
+	@Override
+	public List<IndustryInfo> parentList() {
+		// TODO Auto-generated method stub
+		return industryInfoDAO.parentList();
+	}
+
 	@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(()->{
@@ -77,4 +83,9 @@ public class IndustryInfoServiceImpl implements IndustryInfoService {
 	public List<IndustryInfo> findParentIndustry() {
 		return industryInfoDAO.findParentIndustry();
 	}
+
+	@Override
+	public IndustryInfo findByName(String name){
+		return industryInfoDAO.findByName(name);
+	}
 }

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

@@ -61,6 +61,12 @@ public class NewsTypeServiceImpl implements NewsTypeService {
 		return newsTypeDAO.list();
 	}
 
+
+	@Override
+	public List<NewsType> parentList(){
+		return newsTypeDAO.parentList();
+	}
+
 	@Override
 	public Page<NewsType> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<NewsType> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{

+ 15 - 8
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -21,6 +21,7 @@
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
+			<result property="industryName" column="industry_name" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.CompanyInfo">
 	<!--
@@ -121,27 +122,33 @@
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="CompanyInfoMap">
 		<![CDATA[
-			select * from base_company_info
+			SELECT
+				a.*,
+				b.industry_name AS industry_name
+			FROM
+				base_company_info a
+				LEFT JOIN base_industry_info b ON a.industry_ = b.id_
 		]]>
 		<where>
-			del_flag = 0
+			a.del_flag = 0
+			and b.del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and a.ID_ like #{searchParams.id}
 			</if>
 			<if test="searchParams.companyName != null">
-				and company_name like #{searchParams.companyName}
+				and a.company_name like #{searchParams.companyName}
 			</if>
 			<if test="searchParams.region != null">
-				and region_ = #{searchParams.region}
+				and a.region_ = #{searchParams.region}
 			</if>
 			<if test="searchParams.type != null">
-				and type_ = #{searchParams.type}
+				and a.type_ = #{searchParams.type}
 			</if>
 			<if test="searchParams.scale != null">
-				and scale_ = #{searchParams.scale}
+				and a.scale_ = #{searchParams.scale}
 			</if>
 			<if test="searchParams.industry != null">
-				and industry_ = #{searchParams.industry}
+				and a.industry_ = #{searchParams.industry}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 35 - 6
common/src/main/resources/mapper/base/IndustryInfo.xml

@@ -12,6 +12,8 @@
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
+			<result property="parentName" column="parent_name" />
+			<result property="sortNo" column="sort_no"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.IndustryInfo">
 	<!--
@@ -21,7 +23,7 @@
 	-->
 	<![CDATA[
 		insert into base_industry_info
-	    (id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag,sort_no)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -32,6 +34,7 @@
 ,#{updateBy,jdbcType=VARCHAR}
 ,#{updateTime,jdbcType= TIMESTAMP }
 ,#{delFlag,jdbcType= NUMERIC }
+,#{sortNo,jdbcType=NUMERIC}
 		)
 	]]>
 	</insert>
@@ -62,26 +65,43 @@
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
 		</if>
+			<if test="sortNo!=null">
+				sort_no=#{sortNo,jdbcType=NUMERIC },
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="IndustryInfoMap">
-		select
-id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag		from base_industry_info where id_=#{0}
+		select * from base_industry_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_industry_info where id_=#{0}
 	</select>
 	<select id="list" resultMap="IndustryInfoMap">
-		select * from base_industry_info
+		select * from base_industry_info where del_flag = 0 ORDER BY parent_id ASC,sort_no ASC
+	</select>
+	<select id="parentList" resultMap="IndustryInfoMap">
+		select * from base_industry_info where del_flag = 0 and parent_id is null ORDER BY parent_id ASC,sort_no ASC
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="IndustryInfoMap">
 		<![CDATA[
-			select * from base_industry_info
+			SELECT
+				a.*,
+				b.industry_name as parent_name
+			FROM
+				base_industry_info a
+				LEFT JOIN base_industry_info b ON a.parent_id = b.id_
 		]]>
 		<where>
+            a.del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.name != null">
+				and a.industry_name like #{searchParams.name}
+			</if>
+			<if test="searchParams.parentName != null">
+				and b.industry_name like #{searchParams.parentName}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
@@ -94,6 +114,7 @@ id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag
 		select * from base_industry_info
 		where del_flag = 0
 		and parent_id = #{parentId}
+		order by sort_no ASC
 		]]>
 	</select>
 
@@ -102,6 +123,14 @@ id_,industry_name,parent_id,create_by,create_time,update_by,update_time,del_flag
 		select * from base_industry_info
 		where del_flag = 0
 		and parent_id is null
+		order by sort_no ASC
 		]]>
 	</select>
+
+	<select id="findByName" parameterType="string" resultMap="IndustryInfoMap">
+		select * from base_industry_info
+		where industry_name = #{0}
+		and del_flag = 0
+		limit 1
+	</select>
 </mapper>

+ 7 - 2
common/src/main/resources/mapper/base/NewsInfo.xml

@@ -19,6 +19,7 @@
 			<result property="topFlag" column="top_flag"/>
 			<result property="newsTypeName" column="news_type_name"/>
 			<result property="companyName" column="company_name" />
+			<result property="sortNo" column="sort_no"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsInfo">
 	<!--
@@ -28,7 +29,7 @@
 	-->
 	<![CDATA[
 		insert into base_news_info
-	    (id_,news_type_id,company_id,title_,content_,reader_num,pic_url,create_by,create_time,update_by,update_time,del_flag,top_flag)
+	    (id_,news_type_id,company_id,title_,content_,reader_num,pic_url,create_by,create_time,update_by,update_time,del_flag,top_flag,sort_no)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -44,6 +45,7 @@
 ,#{updateTime,jdbcType= TIMESTAMP }
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{topFlag,jdbcType=NUMERIC}
+,#{sortNo,jdbcType=NUMERIC}
 		)
 	]]>
 	</insert>
@@ -89,6 +91,9 @@
 			<if test="topFlag!=null">
 				top_flag=#{topFlag,jdbcType=BOOLEAN },
 			</if>
+			<if test="sortNo!=null">
+				sort_no=#{sortNo,jdbcType=NUMERIC },
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
@@ -110,7 +115,7 @@
 		select count(*) from base_news_info where id_=#{0}
 	</select>
 	<select id="list" resultMap="NewsInfoMap">
-		select * from base_news_info
+		select * from base_news_info where del_flag = 0 order by sort_no asc
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="NewsInfoMap">
 		<![CDATA[

+ 10 - 1
common/src/main/resources/mapper/base/NewsType.xml

@@ -15,6 +15,7 @@
 			<result property="code" column="code_"/>
 			<result property="showFlag" column="show_flag"/>
 			<result property="parentName" column="parent_name"/>
+			<result property="sortNo" column="sort_no"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsType">
 	<!--
@@ -24,7 +25,7 @@
 	-->
 	<![CDATA[
 		insert into base_news_type
-	    (id_,name_,parent_id,create_by,create_time,update_by,update_time,del_flag,code_,show_flag)
+	    (id_,name_,parent_id,create_by,create_time,update_by,update_time,del_flag,code_,show_flag,sort_no)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -37,6 +38,7 @@
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{code,jdbcType=VARCHAR}
 ,#{showFlag,jdbcType=NUMERIC}
+,#{sortNo,jdbcType=NUMERIC}
 		)
 	]]>
 	</insert>
@@ -73,6 +75,9 @@
 			<if test="showFlag!=null">
 				show_flag=#{showFlag,jdbcType=NUMERIC },
 			</if>
+			<if test="sortNo!=null">
+				sort_no=#{sortNo,jdbcType=NUMERIC },
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
@@ -85,6 +90,10 @@
 	<select id="list" resultMap="NewsTypeMap">
 		select * from base_news_type where del_flag = 0 and show_flag = 1 ORDER BY parent_id ASC,id_ ASC
 	</select>
+	<select id="parentList" resultMap="NewsTypeMap">
+		select * from base_news_type where del_flag = 0 and show_flag = 1 and parent_id = 0 ORDER BY parent_id ASC,id_ ASC
+	</select>
+
 	<select id="search" parameterType="hashmap" resultMap="NewsTypeMap">
 		<![CDATA[
 			SELECT

+ 13 - 3
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/CompanyInfoController.java

@@ -3,7 +3,9 @@ package com.jpsoft.enterprise.modules.base.controller;
 import com.github.pagehelper.Page;
 import com.jpsoft.enterprise.config.OSSConfig;
 import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
+import com.jpsoft.enterprise.modules.base.entity.IndustryInfo;
 import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
+import com.jpsoft.enterprise.modules.base.service.IndustryInfoService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
 import com.jpsoft.enterprise.modules.common.utils.OSSUtil;
 import com.jpsoft.enterprise.modules.common.utils.POIUtils;
@@ -45,6 +47,8 @@ public class CompanyInfoController {
     @Autowired
     private CompanyInfoService companyInfoService;
     @Autowired
+    private IndustryInfoService industryInfoService;
+    @Autowired
     private DataDictionaryService dataDictionaryService;
     @Autowired
     private UserService userService;
@@ -237,7 +241,7 @@ public class CompanyInfoController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("create_time","desc"));
+        sortList.add(new Sort("a.create_time","desc"));
 
         if (StringUtils.isNotEmpty(companyName)) {
             searchParams.put("companyName","%" + companyName + "%");
@@ -261,7 +265,6 @@ public class CompanyInfoController {
 
         Page<CompanyInfo> page = companyInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
         for(CompanyInfo ci : page.getResult()){
-            ci.setIndustryN(dataDictionaryService.findNameByCatalogNameAndValue("所属行业",ci.getIndustry()));
             ci.setTypeN(dataDictionaryService.findNameByCatalogNameAndValue("企业类型",ci.getType()));
             ci.setScaleN(dataDictionaryService.findNameByCatalogNameAndValue("企业规模",ci.getScale()));
             ci.setRegionN(dataDictionaryService.findNameByCatalogNameAndValue("区域",ci.getRegion()));
@@ -359,7 +362,14 @@ public class CompanyInfoController {
                         companyInfo.setId(UUID.randomUUID().toString());
                         companyInfo.setCompanyName(name);
 
-                        companyInfo.setIndustry(dataDictionaryService.findValueByCatalogNameAndName("所属行业",industry));
+                        IndustryInfo industryInfo = industryInfoService.findByName(industry);
+                        if(industryInfo != null) {
+                            companyInfo.setIndustry(industryInfo.getId());
+                        }else{
+                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("行业不存在!");
+                            failCount++;
+                            continue;
+                        }
                         companyInfo.setType(dataDictionaryService.findValueByCatalogNameAndName("企业类型",type));
                         companyInfo.setScale(dataDictionaryService.findValueByCatalogNameAndName("企业规模",scale));
                         companyInfo.setRegion(dataDictionaryService.findValueByCatalogNameAndName("区域",region));

+ 270 - 0
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/IndustryInfoController.java

@@ -0,0 +1,270 @@
+package com.jpsoft.enterprise.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.modules.base.entity.NewsType;
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
+import com.jpsoft.enterprise.modules.common.dto.Sort;
+import com.jpsoft.enterprise.modules.base.entity.IndustryInfo;
+import com.jpsoft.enterprise.modules.base.service.IndustryInfoService;
+import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 企业分类
+ * sz
+ */
+@RestController
+@RequestMapping("/base/industryInfo")
+@Api(description = "industryInfo")
+public class IndustryInfoController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private IndustryInfoService industryInfoService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<IndustryInfo> create(){
+        MessageResult<IndustryInfo> msgResult = new MessageResult<>();
+
+        IndustryInfo industryInfo = new IndustryInfo();
+
+        List<IndustryInfo> iiList = industryInfoService.list();
+        industryInfo.setSortNo(iiList.size()+1);
+
+        msgResult.setData(industryInfo);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<IndustryInfo> add(@RequestBody IndustryInfo industryInfo,@RequestAttribute String subject){
+        MessageResult<IndustryInfo> msgResult = new MessageResult<>();
+
+        try {
+            industryInfo.setId(UUID.randomUUID().toString());
+            industryInfo.setDelFlag(false);
+            industryInfo.setCreateBy(subject);
+            industryInfo.setCreateTime(new Date());
+            
+            int affectCount = industryInfoService.insert(industryInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(industryInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<IndustryInfo> edit(@PathVariable("id") String id){
+        MessageResult<IndustryInfo> msgResult = new MessageResult<>();
+
+        try {
+            IndustryInfo industryInfo = industryInfoService.get(id);
+
+            if (industryInfo != null) {
+                if(industryInfo.getSortNo() == null){
+                    List<IndustryInfo> iiList = industryInfoService.list();
+                    industryInfo.setSortNo(iiList.size()+1);
+
+                }
+
+                msgResult.setResult(true);
+                msgResult.setData(industryInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<IndustryInfo> update(@RequestBody IndustryInfo industryInfo,@RequestAttribute String subject){
+        MessageResult<IndustryInfo> msgResult = new MessageResult<>();
+
+        try {
+            industryInfo.setUpdateBy(subject);
+            industryInfo.setUpdateTime(new Date());
+            
+            int affectCount = industryInfoService.update(industryInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(industryInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            IndustryInfo industryInfo = industryInfoService.get(id);
+            industryInfo.setDelFlag(true);
+            industryInfo.setUpdateBy(subject);
+            industryInfo.setUpdateTime(new Date());
+
+            int affectCount = industryInfoService.update(industryInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                IndustryInfo industryInfo = industryInfoService.get(id);
+                industryInfo.setDelFlag(true);
+                industryInfo.setUpdateBy(subject);
+                industryInfo.setUpdateTime(new Date());
+
+                affectCount += industryInfoService.update(industryInfo);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="parentName",defaultValue="") String parentName,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.parent_id","asc"));
+        sortList.add(new Sort("a.sort_no","asc"));
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id","%" + id + "%");
+        }
+
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+
+        if (StringUtils.isNotEmpty(parentName)) {
+            searchParams.put("parentName","%" + parentName + "%");
+        }
+
+        Page<IndustryInfo> page = industryInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "查询")
+    @RequestMapping(value = "list", method = RequestMethod.POST)
+    public MessageResult<List<IndustryInfo>> list(
+            @RequestParam(value="queryParent",defaultValue="false") Boolean queryParent,
+            @RequestAttribute String subject) {
+
+        MessageResult<List<IndustryInfo>> msgResult = new MessageResult<>();
+        List<IndustryInfo> list = null;
+        if(queryParent) {
+            list = industryInfoService.parentList();
+        }else{
+            list = industryInfoService.list();
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
+
+        return msgResult;
+    }
+}

+ 7 - 0
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsInfoController.java

@@ -2,6 +2,7 @@ package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
 import com.jpsoft.enterprise.modules.base.entity.NewsInfo;
+import com.jpsoft.enterprise.modules.base.entity.NewsType;
 import com.jpsoft.enterprise.modules.base.service.NewsInfoService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
 import com.jpsoft.enterprise.modules.common.dto.Sort;
@@ -33,6 +34,8 @@ public class NewsInfoController {
         MessageResult<NewsInfo> msgResult = new MessageResult<>();
 
         NewsInfo newsInfo = new NewsInfo();
+        List<NewsInfo> iiList = newsInfoService.list();
+        newsInfo.setSortNo(iiList.size()+1);
 
         msgResult.setData(newsInfo);
         msgResult.setResult(true);
@@ -80,6 +83,10 @@ public class NewsInfoController {
             NewsInfo newsInfo = newsInfoService.get(id);
 
             if (newsInfo != null) {
+                if(newsInfo.getSortNo() == null){
+                    List<NewsInfo> iiList = newsInfoService.list();
+                    newsInfo.setSortNo(iiList.size()+1);
+                }
                 msgResult.setResult(true);
                 msgResult.setData(newsInfo);
             } else {

+ 24 - 4
web/src/main/java/com/jpsoft/enterprise/modules/base/controller/NewsTypeController.java

@@ -2,6 +2,8 @@ package com.jpsoft.enterprise.modules.base.controller;
 
 import com.github.pagehelper.Page;
 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.NewsTypeService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
@@ -35,6 +37,8 @@ public class NewsTypeController {
         MessageResult<NewsType> msgResult = new MessageResult<>();
 
         NewsType newsType = new NewsType();
+        List<NewsType> iiList = newsTypeService.list();
+        newsType.setSortNo(iiList.size()+1);
 
         msgResult.setData(newsType);
         msgResult.setResult(true);
@@ -52,6 +56,9 @@ public class NewsTypeController {
             newsType.setDelFlag(false);
             newsType.setCreateBy(subject);
             newsType.setCreateTime(new Date());
+            if (StringUtils.isEmpty(newsType.getParentId())) {
+                newsType.setParentId("0");
+            }
             
             int affectCount = newsTypeService.insert(newsType);
 
@@ -82,6 +89,10 @@ public class NewsTypeController {
             NewsType newsType = newsTypeService.get(id);
 
             if (newsType != null) {
+                if(newsType.getSortNo() == null){
+                    List<NewsType> iiList = newsTypeService.list();
+                    newsType.setSortNo(iiList.size()+1);
+                }
                 msgResult.setResult(true);
                 msgResult.setData(newsType);
             } else {
@@ -107,6 +118,9 @@ public class NewsTypeController {
         try {
             newsType.setUpdateBy(subject);
             newsType.setUpdateTime(new Date());
+            if (StringUtils.isEmpty(newsType.getParentId())) {
+                newsType.setParentId("0");
+            }
             
             int affectCount = newsTypeService.update(newsType);
 
@@ -213,8 +227,8 @@ public class NewsTypeController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("a.parent_id","asc"));
-        sortList.add(new Sort("a.create_time","asc"));
+        sortList.add(new Sort("b.sort_no","asc"));
+        sortList.add(new Sort("a.sort_no","asc"));
 
         if (StringUtils.isNotEmpty(id)) {
             searchParams.put("id","%" + id + "%");
@@ -239,16 +253,22 @@ public class NewsTypeController {
     @ApiOperation(value = "查询")
     @RequestMapping(value = "list", method = RequestMethod.POST)
     public MessageResult<List<NewsType>> list(
+            @RequestParam(value="queryParent",defaultValue="false") Boolean queryParent,
             @RequestAttribute String subject) {
 
         MessageResult<List<NewsType>> msgResult = new MessageResult<>();
-        List<NewsType> list = newsTypeService.list();
+        List<NewsType> list = null;
+        if(queryParent) {
+            list = newsTypeService.parentList();
+        }else{
+            list = newsTypeService.list();
+        }
+
         for(NewsType nt : list){
             if("0".equals(nt.getParentId())){
                 nt.setParentId(null);
             }
         }
-
         msgResult.setResult(true);
         msgResult.setData(list);