From 041e023f2c05e3ca29c9ca0a37a4f37425c81906 Mon Sep 17 00:00:00 2001 From: chenfei <18955928961@163.com> Date: Fri, 19 Aug 2022 11:27:08 +0800 Subject: [PATCH] =?UTF-8?q?ai=E4=B8=8A=E4=BC=A0=E5=8F=82=E6=95=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=85=B7=E4=BD=93=E5=9B=BE=E7=89=87=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/web/controller/api/AppController.java | 8 ++++---- .../com/ruoyi/web/controller/common/CommonController.java | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index d911114..94c88c2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -419,7 +419,7 @@ public class AppController extends BaseController tImage.setThirdId(recordId); tImage.setCreateTime(new Date()); tImage.setName(name); - String path=GenerateImage(value); + String path=GenerateImage(value,name); tImage.setPath(path); imageService.insertTImage(tImage); } @@ -465,7 +465,7 @@ public class AppController extends BaseController { String imageKey=keys[i]; String imgStr=parents.get(i).getJSONObject(imageKey).getString("v"); - String path=GenerateImage(imgStr); + String path=GenerateImage(imgStr,imageKey); parents.get(i).getJSONObject(keys[i]).put("v",null); TImage tImage = new TImage(); tImage.setName(imageKey); @@ -495,7 +495,7 @@ public class AppController extends BaseController } - public static String GenerateImage(String imgStr) + public static String GenerateImage(String imgStr,String imageName) { BASE64Decoder decoder = new BASE64Decoder(); @@ -515,7 +515,7 @@ public class AppController extends BaseController } catch (Exception e) { - throw new ServiceException("Base64转图片错误"); + throw new ServiceException(imageName + " :Base64转图片错误"); } } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index cec5006..cc24194 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -23,7 +23,7 @@ import com.ruoyi.framework.config.ServerConfig; /** * 通用请求处理 - * + * * @author ruoyi */ @RestController @@ -39,7 +39,7 @@ public class CommonController /** * 通用下载请求 - * + * * @param fileName 文件名称 * @param delete 是否删除 */ @@ -77,6 +77,9 @@ public class CommonController { try { + if(file == null){ + return AjaxResult.error("上传文件为空"); + } // 上传文件路径 String filePath = RuoYiConfig.getUploadPath(); // 上传并返回新文件名称