* Abstract common count method * Abstract common count method * Abstract common count method * Abstract common count method * Abstract common count method * Abstract common count method
This commit is contained in:
parent
ff2497d999
commit
40519a22d5
@ -1092,7 +1092,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
PaginationHelper<ConfigInfoBase> helper = createPaginationHelper();
|
||||
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO);
|
||||
final int startRow = (pageNo - 1) * pageSize;
|
||||
return helper.fetchPage(configInfoMapper.findConfigInfoBaseByDataIdCountRows(),
|
||||
return helper.fetchPage(configInfoMapper.count(Arrays.asList("data_id", "tenant_id")),
|
||||
configInfoMapper.findConfigInfoBaseByDataIdFetchRows(startRow, pageSize),
|
||||
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
||||
|
||||
@ -2588,7 +2588,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
throw new IllegalArgumentException("tenantId can not be null");
|
||||
}
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
||||
String sql = tenantInfoMapper.getCountByTenantId();
|
||||
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||
Integer result = databaseOperate
|
||||
.queryOne(sql, new String[] {tenantId}, Integer.class);
|
||||
if (result == null) {
|
||||
|
@ -1028,7 +1028,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
try {
|
||||
final int startRow = (pageNo - 1) * pageSize;
|
||||
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO);
|
||||
return helper.fetchPage(configInfoMapper.findConfigInfoBaseByDataIdCountRows(),
|
||||
return helper.fetchPage(configInfoMapper.count(Arrays.asList("data_id", "tenant_id")),
|
||||
configInfoMapper.findConfigInfoBaseByDataIdFetchRows(startRow, pageSize),
|
||||
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
||||
} catch (CannotGetJdbcConnectionException e) {
|
||||
@ -2730,7 +2730,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
throw new IllegalArgumentException("tenantId can not be null");
|
||||
}
|
||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
||||
String sql = tenantInfoMapper.getCountByTenantId();
|
||||
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||
Integer result = this.jt
|
||||
.queryForObject(sql, new String[] {tenantId}, Integer.class);
|
||||
if (result == null) {
|
||||
|
@ -381,11 +381,6 @@ public class ConfigInfoMapperByDerby extends AbstractMapper implements ConfigInf
|
||||
return sql + where + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findConfigInfoBaseByDataIdCountRows() {
|
||||
return "SELECT count(*) FROM config_info WHERE data_id=? AND tenant_id=?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
|
||||
return "SELECT id,data_id,group_id,content FROM config_info WHERE data_id=? " + "AND tenant_id=?" + " OFFSET "
|
||||
|
@ -29,11 +29,6 @@ import com.alibaba.nacos.plugin.datasource.mapper.TenantInfoMapper;
|
||||
|
||||
public class TenantInfoMapperByDerby extends AbstractMapper implements TenantInfoMapper {
|
||||
|
||||
@Override
|
||||
public String getCountByTenantId() {
|
||||
return "SELECT count(1) FROM tenant_info WHERE tenant_id = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return TableConstant.TENANT_INFO;
|
||||
|
@ -386,11 +386,6 @@ public class ConfigInfoMapperByMySql extends AbstractMapper implements ConfigInf
|
||||
return sql + where + " LIMIT " + startRow + "," + pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findConfigInfoBaseByDataIdCountRows() {
|
||||
return "SELECT count(*) FROM config_info WHERE data_id=? AND tenant_id=?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
|
||||
return "SELECT id,data_id,group_id,content FROM config_info WHERE data_id=? AND tenant_id=?" + " LIMIT "
|
||||
|
@ -38,9 +38,4 @@ public class TenantInfoMapperByMySql extends AbstractMapper implements TenantInf
|
||||
public String getDataSource() {
|
||||
return DataSourceConstant.MYSQL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountByTenantId() {
|
||||
return "SELECT count(*) FROM tenant_info WHERE tenant_id = ?";
|
||||
}
|
||||
}
|
||||
|
@ -330,15 +330,6 @@ public interface ConfigInfoMapper extends Mapper {
|
||||
*/
|
||||
String findConfigInfo4PageFetchRows(Map<String, String> params, int startRow, int pageSize);
|
||||
|
||||
/**
|
||||
* The count of querying configuration information based on dataId.
|
||||
* The default sql:
|
||||
* SELECT count(*) FROM config_info WHERE data_id=? AND tenant_id=?
|
||||
*
|
||||
* @return The sql of query count.
|
||||
*/
|
||||
String findConfigInfoBaseByDataIdCountRows();
|
||||
|
||||
/**
|
||||
* Query configuration information based on dataId.
|
||||
* The default sql:
|
||||
|
@ -17,19 +17,11 @@
|
||||
package com.alibaba.nacos.plugin.datasource.mapper;
|
||||
|
||||
/**
|
||||
* The tenant info mapper.
|
||||
* The tenant info mapper. If there is a new non-universal sql, you can add it here.
|
||||
*
|
||||
* @author hyx
|
||||
**/
|
||||
|
||||
public interface TenantInfoMapper extends Mapper {
|
||||
|
||||
/**
|
||||
* Get the count of tenant information by id.
|
||||
* The defaut sql:
|
||||
* SELECT count(*) FROM tenant_info WHERE tenant_id = ?
|
||||
*
|
||||
* @return The sql of get the count of tenant information.
|
||||
*/
|
||||
String getCountByTenantId();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user