数据源,添加,修改,删除,测试连接

dev
chao 2024-04-21 17:01:17 +08:00
parent 03eecd791d
commit 1378c3f5e8
16 changed files with 1248 additions and 1 deletions

View File

@ -136,6 +136,11 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,113 @@
package com.etl.data.source.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.etl.common.core.annotation.Excel;
import com.etl.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* data_source
*
* @author Chao
* @date 2024-04-21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName("data_source")
public class DataSource extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
*
*/
@Excel(name = "数据源名称")
private String dataSourceName;
/**
*
*/
@Excel(name = "数据源系统名称")
private String dataSourceSystemName;
/**
*
*/
@Excel(name = "数据源类型")
private Long typeId;
/**
* ip
*/
@Excel(name = "数据源ip地址")
private String dataSourceIp;
/**
*
*/
@Excel(name = "端口号")
private String dataSourcePort;
/**
*
*/
@Excel(name = "连接数据库名称")
private String dataSourceDatabaseName;
/**
*
*/
private String dataSourceUsername;
/**
*
*/
private String dataSourcePassword;
/**
*
*/
private String additionalConfiguration;
/**
*
*/
@Excel(name = "状态")
private String status;
/**
*
*/
private Long initialNumberOfConnections;
/**
*
*/
private Long maximumNumberOfConnections;
/**
*
*/
private Long maximumWaitingTime;
/**
*
*/
private Long maximumWaitingTimes;
}

View File

@ -0,0 +1,124 @@
package com.etl.data.source.domain.resp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.etl.common.core.annotation.Excel;
import com.etl.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* data_source
*
* @author Chao
* @date 2024-04-21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName("data_source")
public class DataSourceResp extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
*
*/
@Excel(name = "数据源名称")
private String dataSourceName;
/**
*
*/
@Excel(name = "数据源系统名称")
private String dataSourceSystemName;
/**
*
*/
@Excel(name = "数据源类型")
private Long typeId;
@Excel(name = "数据源类型")
private String dataType;
/**
* ip
*/
@Excel(name = "数据源ip地址")
private String dataSourceIp;
/**
*
*/
@Excel(name = "端口号")
private String dataSourcePort;
/**
*
*/
@Excel(name = "连接数据库名称")
private String dataSourceDatabaseName;
/**
*
*/
@Excel(name = "用户名")
private String dataSourceUsername;
/**
*
*/
@Excel(name = "密码")
private String dataSourcePassword;
/**
*
*/
@Excel(name = "额外配置")
private String additionalConfiguration;
/**
*
*/
@Excel(name = "状态")
private String status;
/**
*
*/
@Excel(name = "初始化连接数量")
private Long initialNumberOfConnections;
/**
*
*/
@Excel(name = "最大连接数量")
private Long maximumNumberOfConnections;
/**
*
*/
@Excel(name = "最大等待时间")
private Long maximumWaitingTime;
/**
*
*/
@Excel(name = "最大等待次数")
private Long maximumWaitingTimes;
}

View File

@ -0,0 +1,41 @@
package com.etl.data.type.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.etl.common.core.annotation.Excel;
import com.etl.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* data_type
*
* @author Chao
* @date 2024-04-21
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName("data_type")
public class DataType extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
*
*/
@Excel(name = "数据源类型")
private String dataType;
}

View File

@ -1,4 +1,4 @@
package com.etl.source; package com.etl;
import com.etl.common.security.annotation.EnableCustomConfig; import com.etl.common.security.annotation.EnableCustomConfig;
import com.etl.common.security.annotation.EnableMyFeignClients; import com.etl.common.security.annotation.EnableMyFeignClients;

View File

@ -0,0 +1,104 @@
package com.etl.data.source.controller;
import com.etl.common.core.domain.Result;
import com.etl.common.core.utils.poi.ExcelUtil;
import com.etl.common.core.web.controller.BaseController;
import com.etl.common.core.web.page.TableDataInfo;
import com.etl.common.log.annotation.Log;
import com.etl.common.log.enums.BusinessType;
import com.etl.common.security.annotation.RequiresPermissions;
import com.etl.data.source.domain.DataSource;
import com.etl.data.source.domain.resp.DataSourceResp;
import com.etl.data.source.service.IDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author Chao
* @date 2024-04-21
*/
@RestController
@RequestMapping("/source")
public class DataSourceController extends BaseController {
@Autowired
private IDataSourceService dataSourceService;
/**
*
*/
@RequiresPermissions("data:source:list")
@GetMapping("/list")
public Result<TableDataInfo<DataSourceResp>> list(DataSource dataSource) {
startPage();
List<DataSourceResp> list = dataSourceService.selectDataSourceList(dataSource);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("data:source:export")
@Log(title = "数据源信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataSource dataSource) {
List<DataSourceResp> list = dataSourceService.selectDataSourceList(dataSource);
ExcelUtil<DataSourceResp> util = new ExcelUtil<DataSourceResp>(DataSourceResp.class);
util.exportExcel(response, list, "数据源信息数据");
}
/**
*
*/
@RequiresPermissions("data:source:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) {
return success(dataSourceService.selectDataSourceById(id));
}
/**
*
*/
@RequiresPermissions("data:source:add")
@Log(title = "数据源信息", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody DataSource dataSource) {
return toAjax(dataSourceService.insertDataSource(dataSource));
}
/**
*
*/
@RequiresPermissions("data:source:edit")
@Log(title = "数据源信息", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody DataSource dataSource) {
return toAjax(dataSourceService.updateDataSource(dataSource));
}
/**
*
*/
@RequiresPermissions("data:source:remove")
@Log(title = "数据源信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) {
return toAjax(dataSourceService.deleteDataSourceByIds(ids));
}
/**
*
* @param id id
* @return
*/
@RequiresPermissions("data:source:testConnection")
@PostMapping(value = "testConnection/{id}")
public Result testConnection(@PathVariable("id") Long id) {
return Result.success(dataSourceService.testConnection(id));
}
}

View File

@ -0,0 +1,62 @@
package com.etl.data.source.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etl.data.source.domain.DataSource;
import java.util.List;
/**
* Mapper
*
* @author Chao
* @date 2024-04-21
*/
public interface DataSourceMapper extends BaseMapper<DataSource> {
/**
*
*
* @param id
* @return
*/
public DataSource selectDataSourceById(Long id);
/**
*
*
* @param dataSource
* @return
*/
public List<DataSource> selectDataSourceList(DataSource dataSource);
/**
*
*
* @param dataSource
* @return
*/
public int insertDataSource(DataSource dataSource);
/**
*
*
* @param dataSource
* @return
*/
public int updateDataSource(DataSource dataSource);
/**
*
*
* @param id
* @return
*/
public int deleteDataSourceById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteDataSourceByIds(Long[] ids);
}

View File

@ -0,0 +1,69 @@
package com.etl.data.source.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.etl.data.source.domain.DataSource;
import com.etl.data.source.domain.resp.DataSourceResp;
import java.util.List;
/**
* Service
*
* @author Chao
* @date 2024-04-21
*/
public interface IDataSourceService extends IService<DataSource> {
/**
*
*
* @param id
* @return
*/
public DataSource selectDataSourceById(Long id);
/**
*
*
* @param dataSource
* @return
*/
public List<DataSourceResp> selectDataSourceList(DataSource dataSource);
/**
*
*
* @param dataSource
* @return
*/
public int insertDataSource(DataSource dataSource);
/**
*
*
* @param dataSource
* @return
*/
public int updateDataSource(DataSource dataSource);
/**
*
*
* @param ids
* @return
*/
public int deleteDataSourceByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteDataSourceById(Long id);
/**
*
* @param id id
*/
boolean testConnection(Long id);
}

View File

@ -0,0 +1,211 @@
package com.etl.data.source.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etl.common.core.utils.DateUtils;
import com.etl.data.source.domain.DataSource;
import com.etl.data.source.domain.resp.DataSourceResp;
import com.etl.data.source.mapper.DataSourceMapper;
import com.etl.data.source.service.IDataSourceService;
import com.etl.data.type.domain.DataType;
import com.etl.data.type.service.IDataTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author Chao
* @date 2024-04-21
*/
@Service
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements IDataSourceService {
@Autowired
private DataSourceMapper dataSourceMapper;
@Autowired
private IDataTypeService dataTypeService;
/**
*
*
* @param id
* @return
*/
@Override
public DataSource selectDataSourceById(Long id) {
return dataSourceMapper.selectDataSourceById(id);
}
/**
*
*
* @param dataSource
* @return
*/
@Override
public List<DataSourceResp> selectDataSourceList(DataSource dataSource) {
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(dataSource);
List<DataType> dataTypeList = dataTypeService.list();
List<DataSourceResp> dataSourceResps = new ArrayList<>();
dataSources.stream().forEach(
source -> {
dataTypeList.stream().forEach(
dataType -> {
if (dataType.getId().equals(source.getTypeId())) {
DataSourceResp build = DataSourceResp.builder()
.id(source.getId())
.dataSourceName(source.getDataSourceName())
.dataSourceSystemName(source.getDataSourceSystemName())
.typeId(source.getTypeId())
.dataType(dataType.getDataType())
.dataSourceIp(source.getDataSourceIp())
.dataSourcePort(source.getDataSourcePort())
.dataSourceDatabaseName(source.getDataSourceDatabaseName())
.dataSourceUsername(source.getDataSourceUsername())
.dataSourcePassword(source.getDataSourcePassword())
.additionalConfiguration(source.getAdditionalConfiguration())
.status(source.getStatus())
.initialNumberOfConnections(source.getInitialNumberOfConnections())
.maximumNumberOfConnections(source.getMaximumNumberOfConnections())
.maximumWaitingTime(source.getMaximumWaitingTime())
.maximumWaitingTimes(source.getMaximumWaitingTimes())
.remark(source.getRemark())
.build();
dataSourceResps.add(build);
}
}
);
}
);
return dataSourceResps;
}
/**
*
*
* @param dataSource
* @return
*/
@Override
public int insertDataSource(DataSource dataSource) {
dataSource.setCreateTime(DateUtils.getNowDate());
return dataSourceMapper.insertDataSource(dataSource);
}
/**
*
*
* @param dataSource
* @return
*/
@Override
public int updateDataSource(DataSource dataSource) {
dataSource.setUpdateTime(DateUtils.getNowDate());
return dataSourceMapper.updateDataSource(dataSource);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteDataSourceByIds(Long[] ids) {
return dataSourceMapper.deleteDataSourceByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteDataSourceById(Long id) {
return dataSourceMapper.deleteDataSourceById(id);
}
/**
*
*
* @param id id
*/
@Override
public boolean testConnection(Long id) {
DataSource dataSource = this.getOne(
new LambdaQueryWrapper<DataSource>()
.eq(DataSource::getId, id)
);
String driveClass = "";
String jdbcUrl = "";
boolean flag = false;
try {
switch (dataSource.getTypeId().intValue()) {
case 1:
driveClass = "com.mysql.cj.jdbc.Driver";
jdbcUrl = "jdbc:mysql://" + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + "/" + dataSource.getDataSourceDatabaseName() + "?" + dataSource.getAdditionalConfiguration();
break;
case 2:
// redis
//连接指定的redis
Jedis jedis = new Jedis(dataSource.getDataSourceIp(), Integer.valueOf(dataSource.getDataSourcePort()));
//如果有密码则需要下面这一行
if (dataSource.getDataSourcePassword() != null && !dataSource.getDataSourcePassword().equals("")){
jedis.auth(dataSource.getDataSourcePassword());
}
//查看服务是否运行,运行正常的话返回一个PONG否则返回一个连接错误
try {
jedis.ping();
flag = true;
} catch (Exception e) {
flag = false;
}
break;
case 3:
// oracle数据库
driveClass = "oracle.jdbc.OracleDriver";
jdbcUrl = "jdbc:oracle:thin:@" + dataSource.getDataSourceIp() + ":" + dataSource.getDataSourcePort() + ":" + dataSource.getDataSourceDatabaseName();
break;
case 4:
driveClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
jdbcUrl = "jdbc:sqlserver://"+ dataSource.getDataSourceIp() +":"+dataSource.getDataSourcePort()+";databaseName="+dataSource.getDataSourceDatabaseName();
break;
default:
return false;
}
if (dataSource.getTypeId() != 2){
flag = testDatasource(driveClass, jdbcUrl, dataSource.getDataSourceUsername(), dataSource.getDataSourcePassword());
}
return flag;
} catch (Exception e) {
return flag;
}
}
/**
*
*
* @param driveClass
* @param url
* @param username
* @param password
* @return
*/
public static boolean testDatasource(String driveClass, String url, String username, String password) {
try {
Class.forName(driveClass);
DriverManager.getConnection(url, username, password);
return true;
} catch (Exception e) {
return false;
}
}
}

View File

@ -0,0 +1,91 @@
package com.etl.data.type.controller;
import com.etl.common.core.domain.Result;
import com.etl.common.core.utils.poi.ExcelUtil;
import com.etl.common.core.web.controller.BaseController;
import com.etl.common.core.web.page.TableDataInfo;
import com.etl.common.log.annotation.Log;
import com.etl.common.log.enums.BusinessType;
import com.etl.common.security.annotation.RequiresPermissions;
import com.etl.data.type.domain.DataType;
import com.etl.data.type.service.IDataTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author Chao
* @date 2024-04-21
*/
@RestController
@RequestMapping("/type")
public class DataTypeController extends BaseController {
@Autowired
private IDataTypeService dataTypeService;
/**
*
*/
@RequiresPermissions("data:type:list")
@GetMapping("/list")
public Result<TableDataInfo<DataType>> list(DataType dataType) {
startPage();
List<DataType> list = dataTypeService.selectDataTypeList(dataType);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("data:type:export")
@Log(title = "数据源类型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataType dataType) {
List<DataType> list = dataTypeService.selectDataTypeList(dataType);
ExcelUtil<DataType> util = new ExcelUtil<DataType>(DataType.class);
util.exportExcel(response, list, "数据源类型数据");
}
/**
*
*/
@RequiresPermissions("data:type:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) {
return success(dataTypeService.selectDataTypeById(id));
}
/**
*
*/
@RequiresPermissions("data:type:add")
@Log(title = "数据源类型", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody DataType dataType) {
return toAjax(dataTypeService.insertDataType(dataType));
}
/**
*
*/
@RequiresPermissions("data:type:edit")
@Log(title = "数据源类型", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody DataType dataType) {
return toAjax(dataTypeService.updateDataType(dataType));
}
/**
*
*/
@RequiresPermissions("data:type:remove")
@Log(title = "数据源类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) {
return toAjax(dataTypeService.deleteDataTypeByIds(ids));
}
}

View File

@ -0,0 +1,62 @@
package com.etl.data.type.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etl.data.type.domain.DataType;
import java.util.List;
/**
* Mapper
*
* @author Chao
* @date 2024-04-21
*/
public interface DataTypeMapper extends BaseMapper<DataType> {
/**
*
*
* @param id
* @return
*/
public DataType selectDataTypeById(Long id);
/**
*
*
* @param dataType
* @return
*/
public List<DataType> selectDataTypeList(DataType dataType);
/**
*
*
* @param dataType
* @return
*/
public int insertDataType(DataType dataType);
/**
*
*
* @param dataType
* @return
*/
public int updateDataType(DataType dataType);
/**
*
*
* @param id
* @return
*/
public int deleteDataTypeById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteDataTypeByIds(Long[] ids);
}

View File

@ -0,0 +1,62 @@
package com.etl.data.type.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.etl.data.type.domain.DataType;
import java.util.List;
/**
* Service
*
* @author Chao
* @date 2024-04-21
*/
public interface IDataTypeService extends IService<DataType> {
/**
*
*
* @param id
* @return
*/
public DataType selectDataTypeById(Long id);
/**
*
*
* @param dataType
* @return
*/
public List<DataType> selectDataTypeList(DataType dataType);
/**
*
*
* @param dataType
* @return
*/
public int insertDataType(DataType dataType);
/**
*
*
* @param dataType
* @return
*/
public int updateDataType(DataType dataType);
/**
*
*
* @param ids
* @return
*/
public int deleteDataTypeByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteDataTypeById(Long id);
}

View File

@ -0,0 +1,91 @@
package com.etl.data.type.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etl.common.core.utils.DateUtils;
import com.etl.data.type.domain.DataType;
import com.etl.data.type.mapper.DataTypeMapper;
import com.etl.data.type.service.IDataTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author Chao
* @date 2024-04-21
*/
@Service
public class DataTypeServiceImpl extends ServiceImpl<DataTypeMapper, DataType> implements IDataTypeService {
@Autowired
private DataTypeMapper dataTypeMapper;
/**
*
*
* @param id
* @return
*/
@Override
public DataType selectDataTypeById(Long id) {
return dataTypeMapper.selectDataTypeById(id);
}
/**
*
*
* @param dataType
* @return
*/
@Override
public List<DataType> selectDataTypeList(DataType dataType) {
return dataTypeMapper.selectDataTypeList(dataType);
}
/**
*
*
* @param dataType
* @return
*/
@Override
public int insertDataType(DataType dataType) {
dataType.setCreateTime(DateUtils.getNowDate());
return dataTypeMapper.insertDataType(dataType);
}
/**
*
*
* @param dataType
* @return
*/
@Override
public int updateDataType(DataType dataType) {
dataType.setUpdateTime(DateUtils.getNowDate());
return dataTypeMapper.updateDataType(dataType);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteDataTypeByIds(Long[] ids) {
return dataTypeMapper.deleteDataTypeByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteDataTypeById(Long id) {
return dataTypeMapper.deleteDataTypeById(id);
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.etl.data.source.mapper.DataSourceMapper">
<resultMap type="com.etl.data.source.domain.DataSource" id="DataSourceResult">
<result property="id" column="id" />
<result property="dataSourceName" column="data_source_name" />
<result property="dataSourceSystemName" column="data_source_system_name" />
<result property="typeId" column="type_id" />
<result property="dataSourceIp" column="data_source_ip" />
<result property="dataSourcePort" column="data_source_port" />
<result property="dataSourceDatabaseName" column="data_source_database_name" />
<result property="dataSourceUsername" column="data_source_username" />
<result property="dataSourcePassword" column="data_source_password" />
<result property="additionalConfiguration" column="additional_configuration" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="initialNumberOfConnections" column="initial_number_of_connections" />
<result property="maximumNumberOfConnections" column="maximum_number_of_connections" />
<result property="maximumWaitingTime" column="maximum_waiting_time" />
<result property="maximumWaitingTimes" column="maximum_waiting_times" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDataSourceVo">
select id, data_source_name, data_source_system_name, type_id, data_source_ip, data_source_port, data_source_database_name, data_source_username, data_source_password, additional_configuration, status, remark, initial_number_of_connections, maximum_number_of_connections, maximum_waiting_time, maximum_waiting_times, create_by, create_time, update_by, update_time from data_source
</sql>
<select id="selectDataSourceList" parameterType="com.etl.data.source.domain.DataSource" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/>
<where>
<if test="dataSourceName != null and dataSourceName != ''"> and data_source_name like concat('%', #{dataSourceName}, '%')</if>
<if test="dataSourceSystemName != null and dataSourceSystemName != ''"> and data_source_system_name like concat('%', #{dataSourceSystemName}, '%')</if>
</where>
</select>
<select id="selectDataSourceById" parameterType="Long" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/>
where id = #{id}
</select>
<insert id="insertDataSource" parameterType="com.etl.data.source.domain.DataSource" useGeneratedKeys="true" keyProperty="id">
insert into data_source
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">data_source_name,</if>
<if test="dataSourceSystemName != null">data_source_system_name,</if>
<if test="typeId != null">type_id,</if>
<if test="dataSourceIp != null">data_source_ip,</if>
<if test="dataSourcePort != null">data_source_port,</if>
<if test="dataSourceDatabaseName != null">data_source_database_name,</if>
<if test="dataSourceUsername != null">data_source_username,</if>
<if test="dataSourcePassword != null">data_source_password,</if>
<if test="additionalConfiguration != null">additional_configuration,</if>
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
<if test="initialNumberOfConnections != null">initial_number_of_connections,</if>
<if test="maximumNumberOfConnections != null">maximum_number_of_connections,</if>
<if test="maximumWaitingTime != null">maximum_waiting_time,</if>
<if test="maximumWaitingTimes != null">maximum_waiting_times,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">#{dataSourceName},</if>
<if test="dataSourceSystemName != null">#{dataSourceSystemName},</if>
<if test="typeId != null">#{typeId},</if>
<if test="dataSourceIp != null">#{dataSourceIp},</if>
<if test="dataSourcePort != null">#{dataSourcePort},</if>
<if test="dataSourceDatabaseName != null">#{dataSourceDatabaseName},</if>
<if test="dataSourceUsername != null">#{dataSourceUsername},</if>
<if test="dataSourcePassword != null">#{dataSourcePassword},</if>
<if test="additionalConfiguration != null">#{additionalConfiguration},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
<if test="initialNumberOfConnections != null">#{initialNumberOfConnections},</if>
<if test="maximumNumberOfConnections != null">#{maximumNumberOfConnections},</if>
<if test="maximumWaitingTime != null">#{maximumWaitingTime},</if>
<if test="maximumWaitingTimes != null">#{maximumWaitingTimes},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDataSource" parameterType="com.etl.data.source.domain.DataSource">
update data_source
<trim prefix="SET" suffixOverrides=",">
<if test="dataSourceName != null">data_source_name = #{dataSourceName},</if>
<if test="dataSourceSystemName != null">data_source_system_name = #{dataSourceSystemName},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="dataSourceIp != null">data_source_ip = #{dataSourceIp},</if>
<if test="dataSourcePort != null">data_source_port = #{dataSourcePort},</if>
<if test="dataSourceDatabaseName != null">data_source_database_name = #{dataSourceDatabaseName},</if>
<if test="dataSourceUsername != null">data_source_username = #{dataSourceUsername},</if>
<if test="dataSourcePassword != null">data_source_password = #{dataSourcePassword},</if>
<if test="additionalConfiguration != null">additional_configuration = #{additionalConfiguration},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="initialNumberOfConnections != null">initial_number_of_connections = #{initialNumberOfConnections},</if>
<if test="maximumNumberOfConnections != null">maximum_number_of_connections = #{maximumNumberOfConnections},</if>
<if test="maximumWaitingTime != null">maximum_waiting_time = #{maximumWaitingTime},</if>
<if test="maximumWaitingTimes != null">maximum_waiting_times = #{maximumWaitingTimes},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDataSourceById" parameterType="Long">
delete from data_source where id = #{id}
</delete>
<delete id="deleteDataSourceByIds" parameterType="String">
delete from data_source where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.etl.data.type.mapper.DataTypeMapper">
<resultMap type="com.etl.data.type.domain.DataType" id="DataTypeResult">
<result property="id" column="id" />
<result property="dataType" column="data_type" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDataTypeVo">
select id, data_type, remark, create_by, create_time, update_by, update_time from data_type
</sql>
<select id="selectDataTypeList" parameterType="com.etl.data.type.domain.DataType" resultMap="DataTypeResult">
<include refid="selectDataTypeVo"/>
<where>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if>
</where>
</select>
<select id="selectDataTypeById" parameterType="Long" resultMap="DataTypeResult">
<include refid="selectDataTypeVo"/>
where id = #{id}
</select>
<insert id="insertDataType" parameterType="com.etl.data.type.domain.DataType" useGeneratedKeys="true" keyProperty="id">
insert into data_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dataType != null">data_type,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dataType != null">#{dataType},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDataType" parameterType="com.etl.data.type.domain.DataType">
update data_type
<trim prefix="SET" suffixOverrides=",">
<if test="dataType != null">data_type = #{dataType},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDataTypeById" parameterType="Long">
delete from data_type where id = #{id}
</delete>
<delete id="deleteDataTypeByIds" parameterType="String">
delete from data_type where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -34,6 +34,7 @@
<jjwt.version>0.9.1</jjwt.version> <jjwt.version>0.9.1</jjwt.version>
<minio.version>8.2.2</minio.version> <minio.version>8.2.2</minio.version>
<poi.version>4.1.2</poi.version> <poi.version>4.1.2</poi.version>
<jedis.version>2.9.0</jedis.version>
<transmittable-thread-local.version>2.14.3</transmittable-thread-local.version> <transmittable-thread-local.version>2.14.3</transmittable-thread-local.version>
</properties> </properties>
@ -220,6 +221,12 @@
<version>${etl.version}</version> <version>${etl.version}</version>
</dependency> </dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>