style: 优化了不同数据库同步数据的代码,和数据接入的功能优化

将后台同步数据功能完善了一下,使其不再使用sql,而使用jdbc封装的方法进行查询所需数据,数据接入在添加或修改时,会根据所选择的数据库类型进行后台默认添加对应的连接驱动jdbcDriver
master
yaoxin 2024-04-24 15:14:34 +08:00
parent 0689fdb194
commit 7f0e928cd5
8 changed files with 165 additions and 216 deletions

View File

@ -66,6 +66,11 @@ public class DataSourceController extends BaseController
return dataSourceService.dataAssetList(dataSource);
}
@GetMapping("/Statistics")
public Result statistics(){
return dataSourceService.statistics();
}
@PostMapping("/AssetModelList")
public Result assetModelList(@RequestBody DataAsset dataAsset)
{

View File

@ -93,11 +93,22 @@ public class DataSource extends BaseEntity
/** 数据来源名称 */
@Excel(name = "数据来源名称")
private String systemName;
/** 连接驱动名称 */
@Excel(name = "连接驱动名称")
private String jdbcDriver;
/** 模式名称 */
@Excel(name = "数据来源名称")
private String modeName;
public String getJdbcDriver() {
return jdbcDriver;
}
public void setJdbcDriver(String jdbcDriver) {
this.jdbcDriver = jdbcDriver;
}
public String getModeName() {
return modeName;
}

View File

@ -0,0 +1,20 @@
package com.muyu.etl.domain.custom;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @ClassName Statistics
* @Description
* @Author Xin.Yao
* @Date 2024/4/23 20:43
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Statistics {
private Long dataAsset;
private Long assetModel;
private Long dataModel;
}

View File

@ -62,4 +62,6 @@ public interface DataAssetMapper
public int deleteDataAssetByIds(Long[] ids);
void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets);
List<DataAsset> selectDataAssetBatchId(@Param("longs") List<Long> longs);
}

View File

@ -73,4 +73,6 @@ public interface IDataSourceService
Result dataAssetList(DataSource dataSource);
Result assetModelList(DataAsset dataAsset);
Result statistics();
}

View File

