guomengjiao il y a 1 an
Parent
commit
6ec094dd3f

+ 7 - 1
modules/report/src/main/java/com/jeesite/modules/report/dao/ResearchBriefReportDao.java

@@ -3,6 +3,9 @@ package com.jeesite.modules.report.dao;
 import com.jeesite.common.dao.CrudDao;
 import com.jeesite.common.mybatis.annotation.MyBatisDao;
 import com.jeesite.modules.report.entity.ResearchBriefReport;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 简报智库DAO接口
@@ -11,5 +14,8 @@ import com.jeesite.modules.report.entity.ResearchBriefReport;
  */
 @MyBatisDao
 public interface ResearchBriefReportDao extends CrudDao<ResearchBriefReport> {
-	
+
+    long findResearchBriefReportCount(@Param("rr") ResearchBriefReport researchBriefReport);
+
+    List<ResearchBriefReport> findResearchBriefReportList(@Param("rr") ResearchBriefReport researchBriefReport);
 }

+ 2 - 0
modules/report/src/main/java/com/jeesite/modules/report/dao/ResearchBriefReportLabelDao.java

@@ -20,4 +20,6 @@ public interface ResearchBriefReportLabelDao extends CrudDao<ResearchBriefReport
     List<ResearchBriefReportLabel> findPage(@Param("info") ResearchBriefReportLabel researchBriefReportLabel);
 
     long findPageCount(@Param("info") ResearchBriefReportLabel researchBriefReportLabel);
+
+    String findNames(@Param("parentId") String parentId);
 }

+ 36 - 1
modules/report/src/main/java/com/jeesite/modules/report/entity/ResearchBriefReport.java

@@ -49,6 +49,10 @@ public class ResearchBriefReport extends DataEntity<ResearchBriefReport> {
 	private String pptFile;		// ppt文件
 	private String useDownPay;		// 下载是否需要支付 0否 1是
 	private BigDecimal useDownPayPrice;		// 下载需要支付单价
+	private Date publishDateStr;	//发布日期起
+	private Date publishDateEnd;	//发布日期止
+	private String topLabelName;		// 一级标签id
+	private String secondLabelName;		// 二级标签id
 
 	public ResearchBriefReport() {
 		this(null);
@@ -165,5 +169,36 @@ public class ResearchBriefReport extends DataEntity<ResearchBriefReport> {
 	public void setUseDownPayPrice(BigDecimal useDownPayPrice) {
 		this.useDownPayPrice = useDownPayPrice;
 	}
-	
+
+	public Date getPublishDateStr() {
+		return publishDateStr;
+	}
+
+	public void setPublishDateStr(Date publishDateStr) {
+		this.publishDateStr = publishDateStr;
+	}
+
+	public Date getPublishDateEnd() {
+		return publishDateEnd;
+	}
+
+	public void setPublishDateEnd(Date publishDateEnd) {
+		this.publishDateEnd = publishDateEnd;
+	}
+
+	public String getTopLabelName() {
+		return topLabelName;
+	}
+
+	public void setTopLabelName(String topLabelName) {
+		this.topLabelName = topLabelName;
+	}
+
+	public String getSecondLabelName() {
+		return secondLabelName;
+	}
+
+	public void setSecondLabelName(String secondLabelName) {
+		this.secondLabelName = secondLabelName;
+	}
 }

+ 9 - 1
modules/report/src/main/java/com/jeesite/modules/report/entity/ResearchBriefReportLabel.java

@@ -28,6 +28,7 @@ public class ResearchBriefReportLabel extends DataEntity<ResearchBriefReportLabe
 	private String parentId;		// 上级id 可以选择多个
 	private Integer levelNum;		// 层次
 	private Integer sortNum;		// 排序
+	private String parentName;
 
 	public ResearchBriefReportLabel() {
 		this(null);
@@ -70,5 +71,12 @@ public class ResearchBriefReportLabel extends DataEntity<ResearchBriefReportLabe
 	public void setSortNum(Integer sortNum) {
 		this.sortNum = sortNum;
 	}
-	
+
+	public String getParentName() {
+		return parentName;
+	}
+
+	public void setParentName(String parentName) {
+		this.parentName = parentName;
+	}
 }

+ 14 - 10
modules/report/src/main/java/com/jeesite/modules/report/service/ResearchBriefReportLabelService.java

@@ -1,16 +1,14 @@
 package com.jeesite.modules.report.service;
 
-import java.util.List;
-
-import com.jeesite.modules.report.entity.ResearchReport;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.jeesite.common.entity.Page;
 import com.jeesite.common.service.CrudService;
-import com.jeesite.modules.report.entity.ResearchBriefReportLabel;
 import com.jeesite.modules.report.dao.ResearchBriefReportLabelDao;
+import com.jeesite.modules.report.entity.ResearchBriefReportLabel;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 简报分类Service
@@ -27,7 +25,7 @@ public class ResearchBriefReportLabelService extends CrudService<ResearchBriefRe
 	 */
 	@Override
 	public ResearchBriefReportLabel get(ResearchBriefReportLabel researchBriefReportLabel) {
-		return super.get(researchBriefReportLabel);
+		return convert(super.get(researchBriefReportLabel));
 	}
 	
 	/**
@@ -41,12 +39,18 @@ public class ResearchBriefReportLabelService extends CrudService<ResearchBriefRe
 		Page page = new Page(researchBriefReportLabel.getPageNo(),researchBriefReportLabel.getPageSize());
 		long count = dao.findPageCount(researchBriefReportLabel);
 		List<ResearchBriefReportLabel> list = dao.findPage(researchBriefReportLabel);
+		list = list.stream().map(r -> convert(r)).collect(Collectors.toList());
 		page.setCount(count);
 		page.setList(list);
 		page.initialize();
 		return page;
 	}
-	
+
+	private ResearchBriefReportLabel convert(ResearchBriefReportLabel r) {
+		r.setParentName(dao.findNames(r.getParentId()));
+		return r;
+	}
+
 	/**
 	 * 查询列表数据
 	 * @param researchBriefReportLabel

+ 27 - 8
modules/report/src/main/java/com/jeesite/modules/report/service/ResearchBriefReportService.java

@@ -1,13 +1,16 @@
 package com.jeesite.modules.report.service;
 
-import java.util.List;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.jeesite.common.entity.Page;
 import com.jeesite.common.service.CrudService;
-import com.jeesite.modules.report.entity.ResearchBriefReport;
 import com.jeesite.modules.report.dao.ResearchBriefReportDao;
+import com.jeesite.modules.report.dao.ResearchBriefReportLabelDao;
+import com.jeesite.modules.report.entity.ResearchBriefReport;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 简报智库Service
@@ -16,7 +19,10 @@ import com.jeesite.modules.report.dao.ResearchBriefReportDao;
  */
 @Service
 public class ResearchBriefReportService extends CrudService<ResearchBriefReportDao, ResearchBriefReport> {
-	
+
+	@Resource
+	private ResearchBriefReportLabelDao researchBriefReportLabelDao;
+
 	/**
 	 * 获取单条数据
 	 * @param researchBriefReport
@@ -24,7 +30,7 @@ public class ResearchBriefReportService extends CrudService<ResearchBriefReportD
 	 */
 	@Override
 	public ResearchBriefReport get(ResearchBriefReport researchBriefReport) {
-		return super.get(researchBriefReport);
+		return convert(super.get(researchBriefReport));
 	}
 	
 	/**
@@ -35,7 +41,20 @@ public class ResearchBriefReportService extends CrudService<ResearchBriefReportD
 	 */
 	@Override
 	public Page<ResearchBriefReport> findPage(ResearchBriefReport researchBriefReport) {
-		return super.findPage(researchBriefReport);
+		Page page = new Page(researchBriefReport.getPageNo(),researchBriefReport.getPageSize());
+		long count = dao.findResearchBriefReportCount(researchBriefReport);
+		List<ResearchBriefReport> list = dao.findResearchBriefReportList(researchBriefReport);
+		list = list.stream().map(r -> convert(r)).collect(Collectors.toList());
+		page.setCount(count);
+		page.setList(list);
+		page.initialize();
+		return page;
+	}
+
+	private ResearchBriefReport convert(ResearchBriefReport r) {
+		r.setTopLabelName(researchBriefReportLabelDao.findNames(r.getTopLabelId()));
+		r.setSecondLabelName(researchBriefReportLabelDao.findNames(r.getSecondLabelId()));
+		return r;
 	}
 	
 	/**

+ 33 - 13
modules/report/src/main/java/com/jeesite/modules/report/web/ResearchBriefReportController.java

@@ -1,9 +1,13 @@
 package com.jeesite.modules.report.web;
 
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.jeesite.common.config.Global;
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.report.entity.ResearchBriefReport;
+import com.jeesite.modules.report.entity.ResearchBriefReportLabel;
+import com.jeesite.modules.report.service.ResearchBriefReportLabelService;
+import com.jeesite.modules.report.service.ResearchBriefReportService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -14,11 +18,8 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.jeesite.common.config.Global;
-import com.jeesite.common.entity.Page;
-import com.jeesite.common.web.BaseController;
-import com.jeesite.modules.report.entity.ResearchBriefReport;
-import com.jeesite.modules.report.service.ResearchBriefReportService;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * 简报智库Controller
@@ -31,6 +32,8 @@ public class ResearchBriefReportController extends BaseController {
 
 	@Autowired
 	private ResearchBriefReportService researchBriefReportService;
+	@Autowired
+	private ResearchBriefReportLabelService researchBriefReportLabelService;
 	
 	/**
 	 * 获取数据
@@ -53,7 +56,7 @@ public class ResearchBriefReportController extends BaseController {
 	/**
 	 * 查询列表数据
 	 */
-	@RequiresPermissions("report:researchBriefReport:view")
+//	@RequiresPermissions("report:researchBriefReport:view")
 	@RequestMapping(value = "listData")
 	@ResponseBody
 	public Page<ResearchBriefReport> listData(ResearchBriefReport researchBriefReport, HttpServletRequest request, HttpServletResponse response) {
@@ -65,7 +68,7 @@ public class ResearchBriefReportController extends BaseController {
 	/**
 	 * 查看编辑表单
 	 */
-	@RequiresPermissions("report:researchBriefReport:view")
+//	@RequiresPermissions("report:researchBriefReport:view")
 	@RequestMapping(value = "form")
 	public String form(ResearchBriefReport researchBriefReport, Model model) {
 		model.addAttribute("researchBriefReport", researchBriefReport);
@@ -75,10 +78,27 @@ public class ResearchBriefReportController extends BaseController {
 	/**
 	 * 保存数据
 	 */
-	@RequiresPermissions("report:researchBriefReport:edit")
+//	@RequiresPermissions("report:researchBriefReport:edit")
 	@PostMapping(value = "save")
 	@ResponseBody
 	public String save(@Validated ResearchBriefReport researchBriefReport) {
+		if (StringUtils.isEmpty(researchBriefReport.getTopLabelId())) {
+			return renderResult(Global.FALSE, text("一级标签为空!"));
+		}
+		if (StringUtils.isEmpty(researchBriefReport.getSecondLabelId())) {
+			return renderResult(Global.FALSE, text("二级标签为空!"));
+		}
+		ResearchBriefReportLabel researchBriefReportLabel = researchBriefReportLabelService.get(researchBriefReport.getTopLabelId());
+		if (researchBriefReportLabel == null) {
+			return renderResult(Global.FALSE, text("一级标签不存在!"));
+		}
+		ResearchBriefReportLabel researchBriefReportLabelTwo = researchBriefReportLabelService.get(researchBriefReport.getSecondLabelId());
+		if (researchBriefReportLabelTwo == null) {
+			return renderResult(Global.FALSE, text("二级标签不存在!"));
+		}
+		if (!researchBriefReportLabelTwo.getParentId().contains(researchBriefReportLabel.getId())) {
+			return renderResult(Global.FALSE, text("二级标签不属于一级标签下!"));
+		}
 		researchBriefReportService.save(researchBriefReport);
 		return renderResult(Global.TRUE, text("保存简报智库成功!"));
 	}
@@ -86,7 +106,7 @@ public class ResearchBriefReportController extends BaseController {
 	/**
 	 * 删除数据
 	 */
-	@RequiresPermissions("report:researchBriefReport:edit")
+//	@RequiresPermissions("report:researchBriefReport:edit")
 	@RequestMapping(value = "delete")
 	@ResponseBody
 	public String delete(ResearchBriefReport researchBriefReport) {

+ 24 - 1
modules/report/src/main/resources/mappings/modules/report/ResearchBriefReportDao.xml

@@ -11,5 +11,28 @@
 		</where>
 		ORDER BY ${sqlMap.order.toSql()}
 	</select> -->
-	
+
+    <select id="findResearchBriefReportCount" resultType="java.lang.Long">
+        select count(1) from research_brief_report where status = '0'
+        <include refid="researchBriefReport_where"/>
+    </select>
+
+    <sql id="researchBriefReport_where">
+        <if test="rr.title != null and rr.title != ''">and title like concat('%',#{rr.title},'%')</if>
+        <if test="rr.publishDateStr != null">and publish_date >= #{rr.publishDateStr}</if>
+        <if test="rr.publishDateEnd != null">and publish_date &lt; #{rr.publishDateEnd}</if>
+        <if test="rr.outline != null and rr.outline != ''">and outline like concat('%',#{rr.outline},'%')</if>
+        <if test="rr.marketType != null and rr.marketType != ''">and market_type = #{rr.marketType}</if>
+        <if test="rr.topLabelId != null and rr.topLabelId != ''">and top_label_id = #{rr.topLabelId}</if>
+        <if test="rr.secondLabelId != null and rr.secondLabelId != ''">and second_label_id = #{rr.secondLabelId}</if>
+        <if test="rr.useDownPay != null and rr.useDownPay != ''">and use_down_pay = #{rr.useDownPay}</if>
+    </sql>
+
+    <select id="findResearchBriefReportList"
+            resultType="com.jeesite.modules.report.entity.ResearchBriefReport">
+        select * from research_brief_report where status = '0'
+        <include refid="researchBriefReport_where"/>
+        order by update_date desc
+        limit ${rr.pageSize * (rr.pageNo - 1)},${rr.pageSize}
+    </select>
 </mapper>

+ 6 - 0
modules/report/src/main/resources/mappings/modules/report/ResearchBriefReportLabelDao.xml

@@ -30,6 +30,8 @@
         select * from research_brief_report_label a
         where a.status = '0'
         <include refid="whereStr02"/>
+        order by a.update_date desc
+        limit ${info.pageSize * (info.pageNo - 1)},${info.pageSize}
     </select>
 
     <sql id="whereStr02">
@@ -52,4 +54,8 @@
         where a.status = '0'
         <include refid="whereStr02"/>
     </select>
+
+    <select id="findNames" resultType="java.lang.String">
+        select GROUP_CONCAT(name) from research_brief_report_label a where FIND_IN_SET( a.id, #{parentId}) > 0
+    </select>
 </mapper>