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);
    }
}
相关推荐
苹果醋313 小时前
vue + iview + vue-i18n中英翻译
java·运维·spring boot·mysql·nginx
BD_Marathon13 小时前
Vue3_双向绑定
前端·javascript·vue.js
橙露13 小时前
VMware Workstation Pro 25H2的linux版本,免费分享,下载:全新命名体系 + 深度适配 Linux 内核,虚拟化效率拉满
java·linux·服务器
Knight_AL13 小时前
Redis Lua 脚本为什么天然具备原子性?
数据库·redis·lua
帮帮志13 小时前
启动phcharm报错:Archived non-system classes are disabled because the java.system.
java·开发语言
霍理迪13 小时前
CSS复合、关系、属性、伪类选择器
前端·javascript·css
棒棒的唐13 小时前
Avue2图片上传使用object对象模式时,axios的请求模式用post还是get?
开发语言·前端·javascript·avue
Alex_81D13 小时前
Spring Data JPA以及JPQL等特性详细使用教程
java·数据库·后端
spencer_tseng13 小时前
Eclipse JDT Core for Java Code Formatter
java·ide·eclipse
OnlyEasyCode13 小时前
Linux部署Nginx前后端web教程
linux·前端·nginx