ETL模版

master_fei
Yunfei Du 2024-04-29 22:27:36 +08:00
parent ca2b2ce9d5
commit 747aa9ddf9
12 changed files with 15 additions and 698 deletions

View File

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

View File

@ -27,6 +27,7 @@ public class InnerAuthAspect implements Ordered {
throw new InnerAuthException("没有内部访问权限,不允许访问");
}
String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID);
String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
// 用户信息验证

View File

@ -1,210 +0,0 @@
package com.etl.data.source.domain;
import com.etl.common.core.annotation.Excel;
import com.etl.common.core.web.domain.BaseEntity;
/**
* data_source
*
* @author fei
* @date 2024-04-21
*/
public class DataSource extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 接入源名称 */
@Excel(name = "接入源名称")
private String name;
/** 数据来源系统名称 */
@Excel(name = "数据来源系统名称")
private String systemName;
/** 主机ip地址 */
@Excel(name = "主机ip地址")
private String host;
/** 端口 */
@Excel(name = "端口")
private String port;
/** 用户名 */
@Excel(name = "用户名")
private String username;
/** 密码 */
@Excel(name = "密码")
private String password;
/** 数据接入类型 */
@Excel(name = "数据接入类型")
private String type;
/** 数据库名称 */
@Excel(name = "数据库名称")
private String databaseName;
/** 数据连接参数 */
@Excel(name = "数据连接参数")
private String connectionParam;
/** 初始连接数量 */
@Excel(name = "初始连接数量")
private Long initNum;
/** 最大连接数量 */
@Excel(name = "最大连接数量")
private Long maxNum;
/** 最大等待时间 */
@Excel(name = "最大等待时间")
private Long maxWaitTime;
/** 最大等待次数 */
@Excel(name = "最大等待次数")
private Long maxWaitSize;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSystemName() {
return systemName;
}
public void setSystemName(String systemName) {
this.systemName = systemName;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDatabaseName() {
return databaseName;
}
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}
public String getConnectionParam() {
return connectionParam;
}
public void setConnectionParam(String connectionParam) {
this.connectionParam = connectionParam;
}
public Long getInitNum() {
return initNum;
}
public void setInitNum(Long initNum) {
this.initNum = initNum;
}
public Long getMaxNum() {
return maxNum;
}
public void setMaxNum(Long maxNum) {
this.maxNum = maxNum;
}
public Long getMaxWaitTime() {
return maxWaitTime;
}
public void setMaxWaitTime(Long maxWaitTime) {
this.maxWaitTime = maxWaitTime;
}
public Long getMaxWaitSize() {
return maxWaitSize;
}
public void setMaxWaitSize(Long maxWaitSize) {
this.maxWaitSize = maxWaitSize;
}
@Override
public String toString() {
return "DataSource{" +
"id=" + id +
", name='" + name + '\'' +
", systemName='" + systemName + '\'' +
", host='" + host + '\'' +
", port='" + port + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", type='" + type + '\'' +
", databaseName='" + databaseName + '\'' +
", connectionParam='" + connectionParam + '\'' +
", initNum=" + initNum +
", maxNum=" + maxNum +
", maxWaitTime=" + maxWaitTime +
", maxWaitSize=" + maxWaitSize +
"} " + super.toString ( );
}
}

View File

@ -92,6 +92,13 @@
<artifactId>etl-data-source-remote</artifactId>
</dependency>
<!-- 添加 PostgreSQL JDBC 驱动 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version> <!-- 使用当前最新稳定版本 -->
</dependency>
</dependencies>
<build>

View File

@ -1,22 +0,0 @@
package com.etl.data.source;
import com.etl.common.security.annotation.EnableCustomConfig;
import com.etl.common.security.annotation.EnableMyFeignClients;
import com.etl.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
*
*
* @author etl
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class ETLDataSourceApplication {
public static void main (String[] args) {
SpringApplication.run(ETLDataSourceApplication.class, args);
}
}

View File

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

View File

