From 3dd3bc576dada8216099348ad8fd93fc070622b6 Mon Sep 17 00:00:00 2001
From: 杜洪波 <1074825718@qq.com>
Date: 星期五, 15 八月 2025 10:48:59 +0800
Subject: [PATCH] PDF操作类
---
src/main/java/com/product/file/controller/FileManagerController.java | 640 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 354 insertions(+), 286 deletions(-)
diff --git a/src/main/java/com/product/file/controller/FileManagerController.java b/src/main/java/com/product/file/controller/FileManagerController.java
index 660c754..e1acd6a 100644
--- a/src/main/java/com/product/file/controller/FileManagerController.java
+++ b/src/main/java/com/product/file/controller/FileManagerController.java
@@ -1,12 +1,14 @@
package com.product.file.controller;
import com.alibaba.fastjson.JSONObject;
+import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.file.config.CmnConst;
import com.product.file.config.FileCode;
import com.product.file.service.FileManagerService;
import com.product.module.sys.version.ApiVersion;
@@ -30,321 +32,387 @@
@RestController
public class FileManagerController extends AbstractBaseController {
- @Autowired
- public FileManagerService fileManagerService;
+ @Autowired
+ public FileManagerService fileManagerService;
- /**
- * @param uuid
- * @param response
- * @return
- */
- @GetMapping("/get-static-file/{version}")
- @ApiVersion(1)
- public String getStaticFile(@RequestParam("uuid") String uuid, HttpServletResponse response) {
- try {
- // 娌℃湁鐧诲綍锛岀櫧鍚嶅崟涓� 璇ユ帴鍙d腑涓嶈兘鑾峰彇 token 鍜� 褰撳墠鐢ㄦ埛
- fileManagerService.getStaticFile(uuid, response);
- return OK();
- } catch (BaseException e) {
- e.printStackTrace();
- return error(e);
- } catch (Exception e) {
- e.printStackTrace();
- SpringMVCContextHolder.getSystemLogger().error(e);
- return error(FileCode.GET_FILE_FAIL);
- }
- }
+ /**
+ * @param uuid
+ * @param response
+ * @return
+ */
+ @GetMapping("/get-static-file/{version}")
+ @ApiVersion(1)
+ public String getStaticFile(@RequestParam("uuid") String uuid, HttpServletResponse response) {
+ try {
+ // 娌℃湁鐧诲綍锛岀櫧鍚嶅崟涓� 璇ユ帴鍙d腑涓嶈兘鑾峰彇 token 鍜� 褰撳墠鐢ㄦ埛
+ fileManagerService.getStaticFile(uuid, response);
+ return OK();
+ } catch (BaseException e) {
+ e.printStackTrace();
+ return error(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return error(FileCode.GET_FILE_FAIL);
+ }
+ }
- /**
- * 鑾峰彇瀹㈡埛涓婁紶鐨勬枃浠舵�诲ぇ灏�
- *
- * @param request 璇锋眰
- * @return 缁撴灉
- */
- @RequestMapping(value = "/find-client-file-uesd-capacity/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String findClientFileUsedCapacity(HttpServletRequest request) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
+ /**
+ * 鑾峰彇瀹㈡埛涓婁紶鐨勬枃浠舵�诲ぇ灏�
+ *
+ * @param request 璇锋眰
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/find-client-file-uesd-capacity/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String findClientFileUsedCapacity(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
- long usedCapacity = fileManagerService.findClientFileUsedCapacity(fse.getString("client_uuid"));
- JSONObject data = new JSONObject();
- data.put("used_capacity", String.valueOf(usedCapacity));
- JSONObject result = new JSONObject();
- result.put("data", data);
- result.put("msg", FileCode.SUCCESS.getText());
- result.put("code", "200");
- result.put("status", "success");
- return result.toString();
- } catch (BaseException e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- return this.error(e.getCode(), e.getMessageInfo());
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.GET_DATA_FAIL.getValue(), FileCode.GET_DATA_FAIL.getText());
- }
- }
+ long usedCapacity = fileManagerService.findClientFileUsedCapacity(fse.getString("client_uuid"));
+ JSONObject data = new JSONObject();
+ data.put("used_capacity", String.valueOf(usedCapacity));
+ JSONObject result = new JSONObject();
+ result.put("data", data);
+ result.put("msg", FileCode.SUCCESS.getText());
+ result.put("code", "200");
+ result.put("status", "success");
+ return result.toString();
+ } catch (BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e.getCode(), e.getMessageInfo());
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_DATA_FAIL.getValue(), FileCode.GET_DATA_FAIL.getText());
+ }
+ }
- /**
- * 鑾峰彇瀹㈡埛鍓╀綑鐨勬枃浠舵�诲ぇ灏�
- *
- * @param request 璇锋眰
- * @return 缁撴灉
- */
- @RequestMapping(value = "/find-client-file-residue-capacity/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String findClientFileResidueCapacity(HttpServletRequest request) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
+ /**
+ * 鑾峰彇瀹㈡埛鍓╀綑鐨勬枃浠舵�诲ぇ灏�
+ *
+ * @param request 璇锋眰
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/find-client-file-residue-capacity/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String findClientFileResidueCapacity(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
- long residueCapacity = fileManagerService.findClientFileResidueCapacity(fse.getString("client_uuid"));
- JSONObject data = new JSONObject();
- data.put("residue_capacity", String.valueOf(residueCapacity));
- JSONObject result = new JSONObject();
- result.put("data", data);
- result.put("msg", FileCode.SUCCESS.getText());
- result.put("code", "200");
- result.put("status", "success");
- return result.toString();
- } catch (BaseException e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- return this.error(e.getCode(), e.getMessageInfo());
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.GET_DATA_FAIL.getValue(), FileCode.GET_DATA_FAIL.getText());
- }
- }
+ long residueCapacity = fileManagerService.findClientFileResidueCapacity(fse.getString("client_uuid"));
+ JSONObject data = new JSONObject();
+ data.put("residue_capacity", String.valueOf(residueCapacity));
+ JSONObject result = new JSONObject();
+ result.put("data", data);
+ result.put("msg", FileCode.SUCCESS.getText());
+ result.put("code", "200");
+ result.put("status", "success");
+ return result.toString();
+ } catch (BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e.getCode(), e.getMessageInfo());
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_DATA_FAIL.getValue(), FileCode.GET_DATA_FAIL.getText());
+ }
+ }
- /**
- * 楠岃瘉鏄惁鍏佽涓婁紶鐨勬枃浠剁被鍨�
- *
- * @param request 璇锋眰
- * @return 缁撴灉
- */
- @RequestMapping(value = "/check-is-allowed-file-type/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String checkIsAllowedFileType(HttpServletRequest request) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
+ /**
+ * 楠岃瘉鏄惁鍏佽涓婁紶鐨勬枃浠剁被鍨�
+ *
+ * @param request 璇锋眰
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/check-is-allowed-file-type/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String checkIsAllowedFileType(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
- boolean f = fileManagerService.checkIsAllowedFileType(fse.getString("attachment_name"));
- return f ? this.OK() : this.error(FileCode.CHECK_FAIL.getValue(), FileCode.CHECK_FAIL.getText());
- } catch (BaseException e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- return this.error(e.getCode(), e.getMessageInfo());
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.CHECK_FAIL.getValue(), FileCode.CHECK_FAIL.getText());
- }
- }
+ boolean f = fileManagerService.checkIsAllowedFileType(fse.getString("attachment_name"));
+ return f ? this.OK() : this.error(FileCode.CHECK_FAIL.getValue(), FileCode.CHECK_FAIL.getText());
+ } catch (BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ return this.error(e.getCode(), e.getMessageInfo());
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.CHECK_FAIL.getValue(), FileCode.CHECK_FAIL.getText());
+ }
+ }
- /**
- * 鑾峰彇鍘熷鍩熷悕
- *
- * @return 缁撴灉
- */
- @RequestMapping(value = "/find-source-domain/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String findSourceDomain() {
- try {
- String sourceDomain = fileManagerService.findSourceDomain();
+ /**
+ * 鑾峰彇鍘熷鍩熷悕
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/find-source-domain/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String findSourceDomain() {
+ try {
+ String sourceDomain = fileManagerService.findSourceDomain();
- JSONObject data = new JSONObject();
- data.put("source_domain", sourceDomain);
- JSONObject result = new JSONObject();
- result.put("data", data);
- result.put("msg", FileCode.SUCCESS.getText());
- result.put("code", "200");
- result.put("status", "success");
- return result.toString();
- } catch (Exception e) {
+ JSONObject data = new JSONObject();
+ data.put("source_domain", sourceDomain);
+ JSONObject result = new JSONObject();
+ result.put("data", data);
+ result.put("msg", FileCode.SUCCESS.getText());
+ result.put("code", "200");
+ result.put("status", "success");
+ return result.toString();
+ } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.FIND_SOURCE_DOMAIN_FAIL.getValue(), FileCode.FIND_SOURCE_DOMAIN_FAIL.getText());
- }
- }
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.FIND_SOURCE_DOMAIN_FAIL.getValue(), FileCode.FIND_SOURCE_DOMAIN_FAIL.getText());
+ }
+ }
- /**
- * 鎵嬪姩瑙﹀彂鏃犵敤鏁版嵁娓呯┖
- *
- * @return 缁撴灉
- */
- @RequestMapping(value = "/clear-no-used-data/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String clearNoUsedData() {
- try {
- boolean reuslt = fileManagerService.autoClearNoUsedData();
- JSONObject result = new JSONObject();
- result.put("msg", FileCode.SUCCESS.getText());
- result.put("code", "200");
- result.put("status", reuslt);
- return result.toString();
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.CLEAR_NO_USED_DATA_FAIL.getValue(), FileCode.CLEAR_NO_USED_DATA_FAIL.getText());
- }
- }
+ /**
+ * 鎵嬪姩瑙﹀彂鏃犵敤鏁版嵁娓呯┖
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/clear-no-used-data/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String clearNoUsedData() {
+ try {
+ boolean reuslt = fileManagerService.autoClearNoUsedData();
+ JSONObject result = new JSONObject();
+ result.put("msg", FileCode.SUCCESS.getText());
+ result.put("code", "200");
+ result.put("status", reuslt);
+ return result.toString();
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.CLEAR_NO_USED_DATA_FAIL.getValue(), FileCode.CLEAR_NO_USED_DATA_FAIL.getText());
+ }
+ }
- /**
- * 鏂囦欢鍒櫎
- *
- * @param request
- * @return
- */
- @RequestMapping(value = "/delete-file/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String deleteFile(HttpServletRequest request) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
- return BaseUtil.success(fileManagerService.delFiles(fse), null);
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.CLEAR_NO_USED_DATA_FAIL.getValue(), FileCode.CLEAR_NO_USED_DATA_FAIL.getText());
- }
- }
+ /**
+ * 鏂囦欢鍒櫎
+ *
+ * @param request
+ * @return
+ */
+ @RequestMapping(value = "/delete-file/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String deleteFile(HttpServletRequest request) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
+ return BaseUtil.success(fileManagerService.delFiles(fse), null);
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.CLEAR_NO_USED_DATA_FAIL.getValue(), FileCode.CLEAR_NO_USED_DATA_FAIL.getText());
+ }
+ }
- /**
- * 涓婁紶鏂囦欢
- *
- * @return 缁撴灉
- */
- @RequestMapping(value = "/upload-file/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String uploadFile(HttpServletRequest request) {
- try {
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- FieldSetEntity fieldSetEntity = fileManagerService.uploadFile(rpe);
- return OK_List(fieldSetEntity);
- } catch (BaseException e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(e.getCode(), e.getMessage());
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.UPLOAD_FILE_FAIL.getValue(), FileCode.UPLOAD_FILE_FAIL.getText());
- }
- }
+ /**
+ * 涓婁紶鏂囦欢
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/upload-file/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String uploadFile(HttpServletRequest request) {
+ try {
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ FieldSetEntity fieldSetEntity = fileManagerService.uploadFile(rpe);
+ return OK_List(fieldSetEntity);
+ } catch (BaseException e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(e.getCode(), e.getMessage());
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.UPLOAD_FILE_FAIL.getValue(), FileCode.UPLOAD_FILE_FAIL.getText());
+ }
+ }
+ /**
+ * 绉诲姩绔崌绾т笅杞藉畨瑁呮枃浠�
+ * 姝ゆ帴鍙i渶瑕佸姞鍏ョ櫧鍚嶅崟
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/upgrade-download/{version}", method = RequestMethod.GET)
+ @ApiVersion(1)
+ public String getAppFileContents(@RequestParam("uuid") String uuid,HttpServletRequest request, HttpServletResponse response) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ fse=new FieldSetEntity();
+ fse.setTableName("product_sys_attachments");
+ fse.setValue("uuid",uuid);
+ fse.setValue("needOnlineView", 0);
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+// return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
+ SpringMVCContextHolder.getSystemLogger().info("閫氳繃GET璇锋眰鑾峰彇闄勪欢鍐呭");
+ // 姝e紡浠g爜
+ fileManagerService.getFileContent(fse, response ,true);
+ return OK();
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
+ }
+ }
+ /**
+ * 涓嬭浇鏂囦欢鎴栬�呭湪绾块瑙�
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/get-file-content/{version}", method = RequestMethod.GET)
+ @ApiVersion(1)
+ public String getFileContents(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
+ SpringMVCContextHolder.getSystemLogger().info("閫氳繃GET璇锋眰鑾峰彇闄勪欢鍐呭");
+ // 姝e紡浠g爜
+ fileManagerService.getFileContent(fse, response);
+ return OK();
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
+ }
+ }
- /**
- * 涓嬭浇鏂囦欢鎴栬�呭湪绾块瑙�
- *
- * @return 缁撴灉
- */
- @RequestMapping(value = "/get-file-content/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String getFileContent(HttpServletRequest request, HttpServletResponse response) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
- // 姝e紡浠g爜
- fileManagerService.getFileContent(fse, response);
- /*===test-start===*/
+ /**
+ * 涓嬭浇鏂囦欢鎴栬�呭湪绾块瑙�
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/get-file-content/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String getFileContent(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
+ // 姝e紡浠g爜
+ fileManagerService.getFileContent(fse, response);
+ /*===test-start===*/
// String tempPath = fse.getString("tempPath");
// File file = new File(tempPath);
// OutputStream sos = new FileOutputStream(file);
// fileManagerService.getFileContent(fse, sos);
// sos.close();
- /*===test-start===*/
- return OK();
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
- }
- }
+ /*===test-start===*/
+ return OK();
+ } catch (BaseException e) {
+ e.printStackTrace();
+ return error(e);
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
+ }
+ }
- /**
- * 鎵归噺鎵撳寘涓嬭浇
- *
- * @return 缁撴灉
- */
- @RequestMapping(value = "/download-file-zip/{version}", method = RequestMethod.POST)
- @ApiVersion(1)
- public String downLoadFileZip(HttpServletRequest request, HttpServletResponse response) {
- try {
- FieldSetEntity fse = null;
- Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
- RequestParameterEntity rpe = (RequestParameterEntity) bean;
- if (null != rpe && null != rpe.getFormData()) {
- fse = rpe.getFormData();
- }
- if (fse == null) {
- SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
- }
+ /**
+ * 鎵归噺鎵撳寘涓嬭浇
+ *
+ * @return 缁撴灉
+ */
+ @RequestMapping(value = "/download-file-zip/{version}", method = RequestMethod.POST)
+ @ApiVersion(1)
+ public String downLoadFileZip(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ FieldSetEntity fse = null;
+ Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+ RequestParameterEntity rpe = (RequestParameterEntity) bean;
+ if (null != rpe && null != rpe.getFormData()) {
+ fse = rpe.getFormData();
+ }
+ if (fse == null) {
+ SpringMVCContextHolder.getSystemLogger().error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ return this.error(FileCode.FORM_NODATA.getValue(), FileCode.FORM_NODATA.getText());
+ }
- response.setContentType("multipart/form-data");
- // 姝e紡浠g爜
- fileManagerService.downLoadFileZip(fse, response);
+ response.setContentType("multipart/form-data");
+ // 姝e紡浠g爜
+ fileManagerService.downLoadFileZip(fse, response);
- /*===test-start===*/
+ /*===test-start===*/
// String tempPath ="D:\\Desktop\\ccc.zip";
// File file = new File(tempPath);
// OutputStream sssos = new FileOutputStream(file);
// fileManagerService.downLoadFileZip(fse, sssos);
// sssos.close();
- /*===test-start===*/
- return OK();
- } catch (Exception e) {
- SpringMVCContextHolder.getSystemLogger().error(e);
- e.printStackTrace();
- return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
- }
- }
+ /*===test-start===*/
+ return OK();
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
+ e.printStackTrace();
+ return error(FileCode.GET_FILE_CONTENT_FAIL.getValue(), FileCode.GET_FILE_CONTENT_FAIL.getText());
+ }
+ }
}
--
Gitblit v1.9.2