* 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();
|
PaginationHelper<ConfigInfoBase> helper = createPaginationHelper();
|
||||||
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO);
|
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO);
|
||||||
final int startRow = (pageNo - 1) * pageSize;
|
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),
|
configInfoMapper.findConfigInfoBaseByDataIdFetchRows(startRow, pageSize),
|
||||||
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
||||||
|
|
||||||
@ -2587,8 +2587,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
|||||||
if (Objects.isNull(tenantId)) {
|
if (Objects.isNull(tenantId)) {
|
||||||
throw new IllegalArgumentException("tenantId can not be null");
|
throw new IllegalArgumentException("tenantId can not be null");
|
||||||
}
|
}
|
||||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
||||||
String sql = tenantInfoMapper.getCountByTenantId();
|
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||||
Integer result = databaseOperate
|
Integer result = databaseOperate
|
||||||
.queryOne(sql, new String[] {tenantId}, Integer.class);
|
.queryOne(sql, new String[] {tenantId}, Integer.class);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
@ -1028,7 +1028,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
|||||||
try {
|
try {
|
||||||
final int startRow = (pageNo - 1) * pageSize;
|
final int startRow = (pageNo - 1) * pageSize;
|
||||||
ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSource, TableConstant.CONFIG_INFO);
|
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),
|
configInfoMapper.findConfigInfoBaseByDataIdFetchRows(startRow, pageSize),
|
||||||
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
new Object[] {dataId, StringUtils.EMPTY}, pageNo, pageSize, CONFIG_INFO_BASE_ROW_MAPPER);
|
||||||
} catch (CannotGetJdbcConnectionException e) {
|
} catch (CannotGetJdbcConnectionException e) {
|
||||||
@ -2730,7 +2730,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
|||||||
throw new IllegalArgumentException("tenantId can not be null");
|
throw new IllegalArgumentException("tenantId can not be null");
|
||||||
}
|
}
|
||||||
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
TenantInfoMapper tenantInfoMapper = mapperManager.findMapper(dataSource, TableConstant.TENANT_INFO);
|
||||||
String sql = tenantInfoMapper.getCountByTenantId();
|
String sql = tenantInfoMapper.count(Arrays.asList("tenant_id"));
|
||||||
Integer result = this.jt
|
Integer result = this.jt
|
||||||
.queryForObject(sql, new String[] {tenantId}, Integer.class);
|
.queryForObject(sql, new String[] {tenantId}, Integer.class);
|
||||||
if (result == null) {
|
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";
|
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
|
@Override
|
||||||
public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
|
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 "
|
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 {
|
public class TenantInfoMapperByDerby extends AbstractMapper implements TenantInfoMapper {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCountByTenantId() {
|
|
||||||
return "SELECT count(1) FROM tenant_info WHERE tenant_id = ?";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTableName() {
|
public String getTableName() {
|
||||||
return TableConstant.TENANT_INFO;
|
return TableConstant.TENANT_INFO;
|
||||||
|
@ -385,12 +385,7 @@ public class ConfigInfoMapperByMySql extends AbstractMapper implements ConfigInf
|
|||||||
}
|
}
|
||||||
return sql + where + " LIMIT " + startRow + "," + pageSize;
|
return sql + where + " LIMIT " + startRow + "," + pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String findConfigInfoBaseByDataIdCountRows() {
|
|
||||||
return "SELECT count(*) FROM config_info WHERE data_id=? AND tenant_id=?";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String findConfigInfoBaseByDataIdFetchRows(int startRow, int pageSize) {
|
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 "
|
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() {
|
public String getDataSource() {
|
||||||
return DataSourceConstant.MYSQL;
|
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);
|
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.
|
* Query configuration information based on dataId.
|
||||||
* The default sql:
|
* The default sql:
|
||||||
|
@ -17,19 +17,11 @@
|
|||||||
package com.alibaba.nacos.plugin.datasource.mapper;
|
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
|
* @author hyx
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public interface TenantInfoMapper extends Mapper {
|
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