This commit is contained in:
2025-11-03 10:33:30 +08:00
parent 148583cdaa
commit e924e8c0e6
46 changed files with 1151 additions and 428 deletions

View File

@@ -8,6 +8,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import quant.rich.emoney.annotation.LockByCaller;
import quant.rich.emoney.util.CallerLockUtil;
import java.lang.reflect.Method;
@@ -19,7 +20,7 @@ public class CallerLockAspect {
private final SpelExpressionParser parser = new SpelExpressionParser();
@Around("@annotation(com.example.lock.LockByCaller)")
@Around("@annotation(me.qwq.emoney.annotation.LockByCaller)")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Method method = signature.getMethod();

View File

@@ -175,7 +175,8 @@ public class EmoneyAutoPlatformExceptionHandler {
if (ex instanceof NoResourceFoundException nrfe) {
if (StringUtils.isNotEmpty(nrfe.getMessage())
&& nrfe.getMessage().endsWith(" .well-known/appspecific/com.chrome.devtools.json.")) {
// 傻逼 Chrome 开发工具默认调用该地址
// 傻逼 Chrome 开发工具在本地调试时默认调用该地址
// see: https://blog.ni18.in/well-known-appspecific-com-chrome-devtools-json-request/
return null;
}
}

View File

@@ -1,24 +0,0 @@
package quant.rich.emoney.component;
import java.lang.annotation.*;
/**
* 在方法上添加此注解,可针对调用方加锁,即:<br>
* 调用方法为 A 的,多次从 A 调用则加锁,从 B 调用时不受影响<br>
* 需要开启 AOP在任意配置类上增加注解<i><code>@EnableAspectJAutoProxy</code></i>
* @see CallerLockAspect
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface LockByCaller {
/**
* 可选参数,用于 SpEL 表达式获取 key
* 例如:<ul>
* <li>@LockByCaller(key = "#userId")</li>
* <li>@LockByCaller(key = "#userId + ':' + #userName")</li>
* </ul>
* 当不指定时,不校验参数,单纯校验 Caller
*/
String key() default "";
}