集成proovy

main
刘泽璋 2024-06-30 18:42:43 +08:00
parent 0bdc8c88f9
commit 1f408ba6d3
58 changed files with 674 additions and 202 deletions

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
@ -21,7 +20,9 @@
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/../../love" />
</component>
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/etl-auth-common.iml" filepath="$PROJECT_DIR$/etl-auth-common.iml" />
</modules>
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$/etl-auth/etl-auth-common" dumb="true">
<sourceFolder url="file://$MODULE_DIR$/etl-auth/etl-auth-common/src/main/java" isTestSource="false" />
</content>
</component>
</module>

View File

@ -32,9 +32,9 @@
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>com.bwie</groupId>
@ -56,11 +56,7 @@
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>

View File

@ -1,18 +0,0 @@
//package com.auth.server.config;
//import com.auth.server.interceptor.UserInterceptor;
//import com.auth.server.mapper.UserMangeMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//@Configuration
//public class MvcConfig implements WebMvcConfigurer {
// @Autowired
// private UserMangeMapper userMangeMapper;
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// //添加拦截器,排除/路径和 /login路径
// registry.addInterceptor(new UserInterceptor(userMangeMapper))
// .excludePathPatterns("/","/user/login");
// }
//}

View File

@ -19,15 +19,13 @@ import org.springframework.beans.factory.annotation.Autowired;
public class UserRealm extends AuthorizingRealm {
@Autowired
private UserManageService userManageService;
//授权
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
/**
*Userroles
*
* */
*/
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
Subject subject= SecurityUtils.getSubject();
UserAccount currentUser =(UserAccount) subject.getPrincipal();
@ -35,7 +33,6 @@ public class UserRealm extends AuthorizingRealm {
log.info("用户权限为:"+currentUser.getRoles());
return authorizationInfo;
}
//认证
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
@ -56,7 +53,6 @@ public class UserRealm extends AuthorizingRealm {
}else {
log.info(user.getUsername());
}
//principal认证的实体信息可以是username也可以是数据库表对应的用户的实体对象
// Object principal = user.getUsername();
ByteSource salt = ByteSource.Util.bytes(username);

View File

@ -4,7 +4,7 @@ spring:
application:
name: engine-auth
redis:
host: 115.159.33.152
host: 127.0.0.1
port: 6379
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
@ -20,12 +20,12 @@ spring:
nacos:
#注册服务
discovery:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置
config:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -4,7 +4,7 @@ spring:
application:
name: engine-auth
redis:
host: 115.159.33.152
host: 127.0.0.1
port: 6379
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
@ -20,12 +20,12 @@ spring:
nacos:
#注册服务
discovery:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置
config:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -0,0 +1,39 @@
package com.etl.data.source.common.pojo.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "数据库配置")
public class DataRinse {
@NotBlank(message = "驱动类不能为空")
@ApiModelProperty(value = "驱动类")
private String driverClassName;
@NotBlank(message = "数据库连接地址不能为空")
@ApiModelProperty(value = "数据库连接地址")
private String url;
@NotBlank(message = "数据库用户名不能为空")
@ApiModelProperty(value = "数据库用户名")
private String username;
@NotBlank(message = "数据库密码不能为空")
@ApiModelProperty(value = "数据库密码")
private String password;
@ApiModelProperty(value = "数据库表名")
private String tableName;
@ApiModelProperty(value = "数据库库名")
private String warehouseName;
@ApiModelProperty(value = "数据表输入输出状态 0输入 1输出")
private Integer data;
@ApiModelProperty(value = "规则0数据清洗 1:数据脱敏")
private Integer ruleTypeId;
}

View File

@ -0,0 +1,5 @@
#Generated by Maven
#Fri Jun 28 17:15:30 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie
artifactId=el-data-source-common

View File

