|
|
@@ -2,6 +2,7 @@ package com.goafanti.demand.controller;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -27,6 +28,7 @@ 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.enums.UserType;
|
|
|
import com.goafanti.common.model.AftFile;
|
|
|
import com.goafanti.common.model.Demand;
|
|
|
import com.goafanti.common.model.DemandOrder;
|
|
|
@@ -102,11 +104,19 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
Demand d = new Demand();
|
|
|
BeanUtils.copyProperties(demand, d);
|
|
|
d.setEmployerId(TokenManager.getUserId());
|
|
|
+ if(TokenManager.getUserToken().getType().intValue() == UserType.PERSONAL.getCode().intValue()){
|
|
|
+ d.setDataCategory(DemandDataCategory.USERDEMAND.getCode());
|
|
|
+ }else if(TokenManager.getUserToken().getType().intValue() == UserType.ORGANIZATION.getCode().intValue()){
|
|
|
+ d.setDataCategory(DemandDataCategory.ORGDEMAND.getCode());
|
|
|
+ }else{
|
|
|
+ res.getError().add(buildError(ErrorConstants.USER_UN_AUTHENTICATION,"","用户未认证"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
List<String> webPages = new ArrayList<String>();
|
|
|
List<String> appPages = new ArrayList<String>();
|
|
|
PageConstants.putDemand(publishPages, webPages, appPages);
|
|
|
if(webPages.size()==0 && appPages.size() == 0){
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "页面参数错误"));
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "页面参数错误"));
|
|
|
return res;
|
|
|
}
|
|
|
demandService.saveDemand(d, validityPeriodFormattedDate, keywords, webPages, appPages);
|
|
|
@@ -199,6 +209,12 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发布需求
|
|
|
+ * @param id
|
|
|
+ * @param auditStatus
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@RequestMapping(value = "/publishDemand", method = RequestMethod.POST)
|
|
|
public Result publishDemand(String id,Integer auditStatus){
|
|
|
Result res = new Result();
|
|
|
@@ -218,16 +234,45 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
}
|
|
|
Demand d = new Demand();
|
|
|
d.setId(id);
|
|
|
+ d.setReleaseDate(new Date());
|
|
|
d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
|
|
|
demandService.updateByPrimaryKeySelective(d);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 刷新发布时间
|
|
|
+ * @param id
|
|
|
+ * @param auditStatus
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/refreshPublish", method = RequestMethod.POST)
|
|
|
+ public Result refreshPublish(String id,Integer auditStatus){
|
|
|
+ Result res = new Result();
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (null == auditStatus) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "需求状态错误", "需求状态"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (DemandAuditStatus.AUDITED.getCode() != auditStatus) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "当前状态无法刷新发布"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ Demand d = new Demand();
|
|
|
+ d.setId(id);
|
|
|
+ d.setReleaseDate(new Date());
|
|
|
+ demandService.updateByPrimaryKeySelective(d);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 需求撤消发布(下架)
|
|
|
*/
|
|
|
@RequestMapping(value = "/offShelf", method = RequestMethod.POST)
|
|
|
- public Result offShelf(String id) {
|
|
|
+ public Result offShelf(String id,Integer auditStatus) {
|
|
|
Result res = new Result();
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
|
|
|
@@ -238,7 +283,11 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
|
|
|
return res;
|
|
|
}
|
|
|
- res.setData(demandService.updateReleaseStatus(d));
|
|
|
+ if(DemandAuditStatus.AUDITED.getCode() != auditStatus){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "当前状态无法撤销发布"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ demandService.updateReleaseStatus(d);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -290,11 +339,11 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
|
|
|
AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
|
|
|
- if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
|
|
|
+ /*if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
|
|
|
res.setData(handleFiles(res, "/demand/", false, req, sign, TokenManager.getUserId()));
|
|
|
} else {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
- }
|
|
|
+ }*/
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -326,13 +375,13 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())
|
|
|
+ /*if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())
|
|
|
&& !DemandDataCategory.ORGDEMAND.getCode().equals(demand.getDataCategory())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "数据类型"));
|
|
|
return res;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- /*if (StringUtils.isBlank(demand.getKeyword())) {
|
|
|
+ if (StringUtils.isBlank(demand.getKeyword())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
|
|
|
return res;
|
|
|
}
|
|
|
@@ -340,7 +389,7 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
if (null == keywords || keywords.length < 1) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
|
|
|
return res;
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
if (null == demand.getIndustryCategoryA()) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到行业类别", "行业类别"));
|
|
|
@@ -366,5 +415,4 @@ public class UserDemandApiController extends CertifyApiController {
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
}
|