🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 组件源码 /** * <b>方法描述:</b> 数据分页查询 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-03-28 15:01:23 <br/> * * @param poolName * 入参|数据源,为空使用默认|{@link java.lang.String} * @param tableName * 入参|表名称|{@link java.lang.String} * @param selectValue * 入参|查询列(可以空,全部字段)| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @param conditions * 入参|查询的条件(可以传空) 传入值例子: { * 'name':{'in':['zhengSan','liSi','wangWu']},'age':{'between':['20','60']},'gender':{'=':['男']} * }|{@link com.ylink.ide.trade.runtime.context.JavaContainer} * @param orderByValue * 入参|排序查询列名(可以传空) 例如:' 'name desc,age asc'' | * {@link java.lang.String} * @param pageNum * 入参|查询页码(默认1)|{@link int} * @param pageSize * 入参|每页查询条数(默认8)|{@link int} * @param cnt * 出参|总行数|{@link long} * @param pages * 出参|查询总页数|{@link int} * @param currentPage * 出参|当前页数|{@link int} * @param pageSize * 出参|每页条数|{@link int} * @param results * 出参|查询结果|{@link com.ylink.ide.trade.runtime.context.JavaList} * @return -1 异常<br/> * 2 无数据<br/> * 1 成功<br/> */ @Component(label = "数据分页查询", style = "判断型", type = "同步组件", comment = "支持Oracle/DB2/mysql三种数据库", version = "1.0.0", deprecated = false, author = "admin", date = "2019-03-28 03:01:23") @InParams(param = { @Param(name = "poolName", comment = "数据源,为空使用默认", type = java.lang.String.class), @Param(name = "tableName", comment = "表名称", type = java.lang.String.class), @Param(name = "selectValue", comment = "查询列(可以空,全部字段)", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "conditions", comment = "查询的条件(可以传空) 传入值例子: {'name':{'in':['zhengSan','liSi','wangWu']},'age':{'between':['20','60']},'gender':{'=':['男']} }", type = com.ylink.ide.trade.runtime.context.JavaContainer.class), @Param(name = "orderByValue", comment = "排序查询列名(可以传空) 例如:' 'name desc,age asc'' ", type = java.lang.String.class), @Param(name = "pageNum", comment = "查询页码(默认1)", type = int.class), @Param(name = "pageSize", comment = "每页查询条数(默认8)", type = int.class) }) @OutParams(param = { @Param(name = "cnt", comment = "总行数", type = long.class), @Param(name = "pages", comment = "查询总页数", type = int.class), @Param(name = "currentPage", comment = "当前页数", type = int.class), @Param(name = "pageSize", comment = "每页条数", type = int.class), @Param(name = "results", comment = "查询结果", type = com.ylink.ide.trade.runtime.context.JavaList.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "2", desp = "无数据"), @Return(id = "1", desp = "成功") }) public static ResultBase P_queryPage(String poolName, String tableName, JavaList selectValue, JavaContainer conditions, String orderByValue, int pageNum, int pageSize) { try { JavaList list = JdbcUtil.pageQuery(poolName, tableName, selectValue, conditions, pageNum, pageSize, orderByValue); long cnt = JdbcUtil.count(poolName, tableName, conditions); int size = list.size(); if (list == null || size < 1) { return new ResultBase(2); } return ResultBase.newSuccessResult(cnt, (cnt / pageSize) + 1, pageNum, pageSize, list); } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTJ0011", "分页查询 异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/c5/fc/c5fc1b9c072ddaa6fd8b15cacd7dde0e_1506x1257.png) 数据源的来源为项目的配置文件中的数据源,以及前端页面上的数据源管理列表中添加的数据源 ## 参数说明及示例 表名称:数据库表名,示例: `"sys-user"` 查询列(可以空,全部字段):需要查询的字段集合,为空时查询表全字段,示例: `["id","name"]` 查询的条件(可以传空):where条件设置,需要map传值,示例: `{"name":{"in":["zhengSan","liSi","wangWu"]},"age":{"between":[20,60]},"gender":{"=":["男"]} }` 排序查询列名(可以传空):排序字段集合,示例: `"name desc,age asc" ` 查询页码(默认1):查询多少页,示例: `1` 每页查询条数(默认8):每页展示数据条数,示例: `10` 总行数:查询结果总行数,示例: `__INNER__["cnt"]` 查询总页数:查询结果总页数,示例: `__INNER__["pages"]` 当前页数:查询结果当前是第几页,示例: `__INNER__["currentPage"]` 每页条数:查询结果每页展示数据量,示例: `__INNER__["pageSize"]` 查询结果:查询结果集合,示例: `__INNER__["results"]` > 注意:填写值如果是String字符串,则需要在前后加上英文双引号"",如果是数字或者boolean值,则不需要