@ -0,0 +1,22 @@
com\etl\data\source\common\pojo\DataSourceType.class
com\etl\data\source\common\pojo\DatabaseRedis.class
com\etl\data\source\common\pojo\resq\ColumnInfo.class
com\etl\data\source\common\pojo\req\RuleReq.class
com\etl\data\source\common\pojo\req\DataSourceReq.class
com\etl\data\source\common\pojo\req\ConnectMysqlReq.class
com\etl\data\source\common\pojo\req\DataRinse.class
com\etl\data\source\common\pojo\Task.class
com\etl\data\source\common\pojo\CodeType.class
com\etl\data\source\common\pojo\constants\MysqlConstants.class
com\etl\data\source\common\ennum\LimitType.class
com\etl\data\source\common\pojo\constants\Constants.class
com\etl\data\source\common\pojo\DatabaseConfig.class
com\etl\data\source\common\pojo\Rule.class
com\etl\data\source\common\pojo\RuleType.class
com\etl\data\source\common\pojo\Code.class
com\etl\data\source\common\pojo\DataSource.class
com\etl\data\source\common\pojo\BaseEntity.class
com\etl\data\source\common\pojo\Person.class
com\etl\data\source\common\pojo\req\DataSourceColumn.class
com\etl\data\source\common\pojo\TaskManagerEntity.class
com\etl\data\source\common\pojo\until\R.class

View File

@ -0,0 +1,22 @@
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\Person.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\DatabaseRedis.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\TaskManagerEntity.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\Code.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\DataSource.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\Rule.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\req\DataSourceReq.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\req\DataRinse.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\req\DataSourceColumn.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\RuleType.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\req\ConnectMysqlReq.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\Task.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\constants\MysqlConstants.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\DataSourceType.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\ennum\LimitType.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\DatabaseConfig.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\constants\Constants.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\CodeType.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\BaseEntity.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\resq\ColumnInfo.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\req\RuleReq.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-common\src\main\java\com\etl\data\source\common\pojo\until\R.java

View File

