All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.pagehelper.PageHelperHandler Maven / Gradle / Ivy

There is a newer version: 3.6.16
Show newest version
package com.github.pagehelper;

import com.jn.langx.pipeline.AbstractHandler;
import com.jn.langx.pipeline.HandlerContext;
import com.jn.langx.pipeline.Pipelines;
import com.jn.sqlhelper.mybatis.MybatisUtils;
import com.jn.sqlhelper.mybatis.plugins.ExecutorInvocation;

/**
 * after PaginationHandler
 * before sink handler
 */
public class PageHelperHandler extends AbstractHandler {
    @Override
    public void inbound(HandlerContext ctx) throws Throwable {
        ExecutorInvocation executorInvocation = (ExecutorInvocation) ctx.getPipeline().getTarget();
        if (MybatisUtils.isQueryStatement(executorInvocation.getMappedStatement()) && executorInvocation.getMethodName().equals("query")) {
            Page page = PageHelper.getLocalPage();
            if (page != null) {
                executorInvocation.setResult(page);
            }
            PageHelper.clearPage();
        } else {
            Pipelines.skipHandler(ctx, true);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy