|
|
@@ -2,20 +2,23 @@ package com.goafanti.techproject.controller;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
import com.goafanti.common.model.TechProject;
|
|
|
-import com.goafanti.common.model.TechProjectLog;
|
|
|
-import com.goafanti.common.utils.DateUtils;
|
|
|
+import com.goafanti.common.utils.FileUtils;
|
|
|
+import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.techproject.service.TechProjectLogService;
|
|
|
@@ -64,7 +67,6 @@ public class TechProjectApiController extends BaseApiController{
|
|
|
Result res = new Result();
|
|
|
techProjectService.saveTechProject(techProject, TokenManager.getUserId(), TokenManager.getToken().getAid());
|
|
|
return res;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -100,16 +102,49 @@ public class TechProjectApiController extends BaseApiController{
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
@RequestMapping(value = "/updateTechProject", method = RequestMethod.POST)
|
|
|
- public Result updateTechProject(TechProject t, TechProjectLog l, String recordTimeFormattedDate) throws ParseException{
|
|
|
+ public Result updateTechProject(TechProject t) throws ParseException{
|
|
|
Result res = new Result();
|
|
|
- Date recordTime =null;
|
|
|
- if (!StringUtils.isBlank(recordTimeFormattedDate)) {
|
|
|
- recordTime = DateUtils.parseDate(recordTimeFormattedDate, "yyyy-MM-dd");
|
|
|
- }
|
|
|
- res.setData(techProjectService.updateTechProject(t, l, recordTime));
|
|
|
+ res.setData(techProjectService.updateTechProject(t, null, null));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 科技项目申报材料上传
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @param sign
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/upload", method = RequestMethod.POST)
|
|
|
+ public Result cognizanceFile(HttpServletRequest req, String uid) {
|
|
|
+ Result res = new Result();
|
|
|
+ String sign = "tech_project";
|
|
|
+ res.setData(handleFile(res, "/techProject/", true, req, sign, uid));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String handleFile(Result res, String path, boolean isPrivate, HttpServletRequest req, String sign,
|
|
|
+ String uid) {
|
|
|
+ List<MultipartFile> files = getFiles(req);
|
|
|
+ MultipartFile mf = files.get(0);
|
|
|
+
|
|
|
+ String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign, path,
|
|
|
+ StringUtils.isBlank(uid) ? TokenManager.getUserId() : uid);
|
|
|
+ if (!files.isEmpty()) {
|
|
|
+ try {
|
|
|
+ mf.transferTo(toPrivateFile(fileName));
|
|
|
+ LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
|
|
|
+ } catch (IllegalStateException | IOException e) {
|
|
|
+ LoggerUtils.error(getClass(), "文件上传失败", e);
|
|
|
+ res.getError().add(buildError("", "文件上传失败!"));
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError("", "文件上传失败!"));
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return fileName;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|