|
|
@@ -1,7 +1,7 @@
|
|
|
package com.goafanti.admin.controller;
|
|
|
|
|
|
-
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -25,33 +25,67 @@ import com.goafanti.common.model.Demand;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.demand.bo.InputDemand;
|
|
|
import com.goafanti.demand.service.DemandService;
|
|
|
+import com.goafanti.user.service.UserService;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/api/admin/demand")
|
|
|
public class AdminDemandApiController extends CertifyApiController {
|
|
|
@Resource
|
|
|
- private DemandService demandService;
|
|
|
-
|
|
|
-
|
|
|
+ private DemandService demandService;
|
|
|
+ @Resource
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 需求管理--获取组织用户下拉
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/unitNames", method = RequestMethod.GET)
|
|
|
+ public Result getUnitNames() {
|
|
|
+ Result res = new Result();
|
|
|
+ res.setData(userService.selectDemandUnitNames());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
+ * 需求管理--获取个人用户下拉
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userNames", method = RequestMethod.GET)
|
|
|
+ public Result getUserNames() {
|
|
|
+ Result res = new Result();
|
|
|
+ res.setData(userService.selectDemandUserNames());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组织用户详情
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
|
|
|
+ public Result orgDemandDetail(String id) {
|
|
|
+ Result res = new Result();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ res.setData(demandService.selectOrgDemandDetail(id));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 个人需求详情
|
|
|
*/
|
|
|
- @RequestMapping(value = "/userDemandDeatail", method = RequestMethod.GET)
|
|
|
- public Result userDemandDetail(String id){
|
|
|
+ @RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
|
|
|
+ public Result userDemandDetail(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;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
res.setData(demandService.selectUserDemandDetail(id));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 个人用户--需求列表
|
|
|
@@ -81,7 +115,8 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
* 个人用户新增需求
|
|
|
*/
|
|
|
@RequestMapping(value = "/userApply", method = RequestMethod.POST)
|
|
|
- public Result userApply(@Valid InputDemand demand, BindingResult bindingResult, String validityPeriodFormattedDate) {
|
|
|
+ public Result userApply(@Valid InputDemand demand, BindingResult bindingResult,
|
|
|
+ String validityPeriodFormattedDate) {
|
|
|
Result res = new Result();
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
@@ -89,38 +124,39 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
return res;
|
|
|
}
|
|
|
res = disposeDemand(res, demand);
|
|
|
- if (!res.getError().isEmpty()){
|
|
|
+ if (!res.getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Demand d = new Demand();
|
|
|
BeanUtils.copyProperties(demand, d);
|
|
|
demandService.saveUserDemandByManager(d, validityPeriodFormattedDate);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 修改个人用户需求
|
|
|
*/
|
|
|
@RequestMapping(value = "/userUpdate", method = RequestMethod.POST)
|
|
|
- public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult, String validityPeriodFormattedDate){
|
|
|
+ public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult,
|
|
|
+ String validityPeriodFormattedDate) {
|
|
|
Result res = new Result();
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- if (StringUtils.isBlank(demand.getId())){
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(demand.getId())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
res = disposeDemand(res, demand);
|
|
|
- if (!res.getError().isEmpty()){
|
|
|
+ if (!res.getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Demand d = new Demand();
|
|
|
BeanUtils.copyProperties(demand, d);
|
|
|
res.setData(demandService.updateUserDemandByManager(d, validityPeriodFormattedDate));
|
|
|
@@ -150,18 +186,18 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
releaseDateStartDate, releaseDateEndDate, pNo, pSize));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 需求资料--图片上传
|
|
|
*/
|
|
|
@RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
|
|
|
public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
|
|
|
Result res = new Result();
|
|
|
- if (StringUtils.isBlank(uid)){
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
|
|
|
if (attachmentType == AttachmentType.DEMAND_PICTURE) {
|
|
|
@@ -169,22 +205,22 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
} else {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 需求资料--文本文件上传
|
|
|
*/
|
|
|
@RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
|
|
|
- public Result uploadTextFile(HttpServletRequest req, String sign, String uid){
|
|
|
+ public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
|
|
|
Result res = new Result();
|
|
|
-
|
|
|
- if (StringUtils.isBlank(uid)){
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
|
|
|
if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
|
|
|
@@ -194,12 +230,12 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 删除需求(个人&团体)
|
|
|
*/
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
- public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids){
|
|
|
+ public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids) {
|
|
|
Result res = new Result();
|
|
|
if (ids == null || ids.length < 1) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
|
|
|
@@ -208,14 +244,14 @@ public class AdminDemandApiController extends CertifyApiController {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- private Result disposeDemand(Result res, InputDemand demand){
|
|
|
+
|
|
|
+ private Result disposeDemand(Result res, InputDemand demand) {
|
|
|
if (StringUtils.isBlank(demand.getName())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())){
|
|
|
+
|
|
|
+ if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "数据类型"));
|
|
|
return res;
|
|
|
}
|