From f08a344c1c080a94d4817414461678d63de2b805 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Tue, 16 May 2023 09:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/idc/controller/FileController.java | 22 ++++------ .../idc/service/impl/FileServiceImpl.java | 44 +++++++++---------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java index 2be613c..00dcc56 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java @@ -16,10 +16,6 @@ import com.glxp.sale.admin.idc.service.FileService; import com.glxp.sale.common.res.BaseResponse; - - - - /** * 中继服务接口 */ @@ -32,30 +28,28 @@ public class FileController { @RequestMapping(value = "/spssync/file/upload") @ResponseBody public BaseResponse upload(HttpServletRequest request, @RequestBody Map params) { - return fileService.fileUpload(request,params); + return fileService.fileUpload(request, params); } - + @RequestMapping(value = "/spssync/file/download") @ResponseBody public BaseResponse download(HttpServletRequest request, @RequestBody Map params) { - return fileService.fileDownload(request,params); + return fileService.fileDownload(request, params); } - + @RequestMapping(value = "/spssync/file/downloadFile") @ResponseBody public BaseResponse downloadFile(HttpServletRequest request, @RequestBody Map params) { - return fileService.downloadFile(request,params); + return fileService.downloadFile(request, params); } - + @RequestMapping(value = "/spssync/file/uploadFile") public BaseResponse uploadFile(HttpServletRequest request, - @RequestParam(value = "content" , required = false) String content, - @RequestParam(value = "files", required = false) MultipartFile[] files) { + @RequestParam(value = "content", required = false) String content, + @RequestParam(value = "files", required = false) MultipartFile[] files) { // return fileService.receiveFile(request, content, files); } - - } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java index 74bebd4..bdc492e 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java @@ -46,7 +46,7 @@ public class FileServiceImpl implements FileService { private String apiKey; @Value("${API_SECRET}") private String apiSecret; - + @Resource private DbDao dbDao; @Resource @@ -60,7 +60,7 @@ public class FileServiceImpl implements FileService { if(map!=null&&map.get("syncIp")!=null) host = map.get("syncIp").toString(); } catch (Exception ex) { - + } if(StringUtils.isEmpty(host)) { try { @@ -68,7 +68,7 @@ public class FileServiceImpl implements FileService { if(config!=null&&config.get("paramValue")!=null) host = config.get("paramValue").toString(); } catch (Exception ex) { - + } } if(StringUtils.isEmpty(host)) @@ -96,9 +96,9 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.error(9999,"失败"); } - - - + + + @Override public BaseResponse fileDownload(HttpServletRequest request,Map params) { Map map = dbDao.get("select * from sync_data_set limit 1"); @@ -109,7 +109,7 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.success(null); } - + @Override public BaseResponse receiveFile(HttpServletRequest request,String content,MultipartFile[] files) { boolean isRelay = false; @@ -121,9 +121,9 @@ public class FileServiceImpl implements FileService { isRelay = true; host = config.get("paramValue").toString(); } - + } catch (Exception ex) { - + } ArrayList saveFiles = new ArrayList<>(); Date startTime = new Date(); @@ -157,12 +157,12 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.success(null); } - + /*转发图片*/ private String relayFile(ArrayList files, String ip) { String host = ip; String result = ""; - + if (!StringUtils.isEmpty(host)) { host += "/spssync/file/uploadFile"; OkHttpClient client = new OkHttpClient().newBuilder() @@ -185,7 +185,7 @@ public class FileServiceImpl implements FileService { } } } - + RequestBody body = builder.build(); Request req = new Request.Builder() @@ -211,8 +211,8 @@ public class FileServiceImpl implements FileService { } return result; } - - + + @Override public BaseResponse downloadFile(HttpServletRequest request,Map params) { String host = ""; @@ -221,11 +221,11 @@ public class FileServiceImpl implements FileService { if(config!=null&&config.get("paramValue")!=null) host = config.get("paramValue").toString(); } catch (Exception ex) { - + ex.printStackTrace(); } if(!StringUtils.isEmpty(host)) { - String result = IDCUtils.post(host+"/spssync/file/downloadFile", params); - + String result = IDCUtils.post(host+"/spssync/file/downloadFile", params); + JSONObject object = JSON.parseObject(result); boolean success = false; if(object.getInteger("code")==20000) { @@ -237,10 +237,10 @@ public class FileServiceImpl implements FileService { } } if(!success) - ResultVOUtils.error(9999,"失败"); - + ResultVOUtils.error(9999,"失败"); + } - return ResultVOUtils.success(null); + return ResultVOUtils.success(null); } - -} \ No newline at end of file + +}