|
|
|
@ -23,13 +23,14 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class DistributedLockHandler {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
@Autowired(required = false)
|
|
|
|
|
private RedissonLock redissonLock;
|
|
|
|
|
|
|
|
|
|
@Around("@annotation(distributedLock)")
|
|
|
|
|
public Object around(ProceedingJoinPoint joinPoint, DistributedLock distributedLock) {
|
|
|
|
|
public Object around(ProceedingJoinPoint joinPoint, DistributedLock distributedLock) throws Throwable {
|
|
|
|
|
Object returnValue = null;
|
|
|
|
|
|
|
|
|
|
if(redissonLock != null){
|
|
|
|
|
log.info("[开始]执行RedisLock环绕通知,获取Redis分布式锁开始");
|
|
|
|
|
//获取锁名称
|
|
|
|
|
String lockName = distributedLock.value();
|
|
|
|
@ -49,6 +50,9 @@ public class DistributedLockHandler {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("释放Redis分布式锁[成功],解锁完成,结束业务逻辑...");
|
|
|
|
|
}else {
|
|
|
|
|
returnValue = joinPoint.proceed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
}
|
|
|
|
|