Commit 91b26afd07750394fbce3069534f1c8ef19b8058
1 parent
4d24184b
【I59M95】自定义JeecgCloudException异常供微服务,及starter模块使用,解决注解添加之后无法实现重复提交的拦截提示
Showing
4 changed files
with
30 additions
and
1 deletions
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
... | ... | @@ -38,6 +38,15 @@ public class JeecgBootExceptionHandler { |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | + * 处理自定义微服务异常 | |
42 | + */ | |
43 | + @ExceptionHandler(JeecgCloudException.class) | |
44 | + public Result<?> handleJeecgCloudException(JeecgCloudException e){ | |
45 | + log.error(e.getMessage(), e); | |
46 | + return Result.error(e.getMessage()); | |
47 | + } | |
48 | + | |
49 | + /** | |
41 | 50 | * 处理自定义异常 |
42 | 51 | */ |
43 | 52 | @ExceptionHandler(JeecgBoot401Exception.class) |
... | ... |
jeecg-boot/jeecg-boot-base/jeecg-boot-base-tools/src/main/java/org/jeecg/common/exception/JeecgCloudException.java
0 → 100644
1 | +package org.jeecg.common.exception; | |
2 | + | |
3 | +/** | |
4 | + * @Description: jeecg-cloud自定义异常 | |
5 | + * @Author: zyf | |
6 | + * @Date: 2022-05-30 | |
7 | + */ | |
8 | +public class JeecgCloudException extends RuntimeException { | |
9 | + private static final long serialVersionUID = 1L; | |
10 | + | |
11 | + public JeecgCloudException(String message) { | |
12 | + super(message); | |
13 | + } | |
14 | + | |
15 | +} | |
... | ... |
jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/pom.xml
... | ... | @@ -12,6 +12,10 @@ |
12 | 12 | <description>jeecg-boot-starter-分布式锁</description> |
13 | 13 | <dependencies> |
14 | 14 | <dependency> |
15 | + <groupId>org.jeecgframework.boot</groupId> | |
16 | + <artifactId>jeecg-boot-base-tools</artifactId> | |
17 | + </dependency> | |
18 | + <dependency> | |
15 | 19 | <groupId>org.redisson</groupId> |
16 | 20 | <artifactId>redisson</artifactId> |
17 | 21 | </dependency> |
... | ... |
jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/src/main/java/org/jeecg/boot/starter/lock/aspect/RepeatSubmitAspect.java
... | ... | @@ -11,6 +11,7 @@ import org.aspectj.lang.annotation.Pointcut; |
11 | 11 | import org.aspectj.lang.reflect.MethodSignature; |
12 | 12 | import org.jeecg.boot.starter.lock.annotation.JRepeat; |
13 | 13 | import org.jeecg.boot.starter.lock.client.RedissonLockClient; |
14 | +import org.jeecg.common.exception.JeecgCloudException; | |
14 | 15 | import org.springframework.core.LocalVariableTableParameterNameDiscoverer; |
15 | 16 | import org.springframework.stereotype.Component; |
16 | 17 | |
... | ... | @@ -63,7 +64,7 @@ public class RepeatSubmitAspect extends BaseAspect{ |
63 | 64 | return joinPoint.proceed(); |
64 | 65 | } else { |
65 | 66 | // 未获取到锁 |
66 | - throw new Exception("请勿重复提交"); | |
67 | + throw new JeecgCloudException("请勿重复提交"); | |
67 | 68 | } |
68 | 69 | } finally { |
69 | 70 | // 如果锁还存在,在方法执行完成后,释放锁 |
... | ... |