@ -11,10 +11,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.*;
import com.muyu.etl.domain.custom.AssetsModule;
import com.muyu.etl.domain.custom.TableAssets;
import com.muyu.etl.domain.custom.TableDetail;
import com.muyu.etl.domain.custom.VTClass;
import com.muyu.etl.domain.custom.*;
import com.muyu.etl.mapper.AssetModelMapper;
import com.muyu.etl.mapper.DataAssetMapper;
import org.springframework.beans.factory.annotation.Autowired;
@ -116,6 +113,11 @@ public class DataSourceServiceImpl implements IDataSourceService
{
dataSource.setCreateTime(DateUtils.getNowDate());
dataSource.setCreateBy(SecurityUtils.getUsername());
if ("MySql".equals(dataSource.getType())){
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver");
}else{
dataSource.setJdbcDriver("org.postgresql.Driver");
}
return dataSourceMapper.insertDataSource(dataSource);
}
@ -130,6 +132,11 @@ public class DataSourceServiceImpl implements IDataSourceService
{
dataSource.setUpdateTime(DateUtils.getNowDate());
dataSource.setUpdateBy(SecurityUtils.getUsername());
if ("MySql".equals(dataSource.getType())){
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver");
}else{
dataSource.setJdbcDriver("org.postgresql.Driver");
}
return dataSourceMapper.updateDataSource(dataSource);
}
@ -159,62 +166,37 @@ public class DataSourceServiceImpl implements IDataSourceService
@Override
public Result testConnection(DataSource dataSource) {
if (dataSource.getType().equals("MySql")){
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
String jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
jdbcUrl = jdbcUrl+"?"+dataSource.getConnectionParam();
}
Connection conn = null;
try {
Class.forName(jdbcDriver);
} catch (ClassNotFoundException e) {
return Result.error("连接失败");
}
try {
conn = DriverManager.getConnection(jdbcUrl, user, password);
conn.close();
}catch (Exception e){
return Result.error("连接失败");
}
}else{
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver = "org.postgresql.Driver";
String jdbcUrl = "jdbc:postgresql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
jdbcUrl = jdbcUrl+"?"+dataSource.getConnectionParam();
}
Connection conn = null;
try {
Class.forName(jdbcDriver);
} catch (ClassNotFoundException e) {
return Result.error("连接失败");
}
try {
conn = DriverManager.getConnection(jdbcUrl, user, password);
conn.close();
}catch (Exception e){
return Result.error("连接失败");
}
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
jdbcUrl = jdbcUrl+"?"+dataSource.getConnectionParam();
}
Connection conn = null;
try {
Class.forName(dataSource.getJdbcDriver());
} catch (ClassNotFoundException e) {
return Result.error("连接失败");
}
try {
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
conn.close();
}catch (Exception e){
return Result.error("连接失败");
}
return Result.success("连接成功");
}
public AssetsModule getStructure(DataSource dataSource){
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
String jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getConnectionParam()!=null && dataSource.getConnectionParam()!=""){
jdbcUrl = jdbcUrl+"?"+dataSource.getConnectionParam();
}
Connection conn = null;
List<Map<String, VTClass>> kvtList = new ArrayList<>();
HashMap<String, String> map = new HashMap<>();
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
Class.forName(dataSource.getJdbcDriver());
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
@ -224,10 +206,6 @@ public class DataSourceServiceImpl implements IDataSourceService
ResultSetMetaData rsd = resultSet.getMetaData();
for(int i = 1; i <= rsd.getColumnCount(); i++) {
String substring = rsd.getColumnClassName(i).substring(rsd.getColumnClassName(i).indexOf("java.lang.") + 10);
System.out.print("java类型"+substring);
System.out.print(" 数据库类型:"+rsd.getColumnTypeName(i));
System.out.print(" 字段名称:"+rsd.getColumnName(i));
System.out.println();
map.put(rsd.getColumnName(i),substring);
}
int columnCount = rsd.getColumnCount();
@ -258,25 +236,19 @@ public class DataSourceServiceImpl implements IDataSourceService
}
public Map<String,String> getTypeMap(DataSource dataSource, String tableName){
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver="";
String jdbcUrl="";
String sql="";
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getType().equals("MySql")){
jdbcDriver = "com.mysql.cj.jdbc.Driver";
jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql = "select * from "+tableName;
}else{
jdbcDriver = "org.postgresql.Driver";
jdbcUrl = "jdbc:postgresql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql = "select * from "+dataSource.getModeName()+"."+tableName;
}
Connection conn = null;
Map<String, String> map = new HashMap<>();
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
Class.forName(dataSource.getJdbcDriver());
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
@ -294,7 +266,7 @@ public class DataSourceServiceImpl implements IDataSourceService
substring = rsd.getColumnClassName(i);
}
map.put(rsd.getColumnName(i).toUpperCase(),substring);
map.put(rsd.getColumnName(i),substring);
}
pst.close();
pst=null;
@ -305,153 +277,64 @@ public class DataSourceServiceImpl implements IDataSourceService
}
public List<AssetModel> getTableAssets(DataSource dataSource, String tableName){
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver="";
String jdbcUrl="";
String sql="";
if (dataSource.getType().equals("MySql")){
jdbcDriver = "com.mysql.cj.jdbc.Driver";
jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql="SELECT COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_KEY,COLUMN_DEFAULT,COLUMN_COMMENT,CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '"+dataSource.getDatabaseName()+"' AND TABLE_NAME = '"+tableName+"'";
}else{
jdbcDriver = "org.postgresql.Driver";
jdbcUrl = "jdbc:postgresql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql="SELECT \n" +
" a.attname AS \"COLUMN_NAME\",\n" +
" coalesce(cc.description, '') AS \"COLUMN_COMMENT\",\n" +
" EXISTS (\n" +
" SELECT 1\n" +
" FROM pg_index i\n" +
" JOIN pg_attribute ia ON ia.attrelid = i.indrelid AND ia.attnum = ANY(i.indkey)\n" +
" WHERE i.indrelid = a.attrelid AND ia.attname = a.attname AND i.indisprimary\n" +
" ) AS \"COLUMN_KEY\",\n" +
" format_type(a.atttypid, a.atttypmod) AS \"DATA_TYPE\",\n" +
" CASE \n" +
" WHEN strpos(format_type(a.atttypid, a.atttypmod), '(') > 0 THEN \n" +
" split_part(substring(format_type(a.atttypid, a.atttypmod) FROM '\\((.*)\\)')::text, ',', 1)::int\n" +
" ELSE \n" +
" NULL\n" +
" END AS \"NUMERIC_PRECISION\",\n" +
" CASE \n" +
" WHEN strpos(format_type(a.atttypid, a.atttypmod), ',') > 0 THEN \n" +
" split_part(substring(format_type(a.atttypid, a.atttypmod) FROM '\\((.*)\\)')::text, ',', 2)::int\n" +
" ELSE \n" +
" NULL\n" +
" END AS \"NUMERIC_SCALE\",\n" +
" COALESCE(pg_get_expr(ad.adbin, ad.adrelid), '') AS \"COLUMN_DEFAULT\",\n" +
" NOT a.attnotnull AS \"IS_NULLABLE\"\n" +
"FROM \n" +
" pg_catalog.pg_attribute a\n" +
"JOIN \n" +
" pg_catalog.pg_class c ON a.attrelid = c.oid\n" +
"JOIN \n" +
" pg_catalog.pg_namespace n ON c.relnamespace = n.oid\n" +
"LEFT JOIN \n" +
" pg_catalog.pg_description cc ON cc.objoid = a.attrelid AND cc.objsubid = a.attnum\n" +
"LEFT JOIN \n" +
" pg_catalog.pg_attrdef ad ON ad.adrelid = a.attrelid AND ad.adnum = a.attnum\n" +
"WHERE \n" +
" n.nspname = '"+dataSource.getModeName()+"' \n" +
" AND c.relname = '"+tableName+"' \n" +
" AND a.attnum > 0 \n" +
" AND NOT a.attisdropped \n" +
"ORDER BY \n" +
" a.attnum ";
}
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
Connection conn = null;
List<AssetModel> assetModels = new ArrayList<>();
Map<String, String> typeMap = getTypeMap(dataSource, tableName);
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
Class.forName(dataSource.getJdbcDriver());
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
try {
PreparedStatement pst = conn.prepareStatement(sql);
ResultSet resultSet = pst.executeQuery();
ResultSetMetaData rsd = resultSet.getMetaData();
while (resultSet.next()) {
DatabaseMetaData metaData = conn.getMetaData();
ResultSet columnsRS = metaData.getColumns(dataSource.getDatabaseName(),dataSource.getModeName(), tableName, "%");
ResultSet primaryKeyRS = metaData.getPrimaryKeys(dataSource.getDatabaseName(), dataSource.getModeName(), tableName);
String primaryKeyColumnName ="";
while (primaryKeyRS.next()) {
primaryKeyColumnName = primaryKeyRS.getString("COLUMN_NAME");
}
while (columnsRS.next()) {
AssetModel assetModel = new AssetModel();
assetModel.setComment(resultSet.getString("COLUMN_COMMENT"));
assetModel.setName(resultSet.getString("COLUMN_NAME"));
assetModel.setType(resultSet.getString("DATA_TYPE"));
if (dataSource.getType().equals("MySql")){
if (resultSet.getString("CHARACTER_MAXIMUM_LENGTH")!=null){
assetModel.setLength(resultSet.getString("CHARACTER_MAXIMUM_LENGTH"));
}else if (resultSet.getString("NUMERIC_PRECISION")!=null){
assetModel.setLength(resultSet.getString("NUMERIC_PRECISION"));
}else{
assetModel.setLength("-");
}
//是否主键
if ("PRI".equals(resultSet.getString("COLUMN_KEY"))){
assetModel.setIsPrimaryKey("Y");
}else{
assetModel.setIsPrimaryKey("N");
}
//是否不可为空
if (resultSet.getString("IS_NULLABLE").equals("NO")){
assetModel.setIsNull("N");
}else{
assetModel.setIsNull("Y");
}
}else{
if (resultSet.getString("NUMERIC_PRECISION")!=null){
assetModel.setLength(resultSet.getString("NUMERIC_PRECISION"));
}else{
if (!assetModel.getType().contains("time")&&!assetModel.getType().contains("date")){
assetModel.setLength("10");
}else{
assetModel.setLength("-");
}
}
//是否主键
if ("t".equals(resultSet.getString("COLUMN_KEY"))){
assetModel.setIsPrimaryKey("Y");
}else{
assetModel.setIsPrimaryKey("N");
}
//是否不可为空
if (resultSet.getString("IS_NULLABLE").equals("t")){
assetModel.setIsNull("N");
}else{
assetModel.setIsNull("Y");
}
}
if (resultSet.getString("NUMERIC_SCALE")!=null){
assetModel.setDecimalPlaces(resultSet.getString("NUMERIC_SCALE"));
}else{
assetModel.setDecimalPlaces("-");
}
//是否有默认值
if (resultSet.getString("COLUMN_DEFAULT")!=null){
assetModel.setDefaultValue(resultSet.getString("COLUMN_DEFAULT"));
}else{
assetModel.setDefaultValue("-");
}
assetModel.setIsDict("");
assetModel.setDictKey("");
assetModel.setCreateBy(SecurityUtils.getUsername());
String columnName = columnsRS.getString("COLUMN_NAME");
String typeName = columnsRS.getString("TYPE_NAME");
int columnSize = columnsRS.getInt("COLUMN_SIZE");
int decimalDigits = columnsRS.getInt("DECIMAL_DIGITS");
String isNullable = columnsRS.getString("IS_NULLABLE");
String columnDef = columnsRS.getString("COLUMN_DEF");
String remarks = columnsRS.getString("REMARKS");
assetModel.setCreateTime(new Date());
assetModel.setMappingType(typeMap.get(assetModel.getName().toUpperCase()));
assetModel.setCreateBy(SecurityUtils.getUsername());
assetModel.setLength(String.valueOf(columnSize));
assetModel.setDecimalPlaces(String.valueOf(decimalDigits));
assetModel.setName(columnName);
assetModel.setType(typeName);
assetModel.setMappingType(typeMap.get(columnName));
assetModel.setDictKey("");
assetModel.setIsDict("");
assetModel.setIsNull(isNullable.substring(0,1));
if (columnName.equals(primaryKeyColumnName)){
assetModel.setIsPrimaryKey("Y");
}else{
assetModel.setIsPrimaryKey("N");
}
if (remarks==null || remarks==""){
assetModel.setComment("-");
}else{
assetModel.setComment(remarks);
}
if (columnDef==null || columnDef==""){
assetModel.setDefaultValue("-");
}else{
assetModel.setDefaultValue(columnDef);
}
assetModels.add(assetModel);
}
pst.close();
columnsRS.close();
primaryKeyRS.close();
conn.close();
} catch(SQLException e) {
e.printStackTrace();
}
@ -459,16 +342,13 @@ public class DataSourceServiceImpl implements IDataSourceService
}
public AssetsModule getAssets(DataSource dataSource){
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
String jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
Connection conn = null;
HashMap<String, String> map = new HashMap<>();
List<AssetModel> assetModels = getTableAssets(dataSource,dataSource.getTableName());
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
Class.forName(dataSource.getJdbcDriver());
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
@ -507,18 +387,12 @@ public class DataSourceServiceImpl implements IDataSourceService
@Override
public Result synchronousData(DataSource dataSource) {
String user = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver ="";
String jdbcUrl = "";
String sql="";
jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
if (dataSource.getType().equals("MySql")){
jdbcDriver = "com.mysql.cj.jdbc.Driver";
jdbcUrl = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql="SELECT TABLE_NAME t_name,TABLE_COMMENT table_comment,TABLE_ROWS table_rows,(SELECT count(*) FROM INFORMATION_SCHEMA.columns WHERE TABLE_SCHEMA = '"+dataSource.getDatabaseName()+"' and TABLE_NAME=t_name) fields FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='"+dataSource.getDatabaseName()+"'";
}else{
jdbcDriver = "org.postgresql.Driver";
jdbcUrl = "jdbc:postgresql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
sql="SELECT \n" +
" c.relname AS t_name,\n" +
" pgd.description AS table_comment,\n" +
@ -543,14 +417,18 @@ public class DataSourceServiceImpl implements IDataSourceService
HashMap<String, String> map = new HashMap<>();
ArrayList<DataAsset> dataAssets = new ArrayList<>();
try {
Class.forName(jdbcDriver);
conn = DriverManager.getConnection(jdbcUrl, user, password);
Class.forName(dataSource.getJdbcDriver());
conn = DriverManager.getConnection(jdbcUrl, dataSource.getUsername(), dataSource.getPassword());
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()){
DataAsset dataAsset = new DataAsset();
dataAsset.setTableName(resultSet.getString("t_name"));
dataAsset.setTableComment(resultSet.getString("table_comment"));
if (resultSet.getString("table_comment")==null || "".equals(resultSet.getString("table_comment"))){
dataAsset.setTableComment("-");
}else{
dataAsset.setTableComment(resultSet.getString("table_comment"));
}
dataAsset.setTableCount(Long.valueOf(resultSet.getString("table_rows")));
dataAsset.setFields(Long.valueOf(resultSet.getString("fields")));
dataAsset.setDataSourceId(dataSource.getId());
@ -585,4 +463,22 @@ public class DataSourceServiceImpl implements IDataSourceService
List<AssetModel> assetModels = assetModelMapper.selectAssetModelList(assetModel);
return Result.success(assetModels);
}
@Override
public Result statistics() {
//查询所有数据源
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(new DataSource());
//获取所有数据源的主键
List<Long> longs = dataSources.stream().map(dataSource -> dataSource.getId()).toList();
List<DataAsset> dataAssetList=dataAssetMapper.selectDataAssetBatchId(longs);
Statistics statistics = new Statistics();
statistics.setDataAsset(Long.valueOf(dataSources.size()));
long sum1;
long sum2=0;
sum1 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum();
sum2 = dataAssetList.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum();
statistics.setAssetModel(sum1);
statistics.setDataModel(sum2);
return Result.success(statistics);
}
}

View File

@ -37,7 +37,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDataAssetVo"/>
where id = #{id}
</select>
<select id="selectDataAssetBatchId" resultType="com.muyu.etl.domain.DataAsset">
select * from data_asset where data_source_id
in (
<foreach collection="longs" item="id" separator=",">
#{id}
</foreach>
)
</select>
<insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
insert into data_asset
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -25,10 +25,11 @@
<result property="type" column="type" />
<result property="systemName" column="system_name" />
<result property="modeName" column="mode_name" />
<result property="jdbcDriver" column="jdbc_driver" />
</resultMap>
<sql id="selectDataSourceVo">
select id, data_source_name, link_address, port, database_name, username, password, connection_param, init_num, max_num, max_wait_time, max_wait_size, create_by, create_time, update_by, update_time, remark, type, system_name,mode_name from data_source
select id, data_source_name, link_address, port, database_name, username, password, connection_param, init_num, max_num, max_wait_time, max_wait_size, create_by, create_time, update_by, update_time, remark, type, system_name,mode_name,jdbc_driver from data_source
</sql>
<select id="selectDataSourceList" parameterType="com.muyu.etl.domain.DataSource" resultMap="DataSourceResult">
@ -48,6 +49,7 @@
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="systemName != null and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
<if test="modeName != null and modeName != ''"> and mode_name like concat('%', #{modeName}, '%')</if>
<if test="jdbcDriver != null and jdbcDriver != ''"> and jdbc_driver like concat('%', #{jdbcDriver}, '%')</if>
</where>
</select>
@ -78,6 +80,7 @@
<if test="type != null">type,</if>
<if test="systemName != null">system_name,</if>
<if test="modeName != null">mode_name,</if>
<if test="jdbcDriver != null">jdbc_driver,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">#{dataSourceName},</if>
@ -99,6 +102,7 @@
<if test="type != null">#{type},</if>
<if test="systemName != null">#{systemName},</if>
<if test="modeName != null">#{modeName},</if>
<if test="jdbcDriver != null">#{jdbcDriver},</if>
</trim>
</insert>
@ -124,6 +128,7 @@
<if test="type != null">type = #{type},</if>
<if test="systemName != null">system_name = #{systemName},</if>
<if test="modeName != null">mode_name = #{modeName},</if>
<if test="jdbcDriver != null">jdbc_driver = #{jdbcDriver},</if>
</trim>
where id = #{id}
</update>