Antiloveg 8 년 전
부모
커밋
fee4981dec

+ 4 - 0
src/main/java/com/goafanti/common/dao/DemandOrderMapper.java

@@ -1,5 +1,7 @@
 package com.goafanti.common.dao;
 
+import java.util.List;
+
 import com.goafanti.common.model.DemandOrder;
 
 public interface DemandOrderMapper {
@@ -16,4 +18,6 @@ public interface DemandOrderMapper {
     int updateByPrimaryKey(DemandOrder record);
 
 	DemandOrder selectDemandOrderByUidAndDemandId(String uid, String id);
+
+	List<DemandOrder> selectDemandOrderByDemandId(String demandId);
 }

+ 7 - 0
src/main/java/com/goafanti/common/mapper/DemandOrderMapper.xml

@@ -226,4 +226,11 @@
   		and do.status = #{status,jdbcType=INTEGER}
   	</if>
   </select>
+  
+  <select id="selectDemandOrderByDemandId" parameterType="java.lang.String" resultMap="BaseResultMap">
+  	 select 
+    <include refid="Base_Column_List" />
+    from demand_order
+    where demand_id = #{demandId,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 41 - 31
src/main/java/com/goafanti/demand/controller/DemandApiController.java

@@ -1,6 +1,7 @@
 package com.goafanti.demand.controller;
 
 import java.util.Arrays;
+import java.util.List;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -23,31 +24,36 @@ import com.goafanti.common.enums.AttachmentType;
 import com.goafanti.common.enums.DemandAuditStatus;
 import com.goafanti.common.enums.DemandDataCategory;
 import com.goafanti.common.enums.DemandFields;
+import com.goafanti.common.enums.DemandOrderStatus;
 import com.goafanti.common.model.AftFile;
 import com.goafanti.common.model.Demand;
+import com.goafanti.common.model.DemandOrder;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.demand.bo.InputDemand;
+import com.goafanti.demand.service.DemandOrderService;
 import com.goafanti.demand.service.DemandService;
 
 @RestController
 @RequestMapping(value = "/api/user/demand")
-public class DemandApiController extends CertifyApiController{
+public class DemandApiController extends CertifyApiController {
 	@Resource
-	private DemandService demandService;
+	private DemandService		demandService;
 	@Resource
-	private AftFileService aftFileService;
-	
+	private AftFileService		aftFileService;
+	@Resource
+	private DemandOrderService	demandOrderService;
+
 	/**
 	 * 成果需求匹配列表
 	 */
 	@RequestMapping(value = "/achievementDemand", method = RequestMethod.GET)
-	public Result achievementDemand(String id){
+	public Result achievementDemand(String id) {
 		Result res = new Result();
 		res.setData(demandService.selectAchievementDemandListByDemandId(id));
 		return res;
 	}
-	
+
 	/**
 	 * 下载技术需求批量导入Excel模板
 	 */
@@ -71,15 +77,14 @@ public class DemandApiController extends CertifyApiController{
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 用户需求列表
 	 */
 	@RequestMapping(value = "/list", method = RequestMethod.GET)
 	public Result list(Integer auditStatus, Integer serialNumber, String name, String keyword, Integer demandType,
-			String validityPeriodStartDate, String validityPeriodEndDate, Integer status,
-			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, String pageNo,
-			String pageSize) {
+			String validityPeriodStartDate, String validityPeriodEndDate, Integer status, Integer releaseStatus,
+			String releaseDateStartDate, String releaseDateEndDate, String pageNo, String pageSize) {
 		Result res = new Result();
 		Integer pNo = 1;
 		Integer pSize = 10;
@@ -95,7 +100,7 @@ public class DemandApiController extends CertifyApiController{
 				releaseDateEndDate, pNo, pSize));
 		return res;
 	}
-	
+
 	/**
 	 * 新增需求
 	 */
@@ -120,7 +125,7 @@ public class DemandApiController extends CertifyApiController{
 		demandService.saveDemand(d, validityPeriodFormattedDate, keywords);
 		return res;
 	}
-	
+
 	/**
 	 * 组织用户详情
 	 */
@@ -171,7 +176,7 @@ public class DemandApiController extends CertifyApiController{
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
 			return res;
 		}
-		
+
 		if (!DemandAuditStatus.CREATE.getCode().equals(demand.getAuditStatus())
 				&& !DemandAuditStatus.SUBMIT.getCode().equals(demand.getAuditStatus())
 				&& !DemandAuditStatus.UNAUDITED.getCode().equals(demand.getAuditStatus())) {
@@ -190,43 +195,50 @@ public class DemandApiController extends CertifyApiController{
 		res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords));
 		return res;
 	}
-	
+
 	/**
 	 * 需求撤消发布(下架)
 	 */
 	@RequestMapping(value = "/offShelf", method = RequestMethod.POST)
-	public Result offShelf(String id){
+	public Result offShelf(String id) {
 		Result res = new Result();
-		if (StringUtils.isBlank(id)){
+		if (StringUtils.isBlank(id)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
 			return res;
 		}
-		
+
 		Demand d = demandService.selectByPrimaryKey(id);
-		
-		if (null == d){
+
+		if (null == d) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
 			return res;
 		}
-		
+
 		res.setData(demandService.updateReleaseStatus(d));
 		return res;
 	}
-	
+
 	/**
 	 * 删除需求(个人&团体)
 	 */
 	@RequestMapping(value = "/delete", method = RequestMethod.POST)
 	public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids) {
 		Result res = new Result();
-		if (ids == null || ids.length < 1) {
+		if (ids == null || ids.length != 1) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
 		} else {
+			List<DemandOrder> list = demandOrderService.selectDemandOrderByDemandId(ids[0]);
+			for (DemandOrder order : list){
+				if (!DemandOrderStatus.CREATE.getCode().equals(order.getStatus())){
+					res.getError().add(buildError("", "当前科技需求有订单,无法删除!"));
+					return res;
+				}
+			}
 			res.setData(demandService.deleteByPrimaryKey(Arrays.asList(ids)));
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 需求资料--图片上传
 	 */
@@ -261,7 +273,7 @@ public class DemandApiController extends CertifyApiController{
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 下载需求文件--文本文件
 	 */
@@ -283,9 +295,7 @@ public class DemandApiController extends CertifyApiController{
 		downloadUnPrivateFile(response, d.getTextFileDownloadFileName(), d.getTextFileUrl());
 		return res;
 	}
-	
-	
-	
+
 	private Result disposeDemand(Result res, InputDemand demand, String[] keywords) {
 		if (StringUtils.isBlank(demand.getName())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
@@ -302,7 +312,7 @@ public class DemandApiController extends CertifyApiController{
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
 			return res;
 		}
-		
+
 		if (null == keywords || keywords.length < 1) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
 			return res;
@@ -322,9 +332,9 @@ public class DemandApiController extends CertifyApiController{
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到问题说明", "问题说明"));
 			return res;
 		}
-		
-		for (int i=0; i<keywords.length; i++){
-			if (AFTConstants.KEYWORDLENTH < keywords[i].length()){
+
+		for (int i = 0; i < keywords.length; i++) {
+			if (AFTConstants.KEYWORDLENTH < keywords[i].length()) {
 				res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "关键词长度"));
 				return res;
 			}

+ 4 - 0
src/main/java/com/goafanti/demand/service/DemandOrderService.java

@@ -1,5 +1,7 @@
 package com.goafanti.demand.service;
 
+import java.util.List;
+
 import com.goafanti.common.model.DemandOrder;
 import com.goafanti.common.model.DemandOrderLog;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -17,4 +19,6 @@ public interface DemandOrderService {
 
 	int updateShutdownByUser(DemandOrder order);
 
+	List<DemandOrder> selectDemandOrderByDemandId(String string);
+
 }

+ 6 - 0
src/main/java/com/goafanti/demand/service/impl/DemandOrderServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.demand.service.impl;
 
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -84,4 +85,9 @@ public class DemandOrderServiceImpl extends BaseMybatisDao<DemandOrderMapper> im
 		return demandOrderMapper.updateByPrimaryKey(order);
 	}
 
+	@Override
+	public List<DemandOrder> selectDemandOrderByDemandId(String demandId) {
+		return demandOrderMapper.selectDemandOrderByDemandId(demandId);
+	}
+
 }