@ -16,6 +16,30 @@
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.21.1</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
@ -55,7 +79,18 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
<version>31.1-jre</version>
<exclusions>
<exclusion>
<groupId>com.OpenAI.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -1,7 +1,7 @@
package com.etl.data.source.server.aop;
import com.etl.common.exception.LimitException;
import com.etl.data.source.common.config.Limit;
import com.etl.data.source.server.config.Limit;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.RateLimiter;
import lombok.extern.slf4j.Slf4j;
@ -20,7 +20,7 @@ public class LimitAspect {
private final Map<String, RateLimiter> limitMap = Maps.newConcurrentMap();
@Around("@annotation(com.etl.data.source.common.config.Limit)")
@Around("@annotation(com.etl.data.source.server.config.Limit)")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature signature = (MethodSignature)pjp.getSignature();
Method method = signature.getMethod();

View File

@ -1,4 +1,4 @@
package com.etl.data.source.common.config;
package com.etl.data.source.server.config;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

View File

@ -1,11 +1,7 @@
package com.etl.data.source.server.config;
import com.etl.data.source.common.pojo.DatabaseRedis;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@Configuration

View File

@ -1,17 +1,16 @@
package com.etl.data.source.server.controller;
import com.etl.common.result.Result;
import com.etl.data.source.common.config.Limit;
import com.etl.data.source.server.config.Limit;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.req.DataRinse;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.common.pojo.until.R;
import com.etl.data.source.server.service.DatabaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@ -29,9 +28,9 @@ public class DatabaseController {
@PostMapping("/testDatabaseRedis")
@ApiOperation(value = "测试redis连接")
@Limit(key = "testDatabaseRedis", permitsPerSecond = 1, timeout = 500, msg = "当前排队人数较多,请稍后再试!")
public Result<Map<String,String>> testDatabaseRedis(@Valid @RequestBody DatabaseRedis databaseRedis) {
public Result testDatabaseRedis(@Valid @RequestBody DatabaseRedis databaseRedis) {
Map<String,String> map = databaseService.testDatabaseRedis(databaseRedis);
return Result.success(map);
return Result.success("连接成功");
}
// POST请求映射到/test-database-connection路径
@PostMapping("/testDatabaseMysql")
@ -63,13 +62,13 @@ public class DatabaseController {
@PostMapping("/findDatabaseTableFieldPrice")
@ApiOperation("数据表输入")
public Result<List<Map<String, Object>> > findDatabaseTableFieldPrice(@Valid @RequestBody DatabaseConfig config){
public Result<List<Map<String, Object>> > findDatabaseTableFieldPrice(@Valid @RequestBody DataRinse config){
return Result.success(databaseService.findDatabaseTableFieldPrice(config));
}
@PostMapping("outDatabaseTableFieldPrice")
@ApiOperation("数据表输出")
public Result outDatabaseTableFieldPrice(@Valid @RequestBody DatabaseConfig config){
public Result outDatabaseTableFieldPrice(@Valid @RequestBody DataRinse config){
return Result.success(databaseService.findDatabaseTableFieldPrice(config));
}

View File

@ -3,6 +3,10 @@ package com.etl.data.source.server.mapper;
import com.etl.data.source.common.pojo.DataSource;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @ClassName DataSourceBaseMapper
@ -11,4 +15,5 @@ import com.github.yulichang.base.MPJBaseMapper;
* @Date 2024/6/25 14:19
*/
public interface DataSourceBaseMapper extends MPJBaseMapper<DataSource> {
}

View File

@ -3,6 +3,7 @@ package com.etl.data.source.server.service;
import com.etl.data.source.common.pojo.DataSource;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.req.DataRinse;
import com.etl.data.source.common.pojo.req.DataSourceColumn;
import com.etl.data.source.common.pojo.req.DataSourceReq;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
@ -29,5 +30,5 @@ public interface DatabaseService {
Map<String, String> testDatabaseRedis(DatabaseRedis databaseRedis);
List<Map<String, Object>> findDatabaseTableFieldPrice(DatabaseConfig config);
List<Map<String, Object>> findDatabaseTableFieldPrice(DataRinse config);
}

View File

@ -4,12 +4,18 @@ import com.etl.common.util.StringUtils;
import com.etl.data.source.common.pojo.DatabaseConfig;
import com.etl.data.source.common.pojo.DatabaseRedis;
import com.etl.data.source.common.pojo.constants.MysqlConstants;
import com.etl.data.source.common.pojo.req.DataRinse;
import com.etl.data.source.common.pojo.resq.ColumnInfo;
import com.etl.data.source.server.config.RedisConfig;
import com.etl.data.source.server.mapper.DataSourceBaseMapper;
import com.etl.data.source.server.mapper.DataSourceTypeBaseMapper;
import com.etl.data.source.server.service.DatabaseService;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@ -22,6 +28,7 @@ import redis.clients.jedis.ScanResult;
import javax.sql.DataSource;
import java.sql.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName DatabaseServiceImpl
@ -32,6 +39,7 @@ import java.util.*;
@Service
@Slf4j
public class DatabaseServiceImpl implements DatabaseService {
@Autowired
private DataSourceBaseMapper dataSourceBaseMapper;
@ -56,6 +64,7 @@ public class DatabaseServiceImpl implements DatabaseService {
@Override
public List<String> findDatabaseTable(DatabaseConfig config) {
List<String> tableNames = new ArrayList<>();
try (Connection connection = getConnection(config)) {
try (Statement statement = connection.createStatement()) {
@ -69,14 +78,17 @@ public class DatabaseServiceImpl implements DatabaseService {
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return tableNames;
}
@Override
public List<String> findDatabaseTables(DatabaseConfig config) {
if(StringUtils.isNull(config.getWarehouseName())){
throw new RuntimeException("请选择数据库");
}
List<String> tableNames = new ArrayList<>();
try (Connection connection = getConnection(config)) {
try (Statement statement = connection.createStatement()) {
@ -91,17 +103,21 @@ public class DatabaseServiceImpl implements DatabaseService {
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return tableNames;
}
@Override
public List<ColumnInfo> findDatabaseTableField(DatabaseConfig config) {
if(StringUtils.isNull(config.getWarehouseName())){
throw new RuntimeException("请选择数据库");
}
if(StringUtils.isNull(config.getTableName())){
throw new RuntimeException("请选择表");
}
List<ColumnInfo> columnInfos = new ArrayList<>();
Connection connection = null;
PreparedStatement preparedStatement = null;
@ -141,7 +157,6 @@ public class DatabaseServiceImpl implements DatabaseService {
columnInfo.setColumnKey(resultSet.getString("COLUMN_KEY"));
columnInfo.setIsNullable(resultSet.getString("IS_NULLABLE"));
columnInfo.setColumnComment(resultSet.getString("COLUMN_COMMENT"));
columnInfos.add(columnInfo);
}
@ -151,9 +166,9 @@ public class DatabaseServiceImpl implements DatabaseService {
} finally {
// 关闭资源
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
if (resultSet != null) {resultSet.close();}
if (preparedStatement != null) {preparedStatement.close();}
if (connection != null) {connection.close();}
} catch (SQLException e) {
e.printStackTrace();
}
@ -162,14 +177,28 @@ public class DatabaseServiceImpl implements DatabaseService {
return columnInfos;
}
@Override
public List<Map<String, Object>> findDatabaseTableFieldPrice(DatabaseConfig config) {
public List<Map<String, Object>> findDatabaseTableFieldPrice(DataRinse config) {
if(StringUtils.isNull(config.getWarehouseName())){
throw new RuntimeException("请选择数据库");
}
if(StringUtils.isNull(config.getTableName())){
throw new RuntimeException("请选择表");
}
List<Map<String, Object>> results = new ArrayList<>();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setDriverClassName(config.getDriverClassName());
databaseConfig.setUrl(config.getUrl());
databaseConfig.setUsername(config.getUsername());
databaseConfig.setPassword(config.getPassword());
databaseConfig.setWarehouseName(config.getWarehouseName());
databaseConfig.setTableName(config.getTableName());
try {
connection = getConnection(config);
connection = getConnection(databaseConfig);
// 这里我们仅作为示例直接构建SQL查询语句实际中可能需要更复杂的逻辑来构建SQL
String sql = "SELECT * FROM " + config.getWarehouseName() + "." + config.getTableName();
preparedStatement = connection.prepareStatement(sql);
@ -195,19 +224,95 @@ public class DatabaseServiceImpl implements DatabaseService {
} finally {
// 关闭资源
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
if (resultSet != null) {resultSet.close();}
if (preparedStatement != null) {preparedStatement.close();}
if (connection != null) {connection.close();}
} catch (SQLException e) {
e.printStackTrace();
}
}
results = checkRoule(results,config.getRuleTypeId());
if(1 == config.getData()){
insertDataExcludingId(config, results);
insertDataExcludingId(databaseConfig, results);
}
return results;
}
public List<Map<String, Object>> checkRoule(List<Map<String, Object>> results, Integer ruleTypeId) {
if (ruleTypeId != null) {
// 根据不同的ruleTypeId进行不同的处理
switch (ruleTypeId) {
case 1:
// 对results数据进行清洗将所有包含中文的字段内容转为英文
results = results.stream()
.map(map -> {
map.forEach((key, value) -> {
if (value instanceof String) {
String strValue = (String) value;
if (strValue.matches(".*[\u4e00-\u9fa5]+.*")) { // 判断是否包含中文
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE); // 小写
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); // 不带音调
format.setVCharType(HanyuPinyinVCharType.WITH_V); // 使用带 "v" 的拼写方式
StringBuilder englishValue = new StringBuilder();
for (char c : strValue.toCharArray()) {
try {
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format);
if (pinyinArray != null) {
englishValue.append(String.join("", pinyinArray));
} else {
englishValue.append(c); // 非中文字符直接追加
}
} catch (Exception e) {
// 处理转换异常
System.err.println("拼音转换异常:" + e.getMessage());
}
}
map.put(key, englishValue.toString());
}
}
});
return map;
})
.collect(Collectors.toList());
break;
case 2:
// 对results数据进行脱敏对字段是username的进行脱敏
results = results.stream()
.map(map -> {
if (map.containsKey("username")) {
String name = (String) map.get("username");
if (name.length() > 1) {
// 根据姓名长度添加星号
String desensitizedName = name.substring(0, 1); // 保留第一个字
for (int i = 1; i < name.length(); i++) {
desensitizedName += "*";
}
map.put("username", desensitizedName);
}
}
if (map.containsKey("userphone")) {
String userphone = (String) map.get("userphone");
if (userphone.length() > 7) {
map.put("userphone", userphone.substring(0, 3) + "****" + userphone.substring(7)); // 保留前三位和后一位,中间用星号代替
}
}
return map;
})
.collect(Collectors.toList());
break;
default:
throw new RuntimeException("不支持的规则类型ID: " + ruleTypeId);
}
return results;
}
return results;
}
public void insertDataExcludingId(DatabaseConfig config, List<Map<String, Object>> results) {
Connection connection = null;
PreparedStatement preparedStatement = null;
@ -253,8 +358,8 @@ public class DatabaseServiceImpl implements DatabaseService {
} finally {
// 关闭资源
try {
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
if (preparedStatement != null) {preparedStatement.close();}
if (connection != null) {connection.close();}
} catch (SQLException e) {
e.printStackTrace();
}

View File

@ -0,0 +1,7 @@
<?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.server.mapper.DataSourceBaseMapper">
</mapper>

View File

@ -0,0 +1,7 @@
<?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.server.mapper.DataSourceBaseMapper">
</mapper>

View File

@ -1,5 +0,0 @@
#Generated by Maven
#Fri Jun 21 15:04:44 CST 2024
groupId=com.bwie
artifactId=el-data-source-server
version=1.0-SNAPSHOT

View File

@ -1 +0,0 @@
com\etl\data\source\server\ElDataSourceServerApplication.class

View File

@ -1 +1,28 @@
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\DataSourceTypeBaseMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\config\Limit.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\impl\TaskServiceImpl.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\config\RedissonConfig.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\TaskMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\controller\RuleController.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\RuleService.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\aop\LimitAspect.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\CodeBaseMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\controller\TaskController.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\ElDataSourceServerApplication.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\RuleBaseMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\impl\DataSheetServiceImpl.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\config\Swagger.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\controller\DatabaseController.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\impl\RuleServiceImpl.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\GlobalExceptionHandler.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\DataSourceBaseMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\DatabaseService.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\impl\DataSourceServiceImpl.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\DataSheetService.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\config\RedisConfig.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\TaskService.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\controller\DataSheetController.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\controller\DataSourceController.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\mapper\DataSheetMapper.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\impl\DatabaseServiceImpl.java
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\main\java\com\etl\data\source\server\service\DataSourceService.java

View File

@ -1 +0,0 @@
com\etl\data\source\server\ElDataSourceServerApplicationTests.class

View File

@ -1 +0,0 @@
D:\workspace\etl-cloud\etl-data-source\el-data-source-server\src\test\java\com\etl\data\source\server\ElDataSourceServerApplicationTests.java

View File

@ -92,10 +92,29 @@
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.21.1</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- SpringBoot Boot Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>

View File

@ -9,12 +9,12 @@ spring:
nacos:
#注册服务
discovery:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置
config:
server-addr: 115.159.33.152:8848
namespace: f9f293d4-55ce-45c1-aa15-124ca461c060
server-addr: 182.254.221.163:8848
namespace: 10a15e4b-3457-44dc-9378-cc25849f1872
# 配置文件格式
file-extension: yml
logging:

View File

@ -15,6 +15,15 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-spring-boot-starter</artifactId>
<version>2.10.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.bwie</groupId>
<artifactId>etl-common</artifactId>

View File

@ -2,19 +2,14 @@ package com.etl.groovy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.etl.groovy"})
@ComponentScan("com.etl.groovy.config")
public class SpringBootGroovyApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootGroovyApplication.class, args);
}
}

View File

@ -0,0 +1,14 @@
package com.etl.groovy.config;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("acmp")
public class ACmp extends NodeComponent {
@Override
public void process() {
//do your business
System.out.println("acmp执行");
}
}

View File

@ -0,0 +1,14 @@
package com.etl.groovy.config;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("bcmp")
public class BCmp extends NodeComponent {
@Override
public void process() {
//do your business
System.out.println("bcmp执行");
}
}

View File

@ -0,0 +1,14 @@
package com.etl.groovy.config;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("ccmp")
public class CCmp extends NodeComponent {
@Override
public void process() {
//do your business
System.out.println("ccmp执行");
}
}

View File

@ -0,0 +1,48 @@
package com.etl.groovy.controller;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName GrooyTestController
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/26 16:58
*/
@RestController
@RequestMapping("/groovy")
public class GroovyTestController {
@GetMapping("/test")
public Object test() {
// 创建GroovyShell
GroovyShell groovyShell = new GroovyShell();
// 装载解析脚本代码
String scriptText =
"import com.etl.groovy.service.GroovyTestService\n" +
"import com.etl.groovy.util.SpringContextUtil\n" +
"\n" +
"def getBean() {\n" +
" GroovyTestService groovyTestService = SpringContextUtil.getBean(GroovyTestService.class);\n" +
" groovyTestService.removeDashesFromAddress()\n" +
"}\n" +
"\n" +
"// 如果需要,你可以在这里定义方法或变量来模拟静态变量的行为\n" +
"def getParam1() {\n" +
" return \"通过方法获取的模拟静态变量\"\n" +
"}\n";
// 解析脚本
Script script = groovyShell.parse(scriptText);
// 执行getBean方法
script.invokeMethod("getBean", null);
// 尝试获取模拟的静态变量(通过方法)
Object param1 = script.invokeMethod("getParam1", null);
return param1;
}
}

View File

@ -1,43 +0,0 @@
package com.etl.groovy.controller;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName GrooyTestController
* @Description
* @Author ZeZhang.Liu
* @Date 2024/6/26 16:58
*/
@RestController
@RequestMapping("/groovy")
public class GrooyTestController {
@RequestMapping("/test")
public String test() {
//创建GroovyShell
GroovyShell groovyShell = new GroovyShell();
//装载解析脚本代码
Script script = groovyShell.parse("package groovy\n" +
"\n" +
"import com.etl.groovy.service.GroovyTestService\n" +
"import com.etl.groovy.util.SpringContextUtil\n" +
"\n" +
"/**\n" +
" * 静态变量\n" +
" */\n" +
"class Globals {\n" +
" static String PARAM1 = \"静态变量\"\n" +
" static int[] arrayList = [1, 2]\n" +
"}\n" +
"\n" +
"def getBean() {\n" +
" GroovyTestService groovyTestService = SpringContextUtil.getBean(GroovyTestService.class);\n" +
" groovyTestService.removeDashesFromAddress()\n" +
"}");
//执行
script.invokeMethod("getBean", null);
return "ok";
}
}

View File

@ -21,3 +21,61 @@ mybatis-plus:
map-underscore-to-camel-case: true
type-aliases-package: com.etl.groovy.entity
mapper-locations: classpath:mappers/*xml
liteflow:
#规则文件路径
rule-source: config/flow.el.xml
#-----------------以下非必须-----------------
#liteflow是否开启默认为true
enable: true
#liteflow的banner打印是否开启默认为true
print-banner: true
#zkNode的节点只有使用zk作为配置源的时候才起作用默认为/lite-flow/flow
zk-node: /lite-flow/flow
#上下文的最大数量槽默认值为1024
slot-size: 1024
#FlowExecutor的execute2Future的线程数默认为64
main-executor-works: 64
#FlowExecutor的execute2Future的自定义线程池BuilderLiteFlow提供了默认的Builder
main-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
#自定义请求ID的生成类LiteFlow提供了默认的生成类
request-id-generator-class: com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
#并行节点的线程池BuilderLiteFlow提供了默认的Builder
thread-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder
#异步线程最长的等待时间(只用于when)默认值为15000
when-max-wait-time: 15000
#异步线程最长的等待时间(只用于when)默认值为MILLISECONDS毫秒
when-max-wait-time-unit: MILLISECONDS
#when节点全局异步线程池最大线程数默认为16
when-max-workers: 16
#并行循环子项线程池最大线程数默认为16
parallelLoop-max-workers: 16
#并行循环子项线程池等待队列数默认为512
parallelLoop-queue-limit: 512
#并行循环子项的线程池BuilderLiteFlow提供了默认的Builder
parallelLoop-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder
#when节点全局异步线程池等待队列数默认为512
when-queue-limit: 512
#是否在启动的时候就解析规则默认为true
parse-on-start: true
#全局重试次数默认为0
retry-count: 0
#是否支持不同类型的加载方式混用默认为false
support-multiple-type: false
#全局默认节点执行器
node-executor-class: com.yomahub.liteflow.flow.executor.DefaultNodeExecutor
#是否打印执行中过程中的日志默认为true
print-execution-log: true
#是否开启本地文件监听默认为false
enable-monitor-file: false
#是否开启快速解析模式默认为false
fast-load: false
#简易监控配置选项
monitor:
#监控是否开启,默认不开启
enable-log: false
#监控队列存储大小默认值为200
queue-limit: 200
#监控一开始延迟多少执行默认值为300000毫秒也就是5分钟
delay: 300000
#监控日志打印每过多少时间执行一次默认值为300000毫秒也就是5分钟
period: 300000

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
THEN(acmp, bcmp, ccmp);
</chain>
</flow>

View File

@ -21,3 +21,61 @@ mybatis-plus:
map-underscore-to-camel-case: true
type-aliases-package: com.etl.groovy.entity
mapper-locations: classpath:mappers/*xml
liteflow:
#规则文件路径
rule-source: config/flow.el.xml
#-----------------以下非必须-----------------
#liteflow是否开启默认为true
enable: true
#liteflow的banner打印是否开启默认为true
print-banner: true
#zkNode的节点只有使用zk作为配置源的时候才起作用默认为/lite-flow/flow
zk-node: /lite-flow/flow
#上下文的最大数量槽默认值为1024
slot-size: 1024
#FlowExecutor的execute2Future的线程数默认为64
main-executor-works: 64
#FlowExecutor的execute2Future的自定义线程池BuilderLiteFlow提供了默认的Builder
main-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
#自定义请求ID的生成类LiteFlow提供了默认的生成类
request-id-generator-class: com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
#并行节点的线程池BuilderLiteFlow提供了默认的Builder
thread-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder
#异步线程最长的等待时间(只用于when)默认值为15000
when-max-wait-time: 15000
#异步线程最长的等待时间(只用于when)默认值为MILLISECONDS毫秒
when-max-wait-time-unit: MILLISECONDS
#when节点全局异步线程池最大线程数默认为16
when-max-workers: 16
#并行循环子项线程池最大线程数默认为16
parallelLoop-max-workers: 16
#并行循环子项线程池等待队列数默认为512
parallelLoop-queue-limit: 512
#并行循环子项的线程池BuilderLiteFlow提供了默认的Builder
parallelLoop-executor-class: com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder
#when节点全局异步线程池等待队列数默认为512
when-queue-limit: 512
#是否在启动的时候就解析规则默认为true
parse-on-start: true
#全局重试次数默认为0
retry-count: 0
#是否支持不同类型的加载方式混用默认为false
support-multiple-type: false
#全局默认节点执行器
node-executor-class: com.yomahub.liteflow.flow.executor.DefaultNodeExecutor
#是否打印执行中过程中的日志默认为true
print-execution-log: true
#是否开启本地文件监听默认为false
enable-monitor-file: false
#是否开启快速解析模式默认为false
fast-load: false
#简易监控配置选项
monitor:
#监控是否开启,默认不开启
enable-log: false
#监控队列存储大小默认值为200
queue-limit: 200
#监控一开始延迟多少执行默认值为300000毫秒也就是5分钟
delay: 300000
#监控日志打印每过多少时间执行一次默认值为300000毫秒也就是5分钟
period: 300000

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
THEN(acmp, bcmp, ccmp);
</chain>
</flow>