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

com.gitee.qdbp.jdbc.stream.SqlOnIdPairPagingResultStream Maven / Gradle / Ivy

package com.gitee.qdbp.jdbc.stream;

import org.springframework.jdbc.core.RowMapper;
import com.gitee.qdbp.able.jdbc.paging.PageList;
import com.gitee.qdbp.able.jdbc.paging.Paging;
import com.gitee.qdbp.jdbc.api.SqlDao;

/**
 * 同时设置queryId/countId, 分页+结果转换后续操作, 只有list()
 *
 * @author zhaohuihua
 * @version 20210530
 */
public class SqlOnIdPairPagingResultStream {

    protected final SqlDao dao;
    protected final String queryId;
    protected final String countId;
    protected final Object params;
    protected final Paging paging;

    protected Class resultType;
    protected RowMapper rowMapper;

    SqlOnIdPairPagingResultStream(SqlDao dao, String queryId, String countId, Object params, Paging paging,
            Class resultType) {
        this.dao = dao;
        this.queryId = queryId;
        this.countId = countId;
        this.params = params;
        this.paging = paging;
        this.resultType = resultType;
    }

    SqlOnIdPairPagingResultStream(SqlDao dao, String queryId, String countId, Object params, Paging paging,
            RowMapper rowMapper) {
        this.dao = dao;
        this.queryId = queryId;
        this.countId = countId;
        this.params = params;
        this.paging = paging;
        this.rowMapper = rowMapper;
    }

    /**
     * 查询列表
*
    List<SysUser> users = qdbcBoot.sqlStream()
        .sqlId("SysUserMapper:queryRoleUsers", "SysUserMapper:countRoleUsers")
        .params(map)
        .pageBy(1,10)
        .resultAs(SysUser.class)
        .list().asPartList(); // 分页后返回的是PageList, 需要转换为普通List
     * 
* * @return 查询结果列表 */ public PageList list() { if (resultType != null) { return this.dao.pageForObjects(queryId, countId, params, paging, resultType); } else { return this.dao.pageForObjects(queryId, countId, params, paging, rowMapper); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy