2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.landtool.lanbase.common.aspect;
 
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
 
import com.landtool.lanbase.common.exception.LanbaseException;
 
/**
 * @author lanbase
 * @Description: TODO(Redis切面处理类)
 * @date 2017-6-23 15:07
 */
@Aspect
@Configuration
public class RedisAspect {
 
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    //是否开启redis缓存  true开启   false关闭
    @Value("${spring.redis.open: #{false}}")
    private boolean open;
 
    @Around("execution(* com.landtool.lanbase.common.utils.RedisUtils.*(..))")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        Object result = null;
        if(open){
            try{
                result = point.proceed();
            }catch (Exception e){
                logger.error("redis error", e);
                throw new LanbaseException("Redis服务异常");
            }
        }
        return result;
    }
}