fix:修改了数据接入同步功能

master
Jiang Peng 2024-04-26 09:29:24 +08:00
parent 4185897de1
commit 639cb8159e
2 changed files with 8 additions and 45 deletions

View File

@ -53,33 +53,6 @@ public class DataSourceServiceImpl implements DataSourceService{
@Override
public List<DataSource> selectDataSourceList(DataSource dataSource) {
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(dataSource);
// dataSources.stream()
// .map(source -> {
// String user = source.getUsername();
// String password = source.getPassword();
// String jdbcDriver = "com.mysql.cj.jdbc.Driver";
// String jdbcUrl = "jdbc:mysql://"+source.getLinkAddress()+":"+source.getPort()+"/"+source.getDatabaseName();
// Connection conn = null;
// Result result = this.test(source);
// if (result.getCode()==200){
// try {
// Class.forName(jdbcDriver);
// conn = DriverManager.getConnection(jdbcUrl, user, password);
// List<TableDetail> tableNames = new ArrayList<>();
// String sql="SELECT table_name FROM information_schema.tables WHERE table_schema = '"+source.getDatabaseName()+"'";
// PreparedStatement ps = conn.prepareStatement(sql);
// ResultSet resultSet = ps.executeQuery();
// while (resultSet.next()){
// tableNames.add(resultSet.getString("table_name"));
// }
// source.setTableList(tableNames);
// ps.close();
// } catch (ClassNotFoundException | SQLException e) {
// throw new RuntimeException(e);
// }
// }
// return null;
// }).toList();
return dataSources;
}
@ -227,6 +200,8 @@ public class DataSourceServiceImpl implements DataSourceService{
case "blob":
case "longblob":
return "byte[]";
case "longtext":
return "Clob";
// ... 其他类型映射包括日期、时间、字符串、二进制、Blob、枚举、集合等
default:
throw new IllegalArgumentException("Unsupported data type: " + mappingType);
@ -262,7 +237,6 @@ public class DataSourceServiceImpl implements DataSourceService{
ResultSet resultSet = preparedStatement.executeQuery();
// 遍历查询结果,创建并填充资产模型列表
while (resultSet.next()){
AssetModel assetModel = new AssetModel();
assetModel.setComment(resultSet.getString("COLUMN_COMMENT"));

View File

@ -130,25 +130,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- <if test="item.createTime != null">#{item.createTime},</if>-->
<!-- </trim>-->
<!-- </foreach>-->
<!-- </insert>-->
<!-- </insert>-->
<insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id">
insert into `asset_model_copy1` (
`data_asset_id`,
`name`,
comment,
is_primary_key,
`type`,
mapping_type,
`length`,
decimal_places,
is_null,
is_dict,
default_value,
dict_key,
create_by,
create_time
) values
INSERT INTO `asset_model_copy1` (
`data_asset_id`, `name`, `comment`, `is_primary_key`, `type`, `mapping_type`,
`length`, `decimal_places`, `is_null`, `is_dict`, `default_value`, `dict_key`,
`create_by`, `create_time`
) VALUES
<foreach collection="tableAssets" item="item" separator=",">
(
#{item.dataAssetId},