|
|
@@ -1,6 +1,5 @@
|
|
|
package com.goafanti.admin.controller;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
@@ -8,6 +7,7 @@ import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
@@ -18,7 +18,6 @@ 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.multipart.MultipartFile;
|
|
|
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
@@ -30,12 +29,8 @@ import com.goafanti.common.model.TechProjectLog;
|
|
|
import com.goafanti.common.model.TechWebsite;
|
|
|
import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.utils.AesUtils;
|
|
|
-import com.goafanti.common.utils.Base64Utils;
|
|
|
-import com.goafanti.common.utils.FileUtils;
|
|
|
-import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
-import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.techproject.bo.InputTechProject;
|
|
|
import com.goafanti.techproject.bo.InputTechProjectLog;
|
|
|
import com.goafanti.techproject.bo.InputTechWebsite;
|
|
|
@@ -89,7 +84,7 @@ public class AdminTechProjectController extends CertifyApiController {
|
|
|
List<TechProjectManageListBo> l = (List<TechProjectManageListBo>) t.getList();
|
|
|
for (TechProjectManageListBo w : l) {
|
|
|
if (!StringUtils.isBlank(w.getPassword())) {
|
|
|
- w.setPassword(Base64Utils.decodeData(w.getPassword()));
|
|
|
+ w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
|
|
|
}
|
|
|
}
|
|
|
t.setList(l);
|
|
|
@@ -282,10 +277,7 @@ public class AdminTechProjectController extends CertifyApiController {
|
|
|
List<TechWebsiteListBo> l = (List<TechWebsiteListBo>) t.getList();
|
|
|
for (TechWebsiteListBo w : l) {
|
|
|
if (!StringUtils.isBlank(w.getPassword())) {
|
|
|
- try {
|
|
|
w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
//w.setPassword(Base64Utils.decodeData(w.getPassword()));
|
|
|
}
|
|
|
}
|
|
|
@@ -312,10 +304,7 @@ public class AdminTechProjectController extends CertifyApiController {
|
|
|
} else {
|
|
|
TechWebsiteDetailBo w = techWebsiteService.selectTechWebsiteDetail(id);
|
|
|
if (null != w && !StringUtils.isBlank(w.getPassword())) {
|
|
|
- try {
|
|
|
w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/*if (null != w && !StringUtils.isBlank(w.getPassword())) {
|
|
|
@@ -359,10 +348,7 @@ public class AdminTechProjectController extends CertifyApiController {
|
|
|
}*/
|
|
|
|
|
|
if (null != w && null != (w.getPassword())) {
|
|
|
- try {
|
|
|
w.setPassword(AesUtils.encrypt(w.getPassword().trim(), aesSecretKey));
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
TechWebsite tw = new TechWebsite();
|
|
|
@@ -390,30 +376,38 @@ public class AdminTechProjectController extends CertifyApiController {
|
|
|
}
|
|
|
|
|
|
String sign = "tech_project";
|
|
|
- res.setData(handleFile(res, "/techProject/", true, req, sign, uid));
|
|
|
+ res.setData(handleFiles(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 "";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载科技项目材料
|
|
|
+ * @param response
|
|
|
+ * @param fileName
|
|
|
+ * @param path
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/download", method = RequestMethod.GET)
|
|
|
+ public Result download(HttpServletResponse response, String id){
|
|
|
+ Result res = new Result();
|
|
|
+ if (!checkUserLogin(res)) {
|
|
|
+ return res;
|
|
|
}
|
|
|
- return fileName;
|
|
|
- }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "科技项目ID"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ TechProject t = techProjectService.selectByPrimaryKey(id);
|
|
|
+ if (null == t){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "科技项目ID"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ downloadFile(response, t.getApprovalDownloadFileName(), t.getApprovalUrl());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
}
|