Antiloveg лет назад: 8
Родитель
Сommit
45e2683bd1

+ 17 - 0
schema/2017-03-23.sql

@@ -0,0 +1,17 @@
+ALTER TABLE `patent_info` 
+MODIFY COLUMN `patent_state` INT(2) NULL COMMENT '专利状态';
+
+ALTER TABLE `patent_log` 
+MODIFY COLUMN `state` INT(2) NULL COMMENT '专利状态';
+
+ALTER TABLE `org_cognizance` 
+MODIFY COLUMN `state` INT(2) NULL COMMENT '高企认定状态';
+
+ALTER TABLE `org_cognizance_log` 
+MODIFY COLUMN `state` INT(2) NULL COMMENT '高企认定状态';
+
+ALTER TABLE `tech_project` 
+MODIFY COLUMN `state` INT(2) NULL COMMENT '科技项目状态';
+
+ALTER TABLE `tech_project_log` 
+MODIFY COLUMN `state` INT(2) NULL COMMENT '科技项目状态状态';

+ 33 - 39
src/main/java/com/goafanti/admin/controller/AdminTechProjectController.java

@@ -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;
+	}
+
 }

+ 24 - 0
src/main/java/com/goafanti/common/controller/BaseApiController.java

@@ -1,6 +1,7 @@
 package com.goafanti.common.controller;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -162,4 +163,27 @@ public class BaseApiController extends BaseController {
 		}
 		return 10;
 	}
+	
+	protected String handleFiles(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;
+	} 
 }

+ 4 - 3
src/main/java/com/goafanti/common/utils/AesUtils.java

@@ -8,7 +8,7 @@ import org.apache.commons.codec.binary.Base64;
 
 public class AesUtils {
 
-	public static String encrypt(String content, String key) throws Exception {
+	public static String encrypt(String content, String key)  {
 		try {
 			String data = content;
 			String iv = key;
@@ -39,13 +39,13 @@ public class AesUtils {
 		}
 	}
 
-	public static String decrypt(String content, String key) throws Exception {
+	public static String decrypt(String content, String key)  {
 		try {
 			String data = content;
 			String iv = key;
 
 			byte[] decoded = Base64.decodeBase64(data);
-System.out.println(ArrayUtils.toString(decoded));
+			System.out.println(ArrayUtils.toString(decoded));
 			Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
 			SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
 			IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
@@ -68,6 +68,7 @@ System.out.println(ArrayUtils.toString(decoded));
 		System.out.println(encrypted);
 		System.out.println(encrypted.length());
 		System.out.println(AesUtils.decrypt(encrypted, pwd));
+		System.out.println("provider= " + javax.crypto.Cipher.getInstance("AES/CBC/NoPadding").getProvider());
 
 	}
 

+ 32 - 27
src/main/java/com/goafanti/techproject/controller/TechProjectApiController.java

@@ -1,11 +1,10 @@
 package com.goafanti.techproject.controller;
 
-import java.io.IOException;
 import java.text.ParseException;
-import java.util.List;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 
 import org.springframework.beans.BeanUtils;
@@ -13,7 +12,6 @@ import org.springframework.stereotype.Controller;
 import org.springframework.validation.BindingResult;
 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.constant.ErrorConstants;
@@ -21,8 +19,6 @@ import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.enums.CopyrightFields;
 import com.goafanti.common.model.TechProject;
 import com.goafanti.common.model.User;
-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.bo.InputTechProject;
@@ -202,31 +198,40 @@ public class TechProjectApiController 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 id
+	 * @param response
+	 * @return
+	 */
+	@RequestMapping(value = "/download", method = RequestMethod.GET)
+	public Result download(String id, HttpServletResponse response){
+		Result res = new Result();
+		if (!checkUserLogin(res)) {
+			return res;
+		}
+		User curUser = TokenManager.getUserToken();
+		if (!checkCertify(res, curUser)) {
+			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 || !curUser.getId().equals(t.getUid())){
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "科技项目ID"));
+			return res;
+		}
+		
+		downloadFile(response, t.getApprovalDownloadFileName(), t.getApprovalUrl());
+		return res;
 	}
 
+
 }