Custom Paging comment
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD,ElementType.TYPE}) @Documented public @interface EnablePage { String value() default ""; }
Defined paged interception
@Aspect @Component public class PageAop the extends BaseService { / ** * defined entry point in the entry point for all functions com.example.fileupload.controller * / @Pointcut ( "Execution (* com.liuchao.mayikttest.mapper public. *. * (..)) " ) / * * defines the point of attachment * / public void Weblog () { } @Around ( " Weblog () " ) public Object doAroundAdvice (ProceedingJoinPoint ProceedingJoinPoint) throws the Throwable { MethodSignature MethodSignature = (MethodSignature) proceedingJoinPoint.getSignature (); Method, Method = methodSignature.getMethod(); EnablePage enablePage = method.getAnnotation(EnablePage.class); if(StringUtils.isEmpty(enablePage)){ Object obj = proceedingJoinPoint.proceed(); return obj; } HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String pageNo = request.getParameter("pageNo"); String pageSize = request.getParameter("pageSize"); PageHelper.startPage(Integer.valueOf(pageNo), Integer.valueOf(pageSize)); Object proceed = proceedingJoinPoint.proceed(); return proceed; /*BaseResponse baseResponse =(BaseResponse) proceedingJoinPoint.proceed(); List data = (List)baseResponse.getData(); PageInfo pageInfo = new PageInfo(data); return setSuccess(pageInfo);*/ } }
On Mapper method paged annotate
public interface UserMapper { @EnablePage List<UserDO> findAll(); UserDO findById(int id); }
Return information page information with paging