sa-token 统一redis 前缀

xml 复制代码
		<dependency>
            <groupId>cn.dev33</groupId>
            <artifactId>sa-token-reactor-spring-boot3-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>cn.dev33</groupId>
            <artifactId>sa-token-redis-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

启动类增加注解

java 复制代码
@EnableAspectJAutoProxy
java 复制代码
package com.ys.config;

import com.alibaba.fastjson2.JSON;
import com.ys.constant.RedisConstant;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author kong
 */
@Aspect
@Component
@Slf4j
public class SaTokenDaoRedisJacksonAspect {

    // 定义切点,匹配SomeClass类的所有方法
    @Pointcut("execution(* cn.dev33.satoken.dao.SaTokenDaoRedisJackson.*(..))")
    public void methodPointcut() {
    }

    // 在方法执行前执行的操作
    @Around("methodPointcut()")
    public Object beforeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();

        for (int i = 0, n = args.length; i < n; i++) {
            if (args[i] instanceof String temp) {
                if (temp.contains("token")) {
                    args[i] = RedisConstant.PREFIX + temp;

                }
            }
        }

        return joinPoint.proceed(args);
    }
}
相关推荐
一城烟雨_1 小时前
vue3 实现将html内容导出为图片、pdf和word
前端·javascript·vue.js·pdf
树懒的梦想2 小时前
调整vscode的插件安装位置
前端·cursor
此木|西贝2 小时前
【设计模式】享元模式
java·设计模式·享元模式
低代码布道师3 小时前
第二部分:网页的妆容 —— CSS(下)
前端·css
一纸忘忧3 小时前
成立一周年!开源的本土化中文文档知识库
前端·javascript·github
李少兄3 小时前
解决Spring Boot多模块自动配置失效问题
java·spring boot·后端
涵信4 小时前
第九节:性能优化高频题-首屏加载优化策略
前端·vue.js·性能优化
bxlj_jcj4 小时前
JVM性能优化之年轻代参数设置
java·性能优化
八股文领域大手子4 小时前
深入理解缓存淘汰策略:LRU 与 LFU 算法详解及 Java 实现
java·数据库·算法·缓存·mybatis·哈希算法