| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.anyline.metadata.Column; |
| | | import org.anyline.metadata.Table; |
| | | import org.anyline.proxy.CacheProxy; |
| | | import org.anyline.proxy.ServiceProxy; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | |
| | | // 获取查询条件 |
| | | String tableName = genTable.getTableName(); |
| | | String tableComment = genTable.getTableComment(); |
| | | // 获取分页参数 |
| | | Integer pageNum = pageQuery.getPageNum(); |
| | | Integer pageSize = pageQuery.getPageSize(); |
| | | |
| | | LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables(); |
| | | if (CollUtil.isEmpty(tablesMap)) { |
| | | return TableDataInfo.build(); |
| | | } |
| | | List<String> tableNames = baseMapper.selectTableNameList(genTable.getDataName()); |
| | | String[] tableArrays; |
| | | if (CollUtil.isNotEmpty(tableNames)) { |
| | | tableArrays = tableNames.toArray(new String[0]); |
| | | } else { |
| | | tableArrays = new String[0]; |
| | | } |
| | | // 过滤并转换表格数据 |
| | | List<GenTable> tables = tablesMap.values().stream() |
| | | .filter(x -> !StringUtils.containsAnyIgnoreCase(x.getName(), TABLE_IGNORE)) |
| | | .filter(x -> { |
| | | if (CollUtil.isEmpty(tableNames)) { |
| | | return true; |
| | | } |
| | | return !StringUtils.containsAnyIgnoreCase(x.getName(), tableArrays); |
| | | }) |
| | | .filter(x -> { |
| | | boolean nameMatches = true; |
| | | boolean commentMatches = true; |
| | |
| | | return gen; |
| | | }).toList(); |
| | | |
| | | // 创建分页对象,并设置总记录数 |
| | | IPage<GenTable> page = new Page<>(pageNum, pageSize, tables.size()); |
| | | // 使用CollUtil进行分页,并设置分页记录 |
| | | page.setRecords(CollUtil.page(pageNum - 1, pageSize, tables)); |
| | | IPage<GenTable> page = pageQuery.build(); |
| | | page.setTotal(tables.size()); |
| | | // 手动分页 set数据 |
| | | page.setRecords(CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), tables)); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | |
| | | */ |
| | | @DS("#dataName") |
| | | private List<GenTableColumn> selectDbTableColumnsByName(String tableName, String dataName) { |
| | | Table<?> table = ServiceProxy.metadata().table(tableName); |
| | | if (Objects.isNull(table)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | LinkedHashMap<String, Column> columns = table.getColumns(); |
| | | // 清理anyline缓存 |
| | | CacheProxy.clear(); |
| | | LinkedHashMap<String, Column> columns = ServiceProxy.metadata().columns(tableName); |
| | | List<GenTableColumn> tableColumns = new ArrayList<>(); |
| | | columns.forEach((columnName, column) -> { |
| | | GenTableColumn tableColumn = new GenTableColumn(); |