新增查询条数方法
parent
fd57183af4
commit
f8f07247ae
|
@ -41,6 +41,19 @@ public class DataValueController {
|
||||||
return Result.success(dataValueList);
|
return Result.success(dataValueList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据基础表ID和SQL语句查询条数
|
||||||
|
*
|
||||||
|
* @param dataValueModel 基础表ID和sql语句
|
||||||
|
* @return DataValue{kltv}
|
||||||
|
*/
|
||||||
|
@PostMapping("/getTableValueTotal")
|
||||||
|
@Operation(summary = "根据基础表ID和SQL语句新增数据", description = "根据基础表ID和SQL语句新增数据")
|
||||||
|
public Result getTableValueTotal(@RequestBody DataValueModel dataValueModel) {
|
||||||
|
Integer i = dataValueService.getTableValueTotal(dataValueModel);
|
||||||
|
return Result.success(i);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据基础表ID和SQL语句查询数据
|
* 根据基础表ID和SQL语句查询数据
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,4 +21,6 @@ public interface DataValueService extends IService<DataValue> {
|
||||||
List<DataValue> findTableValueByTableName(Long basicId, String tableName) throws SQLException;
|
List<DataValue> findTableValueByTableName(Long basicId, String tableName) throws SQLException;
|
||||||
|
|
||||||
Integer addTableValue(DataValueModel dataValueModel);
|
Integer addTableValue(DataValueModel dataValueModel);
|
||||||
|
|
||||||
|
Integer getTableValueTotal(DataValueModel dataValueModel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,26 @@ public class DataValueServiceImpl extends ServiceImpl<DataValueMapper, DataValue
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getTableValueTotal(DataValueModel dataValueModel) {
|
||||||
|
MysqlQuery mysqlQuery = new MysqlQuery();
|
||||||
|
mysqlQuery.setDataSourceId(String.valueOf(dataValueModel.getBasicId()));
|
||||||
|
DataSource dataSource = dataSourceService.getById(dataValueModel.getBasicId());
|
||||||
|
MysqlPool mysqlPool = new MysqlPool(dataSource);
|
||||||
|
mysqlPool.init();
|
||||||
|
Connection conn = mysqlPool.getConn();
|
||||||
|
try (Statement statement = conn.createStatement();
|
||||||
|
ResultSet resultSet = statement.executeQuery(dataValueModel.getSql())) {
|
||||||
|
if (resultSet.next()) {
|
||||||
|
return resultSet.getInt(1);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static final int THREAD_POOL_SIZE = 10;
|
private static final int THREAD_POOL_SIZE = 10;
|
||||||
private final ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
|
private final ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue