企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 ``` /** * <b>方法描述:</b> 查询(分页) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2020-09-14 17:34:28 <br/> * * @param poolName * 入参|数据源名称|{@link java.lang.String} * @param className * 入参|执行操作类名|{@link java.lang.String} * @param size * 入参|每页条数(默认10)|long * @param current * 入参|页码(默认1)|long * @param entity * 入参|条件|{@link com.baomidou.mybatisplus.extension.activerecord.Model} * @param isSearchCount * 入参|进行count查询(默认true)|{@link boolean} * @param ascs * 入参|排序数组(正序)|{@link java.util.List} * @param descs * 入参|排序数组(倒序)|{@link java.util.List} * @param page * 出参|分页对象|{@link com.baomidou.mybatisplus.core.metadata.IPage} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "查询(分页)", style = "判断型", type = "同步组件", comment = "根据条件查询进行分页查询", version = "1.0.0", deprecated = false, author = "admin", date = "2020-09-14 05:34:28") @InParams(param = {@Param(name = "poolName", comment = "数据源名称", type = java.lang.String.class), @Param(name = "className", comment = "执行操作类名", type = java.lang.String.class), @Param(name = "size", comment = "每页条数(默认10)", type = Long.class), @Param(name = "current", comment = "页码(默认1)", type = Long.class), @Param(name = "entity", comment = "条件", type = com.baomidou.mybatisplus.extension.activerecord.Model.class), @Param(name = "isSearchCount", comment = "进行count查询(默认true)", type = Boolean.class), @Param(name = "ascs", comment = "排序数组(正序)", type = java.util.List.class), @Param(name = "descs", comment = "排序数组(倒序)", type = java.util.List.class)}) @OutParams( param = {@Param(name = "page", comment = "分页对象", type = com.baomidou.mybatisplus.core.metadata.IPage.class)}) @Returns( returns = {@Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) @Order(value = 2) public static ResultBase P_selectPage(String poolName, String className, Long size, Long current, Model entity, Boolean isSearchCount, List ascs, List descs) { try { AppLog.debug("根据 分页 查询数据 组件参数:poolName={},className={},map={}", poolName, className, entity); if (StringUtil.isEmpty(className)) { return ResultBase.newFailureResult("TPTD0001", "参数错误:执行类参数【className】不能为空"); } setDatasource(poolName); Object maper = BundleUtil.getService(className); if (maper == null) { return ResultBase.newFailureResult("TPTD0010", "错误:当前环境未找到[" + className + "]的可用数据库操作Mapper 实例"); } Method method = getMethod(maper.getClass(), className, MybatisPlusMapperMehtod.selectPage); if (method != null) { AppLog.debug("开始执行相应的Mapper 方法"); Page page = new Page(); if (size != null) page.setSize(size); if (current != null) page.setCurrent(current); if (isSearchCount != null) page.setSearchCount(isSearchCount); if (CollectionUtil.isNotEmpty(ascs)) page.setAscs(ascs); if (CollectionUtil.isNotEmpty(descs)) page.setDescs(descs); method.invoke(maper, page, Wrappers.update(entity)); AppLog.debug("page={}",JSONUtil.toJsonStr(page)); return ResultBase.newSuccessResult(page); } } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTD0003", "方法调用错误,类:" + className + "调用:" + MybatisPlusMapperMehtod.selectPage + " 方法错误" + AppLog.errorMsg(e)); } return ResultBase.newFailureResult("TPTD0004", "方法调用错误,类:" + className + "没有可执行方法:" + MybatisPlusMapperMehtod.selectPage); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/49/4f/494f5f30ac4978004486718c08a500ed_1867x894.png) # 参数说明及示例 ## 入口参数 数据源名称:使用的数据源名称,可以为空 执行操作类名:执行 SQL 语句的类,示例: `"data.test.test.mapper.TUserMapper"` 每页条数(默认10):每页显示的数量,为空时为默认值 页码(默认1):显示第几页的记录,为空时为默认值 条件:传入一个实体对象当做查询条件,为空时查询全部 进行count查询(默认true):是否进行统计有多少条数据 排序数组(正序):以传入的数据库字段值进行排序,示例: `["name"]` 排序数组(倒序):以传入的数据库字段值进行排序,示例: `["id"]` ## 出口参数 分页对象:根据输入参数进行分页查询,得到分页对象,示例: `__INNER__["list"]` > 当交易部署到微服务上时,数据源在微服务界面上配置。