|
|
@@ -1,12 +1,16 @@
|
|
|
package com.goafanti.admin.controller;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.goafanti.achievement.bo.InputAchievement;
|
|
|
@@ -15,6 +19,7 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
import com.goafanti.common.enums.AchievementFields;
|
|
|
+import com.goafanti.common.enums.AttachmentType;
|
|
|
import com.goafanti.common.model.Achievement;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
|
|
|
@@ -23,12 +28,45 @@ import com.goafanti.common.utils.StringUtils;
|
|
|
public class AdminAchievementApiController extends CertifyApiController {
|
|
|
@Resource
|
|
|
private AchievementService achievementService;
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 图片上传
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
|
|
|
+ public Result uploadPicture(HttpServletRequest req, String sign) {
|
|
|
+ Result res = new Result();
|
|
|
+
|
|
|
+ AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
+
|
|
|
+ if (attachmentType == AttachmentType.ACHIEVEMENT_TECHNICAL_PICTURE
|
|
|
+ || attachmentType == AttachmentType.ACHIEVEMENT_MATURITY_PICTURE) {
|
|
|
+ res.setData(handleFiles(res, "/achievement/", false, req, sign, "achievement"));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
+ private 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, "", ""));
|
|
|
+ } else {
|
|
|
+ res.setData(achievementService.deleteByPrimaryKey(Arrays.asList(ids)));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
- private Result detail(String id){
|
|
|
+ private Result detail(String id) {
|
|
|
Result res = new Result();
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
|
|
|
@@ -77,26 +115,26 @@ public class AdminAchievementApiController extends CertifyApiController {
|
|
|
if (!res.getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Achievement a = new Achievement();
|
|
|
BeanUtils.copyProperties(ia, a);
|
|
|
achievementService.saveAchievementByManager(a);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 修改成果
|
|
|
*/
|
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
|
- public Result update(@Valid InputAchievement ia, BindingResult bindingResult){
|
|
|
+ public Result update(@Valid InputAchievement ia, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
AchievementFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- if (StringUtils.isBlank(ia.getId())){
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(ia.getId())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
|
|
|
return res;
|
|
|
}
|
|
|
@@ -104,14 +142,14 @@ public class AdminAchievementApiController extends CertifyApiController {
|
|
|
if (!res.getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Achievement a = new Achievement();
|
|
|
BeanUtils.copyProperties(ia, a);
|
|
|
achievementService.updateAchievementByManager(a);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- private Result disposeInputAchievement(Result res, InputAchievement ia){
|
|
|
+
|
|
|
+ private Result disposeInputAchievement(Result res, InputAchievement ia) {
|
|
|
if (StringUtils.isBlank(ia.getName())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果名称", "成果名称"));
|
|
|
return res;
|
|
|
@@ -136,28 +174,28 @@ public class AdminAchievementApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到所有人类型", "所有人类型"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (StringUtils.isBlank(ia.getOwnerIdNumber())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到所有人证件号", "所有人证件号"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (StringUtils.isBlank(ia.getOwnerMobile())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到所有人联系电话", "所有人联系电话"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (StringUtils.isBlank(ia.getOwnerEmail())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到所有人电子邮箱", "所有人电子邮箱"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (StringUtils.isBlank(ia.getOwnerPostalAddress())) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到所有人通讯地址", "所有人通讯地址"));
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- if (null == ia.getCooperationMode()){
|
|
|
+
|
|
|
+ if (null == ia.getCooperationMode()) {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到合作方式", "合作方式"));
|
|
|
return res;
|
|
|
}
|