mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-06 01:36:46 +08:00
support view trigger producer function
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package ai.chat2db.server.domain.core.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ -72,6 +71,10 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
DataResult<DataSource> dataResult = queryById(dataSourceId);
|
||||
if (dataResult.success() && dataResult.getData() != null) {
|
||||
DataSource dataSource = dataResult.getData();
|
||||
DriverConfig driverConfig = dataSource.getDriverConfig();
|
||||
if (driverConfig == null || StringUtils.isBlank(driverConfig.getJdbcDriver())) {
|
||||
return;
|
||||
}
|
||||
try (Connection connection = IDriverManager.getConnection(dataSource.getUrl(), dataSource.getUserName(),
|
||||
dataSource.getPassword(), dataSource.getDriverConfig(), dataSource.getExtendMap())) {
|
||||
DatabaseQueryAllParam databaseQueryAllParam = new DatabaseQueryAllParam();
|
||||
@ -80,7 +83,7 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
databaseQueryAllParam.setDbType(dataSource.getType());
|
||||
databaseQueryAllParam.setRefresh(true);
|
||||
databaseService.queryAll(databaseQueryAllParam);
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
log.error("preWarmingData error", e);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package ai.chat2db.server.domain.core.impl;
|
||||
|
||||
import ai.chat2db.server.domain.api.service.ViewService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ListResult;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.model.Table;
|
||||
import ai.chat2db.spi.sql.Chat2DBContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -13,4 +15,17 @@ public class ViewServiceImpl implements ViewService {
|
||||
public ListResult<Table> views(String databaseName, String schemaName) {
|
||||
return ListResult.of(Chat2DBContext.getMetaData().views(Chat2DBContext.getConnection(),databaseName, schemaName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataResult<Table> detail(String databaseName, String schemaName, String tableName) {
|
||||
MetaData metaSchema = Chat2DBContext.getMetaData();
|
||||
String ddl = metaSchema.tableDDL(Chat2DBContext.getConnection(), databaseName, schemaName, tableName);
|
||||
Table table = new Table();
|
||||
table.setDdl(ddl);
|
||||
table.setName(tableName);
|
||||
table.setSchemaName(schemaName);
|
||||
table.setDatabaseName(databaseName);
|
||||
return DataResult.of(table);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user