|
|
@@ -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;
|
|
|
}
|