@ -1,62 +0,0 @@
package com.etl.data.source.mapper;
import com.etl.data.source.domain.DataSource;
import java.util.List;
/**
* Mapper
*
* @author fei
* @date 2024-04-21
*/
public interface DataSourceMapper
{
/**
*
*
* @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

@ -1,63 +0,0 @@
package com.etl.data.source.service;
import com.etl.data.source.domain.DataSource;
import java.util.List;
/**
* Service
*
* @author fei
* @date 2024-04-21
*/
public interface IDataSourceService
{
/**
*
*
* @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 ids
* @return
*/
public int deleteDataSourceByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteDataSourceById(Long id);
}

View File

@ -1,96 +0,0 @@
package com.etl.data.source.service.impl;
import java.util.List;
import com.etl.common.core.utils.DateUtils;
import com.etl.data.source.domain.DataSource;
import com.etl.data.source.mapper.DataSourceMapper;
import com.etl.data.source.service.IDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author fei
* @date 2024-04-21
*/
@Service
public class DataSourceServiceImpl implements IDataSourceService
{
@Autowired
private DataSourceMapper dataSourceMapper;
/**
*
*
* @param id
* @return
*/
@Override
public DataSource selectDataSourceById(Long id)
{
return dataSourceMapper.selectDataSourceById(id);
}
/**
*
*
* @param dataSource
* @return
*/
@Override
public List<DataSource> selectDataSourceList(DataSource dataSource)
{
return dataSourceMapper.selectDataSourceList(dataSource);
}
/**
*
*
* @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);
}
}

View File

@ -31,4 +31,4 @@ spring:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.etl.shop.cart.mapper: DEBUG
com.etl.data.mapper: DEBUG

View File

@ -1,138 +0,0 @@
<?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="name" column="name" />
<result property="systemName" column="systemName" />
<result property="host" column="host" />
<result property="port" column="port" />
<result property="username" column="username" />
<result property="password" column="password" />
<result property="type" column="type" />
<result property="databaseName" column="database_name" />
<result property="connectionParam" column="connection_param" />
<result property="initNum" column="init_num" />
<result property="maxNum" column="max_num" />
<result property="maxWaitTime" column="max_wait_time" />
<result property="maxWaitSize" column="max_wait_size" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDataSourceVo">
select id, name, systemName, host, port, username, password, type, database_name, connection_param, init_num, max_num, max_wait_time, max_wait_size, create_by, create_time, update_by, update_time, remark from data_source
</sql>
<select id="selectDataSourceList" parameterType="com.etl.data.source.domain.DataSource" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="systemName != null and systemName != ''"> and systemName like concat('%', #{systemName}, '%')</if>
<if test="host != null and host != ''"> and host = #{host}</if>
<if test="port != null and port != ''"> and port = #{port}</if>
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="databaseName != null and databaseName != ''"> and database_name like concat('%', #{databaseName}, '%')</if>
<if test="connectionParam != null and connectionParam != ''"> and connection_param = #{connectionParam}</if>
<if test="initNum != null "> and init_num = #{initNum}</if>
<if test="maxNum != null "> and max_num = #{maxNum}</if>
<if test="maxWaitTime != null "> and max_wait_time = #{maxWaitTime}</if>
<if test="maxWaitSize != null "> and max_wait_size = #{maxWaitSize}</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">
insert into data_source
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">name,</if>
<if test="systemName != null">systemName,</if>
<if test="host != null">host,</if>
<if test="port != null">port,</if>
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="type != null">type,</if>
<if test="databaseName != null">database_name,</if>
<if test="connectionParam != null">connection_param,</if>
<if test="initNum != null">init_num,</if>
<if test="maxNum != null">max_num,</if>
<if test="maxWaitTime != null">max_wait_time,</if>
<if test="maxWaitSize != null">max_wait_size,</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>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="systemName != null">#{systemName},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="type != null">#{type},</if>
<if test="databaseName != null">#{databaseName},</if>
<if test="connectionParam != null">#{connectionParam},</if>
<if test="initNum != null">#{initNum},</if>
<if test="maxNum != null">#{maxNum},</if>
<if test="maxWaitTime != null">#{maxWaitTime},</if>
<if test="maxWaitSize != null">#{maxWaitSize},</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>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDataSource" parameterType="com.etl.data.source.domain.DataSource">
update data_source
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="systemName != null">systemName = #{systemName},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="type != null">type = #{type},</if>
<if test="databaseName != null">database_name = #{databaseName},</if>
<if test="connectionParam != null">connection_param = #{connectionParam},</if>
<if test="initNum != null">init_num = #{initNum},</if>
<if test="maxNum != null">max_num = #{maxNum},</if>
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
<if test="maxWaitSize != null">max_wait_size = #{maxWaitSize},</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>
<if test="remark != null">remark = #{remark},</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

@ -50,7 +50,7 @@ public class VelocityUtils {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("tplCategory", genTable.getTplCategory());
velocityContext.put("tableName", genTable.getTableName());
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "数据源");
velocityContext.put("ClassName", genTable.getClassName());
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
velocityContext.put("moduleName", genTable.getModuleName());