@Override
    public PageResult<Table> pageQuery(TablePageQueryParam param, TableSelector selector) {
        LambdaQueryWrapper<TableCacheVersionDO> queryWrapper = new LambdaQueryWrapper<>();
        String key = getTableKey(param.getDataSourceId(), param.getDatabaseName(), param.getSchemaName());
        queryWrapper.eq(TableCacheVersionDO::getKey, key);
        TableCacheVersionDO versionDO = getVersionMapper().selectOne(queryWrapper);
        long total = 0;
        long version = 0L;
        if (param.isRefresh() || versionDO == null) {
            total = addCache(param, versionDO);
        } else {
            if ("2".equals(versionDO.getStatus())) {
                version = versionDO.getVersion() - 1;
            } else {
                version = versionDO.getVersion();
            }
            total = versionDO.getTableCount();
        }
        Page<TableCacheDO> page = new Page<>(param.getPageNo(), param.getPageSize());
        // page.setSearchCount(param.getEnableReturnCount());
        IPage<TableCacheDO> iPage = getTableCacheMapper().pageQuery(page, param.getDataSourceId(), param.getDatabaseName(), param.getSchemaName(), param.getSearchKey());
        List<Table> tables = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(iPage.getRecords())) {
            for (TableCacheDO tableCacheDO : iPage.getRecords()) {
                Table t = new Table();
                t.setName(tableCacheDO.getTableName());
                t.setComment(tableCacheDO.getExtendInfo());
                t.setSchemaName(tableCacheDO.getSchemaName());
                t.setDatabaseName(tableCacheDO.getDatabaseName());
                tables.add(t);
            }
        }
        if (param.getPageNo() <= 1) {
            tables = pinTable(tables, param);
        }
        return PageResult.of(tables, total, param);
    }
@author moji
@version DataSourceCoreServiceImpl.java, v 0.1 September 23, 2022 15:51 moji Exp $
@date 2022/09/23
chat2db-server/chat2db-server-domain/chat2db-server-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/TableServiceImpl.java