38 lines
1002 B
Java
38 lines
1002 B
Java
|
|
package com.jojubanking.boot.server;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
|
||
|
|
import org.aspectj.lang.JoinPoint;
|
||
|
|
import org.aspectj.lang.annotation.Aspect;
|
||
|
|
import org.aspectj.lang.annotation.Before;
|
||
|
|
import org.aspectj.lang.annotation.Pointcut;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @ClassName: MybatisAspectj
|
||
|
|
* @Description:
|
||
|
|
* @Author T.W
|
||
|
|
* @Date 2023/4/4
|
||
|
|
* @Version 1.0
|
||
|
|
*/
|
||
|
|
@Aspect
|
||
|
|
@Component
|
||
|
|
public class MybatisAspectj {
|
||
|
|
|
||
|
|
// 配置织入点
|
||
|
|
// package com.jojubanking.boot.framework.mybatis.core.mapper.selectOne
|
||
|
|
|
||
|
|
//?
|
||
|
|
@Pointcut("execution(public * com.baomidou.mybatisplus.core.mapper.BaseMapper.selectOne(..))")
|
||
|
|
public void selectOneAspect() {
|
||
|
|
}
|
||
|
|
|
||
|
|
@Before("selectOneAspect()")
|
||
|
|
public void beforeSelect(JoinPoint point) {
|
||
|
|
Object arg = point.getArgs()[0];
|
||
|
|
if (arg instanceof AbstractWrapper) {
|
||
|
|
arg = (AbstractWrapper) arg;
|
||
|
|
((AbstractWrapper) arg).last("limit 1");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|