一、分页注解
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})//该注解范围用于方法
public @interface Paging {}
二、分页切面
@Aspect
@Component
public class PageAspect {
@PointCut("execution(切面表达式的作用范围)")
public void pagingCut() {}
//前置条件是上述切面表达式和方法加了Paging注解
@Around(value = "pagingCut() && @annotation(paging)")
public Object doPage(ProceedingJointPoint jp, Paging paging) {
try () {
//PageHelper进行分页逻辑
return jp.proceed();
} ...
}
}