From 52d0d62c35d01ee73d9dba7b1be99a29adc35ef2 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 17 八月 2021 10:45:01 +0800
Subject: [PATCH] update 同步 ruoyi 适配改动

---
 ruoyi-framework/src/main/java/com/ruoyi/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java |    6 +++---
 ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java                  |    2 +-
 ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java         |    5 ++---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java                     |    4 ++--
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java                     |    6 +++---
 ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java                           |    4 ++--
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java               |    6 +++---
 7 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
index 08d7e7e..609d41f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
@@ -10,7 +10,7 @@
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.JsonUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.oss.constant.CloudConstant;
@@ -79,7 +79,7 @@
 	@PostMapping("/upload")
 	public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
 		if (file.isEmpty()) {
-			throw new CustomException("涓婁紶鏂囦欢涓嶈兘涓虹┖");
+			throw new ServiceException("涓婁紶鏂囦欢涓嶈兘涓虹┖");
 		}
 		SysOss oss = iSysOssService.upload(file);
 		Map<String, String> map = new HashMap<>(2);
@@ -94,7 +94,7 @@
 	public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
 		SysOss sysOss = iSysOssService.getById(ossId);
 		if (sysOss == null) {
-			throw new CustomException("鏂囦欢鏁版嵁涓嶅瓨鍦�!");
+			throw new ServiceException("鏂囦欢鏁版嵁涓嶅瓨鍦�!");
 		}
 		response.reset();
 		response.addHeader("Access-Control-Allow-Origin", "*");
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java
index 2eb4eb3..e30f83c 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java
@@ -1,6 +1,6 @@
 package com.ruoyi.framework.config;
 
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
 import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -41,7 +41,7 @@
     public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
         return (throwable, method, objects) -> {
             throwable.printStackTrace();
-            throw new CustomException(
+            throw new ServiceException(
                     "Exception message - " + throwable.getMessage()
                     + ", Method name - " + method.getName()
                     + ", Parameter value - " + Arrays.toString(objects));
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java
index 02efe64..ae36fc3 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java
@@ -3,7 +3,7 @@
 import cn.hutool.http.HttpStatus;
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.reflection.MetaObject;
@@ -30,7 +30,7 @@
 				this.setFieldValByName("createBy", getLoginUsername(), metaObject);
 			}
 		} catch (Exception e) {
-			throw new CustomException("鑷姩娉ㄥ叆寮傚父 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
+			throw new ServiceException("鑷姩娉ㄥ叆寮傚父 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
 		}
 		updateFill(metaObject);
 	}
@@ -45,7 +45,7 @@
 				this.setFieldValByName("updateTime", new Date(), metaObject);
 			}
 		} catch (Exception e) {
-			throw new CustomException("鑷姩娉ㄥ叆寮傚父 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
+			throw new ServiceException("鑷姩娉ㄥ叆寮傚父 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
 		}
 	}
 
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
index 4df3265..9cf69ff 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
@@ -2,9 +2,8 @@
 
 import cn.hutool.http.HttpStatus;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.exception.BaseException;
-import com.ruoyi.common.exception.CustomException;
 import com.ruoyi.common.exception.DemoModeException;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -14,8 +13,8 @@
 import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
-import org.springframework.web.servlet.NoHandlerFoundException;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.validation.ConstraintViolationException;
 
 /**
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
index 48bec60..94a9975 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
@@ -267,7 +267,7 @@
 				try {
                 	String path = getGenPath(table, template);
                 	FileUtils.writeUtf8String(sw.toString(), path);
-				} catch (IOException e) {
+				} catch (Exception e) {
 					throw new ServiceException("娓叉煋妯℃澘澶辫触锛岃〃鍚嶏細" + table.getTableName());
 				}
             }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java
index a202790..5a6e8de 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java
@@ -10,7 +10,7 @@
 import com.ruoyi.common.core.page.PagePlus;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.JsonUtils;
 import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -97,7 +97,7 @@
     private void validEntityBeforeSave(SysOssConfig entity){
 		if (StringUtils.isNotEmpty(entity.getConfigKey())
 			&& UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) {
-			throw new CustomException("鎿嶄綔閰嶇疆'" + entity.getConfigKey() + "'澶辫触, 閰嶇疆key宸插瓨鍦�!");
+			throw new ServiceException("鎿嶄綔閰嶇疆'" + entity.getConfigKey() + "'澶辫触, 閰嶇疆key宸插瓨鍦�!");
 		}
     }
 
@@ -105,7 +105,7 @@
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
     	if(isValid) {
 			if (CollUtil.containsAny(ids, CloudConstant.SYSTEM_DATA_IDS)) {
-				throw new CustomException("绯荤粺鍐呯疆, 涓嶅彲鍒犻櫎!");
+				throw new ServiceException("绯荤粺鍐呯疆, 涓嶅彲鍒犻櫎!");
 			}
 		}
         boolean flag = removeByIds(ids);
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java
index 28f0f16..13a2220 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java
@@ -5,7 +5,7 @@
 import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 import com.ruoyi.common.core.page.PagePlus;
 import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.oss.entity.UploadResult;
@@ -61,7 +61,7 @@
 		try {
 			uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
 		} catch (IOException e) {
-			throw new CustomException("鏂囦欢璇诲彇寮傚父!!!", e);
+			throw new ServiceException(e.getMessage());
 		}
 		// 淇濆瓨鏂囦欢淇℃伅
 		SysOss oss = new SysOss()

--
Gitblit v1.9.3