dcs 6 months ago
parent
commit
2caf6b4aa3

+ 1 - 1
virgo.core/src/main/java/com/bosshand/virgo/core/utils/CodeCache.java

@@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit;
 
 public class CodeCache {
 
-    public static final String DefaultPhone = "18888888888,17777777777,17698569102,17698963228,16666666666,17711111111,17711111112,17711112222,17601274604,17601274603,13298303283,13750914351,17280721640";
+    public static final String DefaultPhone = "18888888888,17777777777,17698569102,17698963228,16666666666,17711111111,17711111112,17711112222,17601274604,17601274603,13298303283,13750914351,17280721640,15397319112";
 
     public static final String DefaultPhoneCode = "888888";
 

+ 97 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/controller/FileNodeManagerController.java

@@ -9,6 +9,7 @@ import com.bosshand.virgo.file.model.FileNodeProject;
 import com.bosshand.virgo.file.model.FileNodeUserSetPermissions;
 import com.bosshand.virgo.file.service.FileNodeManagerService;
 import com.bosshand.virgo.file.util.AliyunOSSUtil;
+import com.bosshand.virgo.file.util.Doc2Pdf;
 import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -137,6 +138,54 @@ public class FileNodeManagerController {
 		}
 	}
 
+	@RequestMapping(value = "/fileNodeOrganization/{id}/type/{xx}", method = RequestMethod.GET)
+	public void getFileNodeOrganizationTo(@PathVariable int id, @PathVariable String xx, final HttpServletResponse response) {
+		logger.info("Ready to get file byte on parentId:" + id);
+		byte[] data = null;
+		OutputStream outputStream = null;
+		try {
+			data = fileNodeManagerService.getFileNodeOrganizationNode(id);
+			response.setCharacterEncoding("UTF-8");
+			response.setContentType("application/x-msdownload");
+			response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(xx, "UTF-8"));
+			OutputStream outputSream = response.getOutputStream();
+			outputSream.write(data);
+			outputSream.flush();
+		} catch (IOException e) {
+			throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
+		} finally {
+			if (outputStream != null) {
+				try {
+					outputStream.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	@RequestMapping(value = "/fileNodeOrganization/{id}/renderPdf", method = RequestMethod.GET)
+	public Response fileNodeOrganizationRenderPdf( @PathVariable int id , final HttpServletResponse response) {
+		byte[] data = null;
+		OutputStream outputStream = null;
+		try {
+			data = fileNodeManagerService.getFileNodeOrganizationNode(id);
+			outputStream = response.getOutputStream();
+			outputStream.write(Doc2Pdf.doc2pdf(data));
+			outputStream.flush();
+		} catch (IOException e) {
+			throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
+		}finally {
+			if(outputStream != null) {
+				try {
+					outputStream.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+		return Response.ok();
+
+	}
+
 	//*****************************************************************
 	// FileNodeProject
 	//*****************************************************************
@@ -200,6 +249,54 @@ public class FileNodeManagerController {
 			}
 		}
 	}
+
+	@RequestMapping(value = "/fileNodeProject/{id}/type/{xx}", method = RequestMethod.GET)
+	public void getFileTo(@PathVariable int id, @PathVariable String xx, final HttpServletResponse response) {
+		logger.info("Ready to get file byte on parentId:" + id);
+		byte[] data = null;
+		OutputStream outputStream = null;
+		try {
+			data = fileNodeManagerService.getFileNodeProjectNode(id);
+			response.setCharacterEncoding("UTF-8");
+			response.setContentType("application/x-msdownload");
+			response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(xx, "UTF-8"));
+			OutputStream outputSream = response.getOutputStream();
+			outputSream.write(data);
+			outputSream.flush();
+		} catch (IOException e) {
+			throw new BadRequestException("Fail to write stream", Constant.RET_DOCUMENT_ERROR, e);
+		} finally {
+			if (outputStream != null) {
+				try {
+					outputStream.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+	}
+
+	@RequestMapping(value = "/fileNodeProject/{id}/renderPdf", method = RequestMethod.GET)
+	public Response renderPdf( @PathVariable int id , final HttpServletResponse response) {
+		byte[] data = null;
+		OutputStream outputStream = null;
+		try {
+			data = fileNodeManagerService.getFileNodeProjectNode(id);
+			outputStream = response.getOutputStream();
+			outputStream.write(Doc2Pdf.doc2pdf(data));
+			outputStream.flush();
+		} catch (IOException e) {
+			throw new BadRequestException("Incorrect file kannode",Constant.RET_DOCUMENT_ERROR, e);
+		}finally {
+			if(outputStream != null) {
+				try {
+					outputStream.close();
+				} catch (IOException e) {
+				}
+			}
+		}
+		return Response.ok();
+
+	}
 	
 	//*****************************************************************
 	// SetPermissions

+ 10 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/service/FileNodeManagerService.java

@@ -80,6 +80,11 @@ public class FileNodeManagerService {
 		return fileNodeOrganizationDao.get(id);
 	}
 
+	public byte[] getFileNodeOrganizationNode(int id) {
+		FileNodeOrganization fileNodeOrganization = fileNodeOrganizationDao.get(id);
+		return AliyunOSSUtil.getByte(fileNodeOrganization.getNode());
+	}
+
 	public FileNodeOrganization createFileNodeOrganization(InputStream is, String name, int parentId) throws ServiceException {
 		if (parentId != FileNodeOrganization.ROOT_ID) {
 			FileNodeOrganization parentNode = getFileNodeOrganization(parentId);
@@ -197,6 +202,11 @@ public class FileNodeManagerService {
 		return fileNodeProjectDao.get(id);
 	}
 
+	public byte[] getFileNodeProjectNode(int id) {
+		FileNodeProject fileNodeProject = fileNodeProjectDao.get(id);
+		return AliyunOSSUtil.getByte(fileNodeProject.getNode());
+	}
+
 	public FileNodeProject createFileNodeProject(InputStream is, String name, int parentId) throws ServiceException {
 		if (parentId != FileNodeProject.ROOT_ID) {
 			FileNodeProject parentNode = getFileNodeProject(parentId);