Compare commits
37 Commits
Author | SHA1 | Date |
---|---|---|
|
e22546a5a7 | |
|
02449a6cb9 | |
|
c47c396c98 | |
|
e3f02b4cf8 | |
|
ae42198a13 | |
|
c783f979d8 | |
|
fe1831a58c | |
|
8408d8f9a6 | |
|
7462c6b251 | |
|
3f8d1fd13b | |
|
5c13d4ba74 | |
|
c33a79599c | |
|
8e0100d909 | |
|
38d52196d2 | |
|
7e8eb968c0 | |
|
dc7bb6a28f | |
|
7496035269 | |
|
7793e99331 | |
|
22bc57b231 | |
|
608f365b60 | |
|
81c1289111 | |
|
49606ab287 | |
|
b36bfd17e8 | |
|
6a2fb20342 | |
|
5af8c4155a | |
|
4e9ba19c33 | |
|
ffd058d717 | |
|
5157792eb7 | |
|
d84aa60bf2 | |
|
f0e60f7ea0 | |
|
1ecbc6702d | |
|
cf4a5755dd | |
|
609b6478b6 | |
|
01c567140e | |
|
102e252f73 | |
|
a9170951fd | |
|
ab2a94179b |
64
README.md
64
README.md
|
@ -1,11 +1,32 @@
|
|||
## 系统模块
|
||||
# **gtl-ruoyi-server**
|
||||
|
||||
## **项目介绍**
|
||||
|
||||
### 简介
|
||||
|
||||
本项目是 **ETL** 项目,主要功能是对接入的 **数据源** 进行数据的 **抽取**(Extract) > **清洗**(Cleaning) > **转换**(Transform) > **装载**(Load) 。
|
||||
|
||||
### 背景
|
||||
|
||||
**数据**是现代企业的重要资产,是企业运用**科学管理**、**决策分析**的基础。在企业中,数据通常来自于多个不同的系统和部门。数据分散存储,较为单一,难以对企业的统一发展规划提供帮助,企业需要对这些数据进行提取筛选,打破信息孤岛的困境,分析出有效信息。让只懂一些,甚至不懂数据存储的企业人也能快速上手,通过一些技术去处理自有数据。
|
||||
|
||||
### 需求
|
||||
|
||||
把分散的数据源提取>清洗>转换>整合,形成一个完整的数据集,便于后续的分析和处理。
|
||||
|
||||
### 拓展
|
||||
|
||||
经由 **ETL**技术 处理过的数据,一般会去往 **BI**(商业智能)/**DM**(数据仓库) 进行分析或存储
|
||||
|
||||
## 项目模块
|
||||
|
||||
~~~
|
||||
com.ruoyi
|
||||
├── muyu-ui // 前端框架 [80]
|
||||
├── muyu-gateway // 网关模块 [8080]
|
||||
├── muyu-auth // 认证中心 [9200]
|
||||
├── muyu-common // 通用模块
|
||||
├── gtl-ruoyi-ui // 前端框架 [80]
|
||||
├── ruoyi-gateway // 网关模块 [8080]
|
||||
├── ruoyi-auth // 认证中心 [9200]
|
||||
├── ruoyi-common // 通用模块
|
||||
│ └── muyu-common-cache // 缓存模块
|
||||
│ └── muyu-common-core // 核心模块
|
||||
│ └── muyu-common-datascope // 权限范围
|
||||
│ └── muyu-common-datasource // 多数据源
|
||||
|
@ -15,12 +36,33 @@ com.ruoyi
|
|||
│ └── muyu-common-security // 安全模块
|
||||
│ └── muyu-common-swagger // 系统接口
|
||||
│ └── muyu-common-system // 系统基础
|
||||
├── muyu-modules // 业务模块
|
||||
│ └── muyu-system // 系统模块 [9201]
|
||||
│ └── muyu-gen // 代码生成 [9202]
|
||||
│ └── muyu-job // 定时任务 [9203]
|
||||
│ └── muyu-file // 文件服务 [9300]
|
||||
├── muyu-visual // 图形化管理模块
|
||||
├── ruoyi-modules // 业务模块
|
||||
│ └── ruoyi-system // 系统模块 [9201]
|
||||
│ └── ruoyi-gen // 代码生成 [9202]
|
||||
│ └── ruoyi-job // 定时任务 [9203]
|
||||
│ └── ruoyi-data-asset // 数据资产 [9204]
|
||||
│ └── ruoyi-file // 文件服务 [9300]
|
||||
├── ruoyi-visual // 图形化管理模块
|
||||
│ └── muyu-visual-monitor // 监控中心 [9100]
|
||||
├──pom.xml // 公共依赖
|
||||
~~~
|
||||
## **项目技术栈**
|
||||
|
||||
### SpringCloud & Alibaba/SpringBoot
|
||||
|
||||
因为 `SpringCloud`进入到了维护阶段,不会再有新的组件技术出现。`Spring Cloud Alibaba`是`Spring cloud`的子项目,阿里巴巴推广,并且API是中文。
|
||||
|
||||
### Mybatis Plus/Mybatis
|
||||
|
||||
`Mybatis`是免费优秀的开源持久层框架。`Mybatis-Plus`是一个`Mybatis`的增强工具,它在`Mybatis`的基础上做了增强,却不做改变。
|
||||
|
||||
### Redis
|
||||
|
||||
本地缓存多个服务之间数据无法共享,甚至是数据存量也不够大,不做考虑。而分布式存储,目前市面上使用比较多的是`memcached`和`redis`,但`memcached`支持的数据类型只有K/V,没有`redis`支持的数据类型多,也不支持持久化
|
||||
|
||||
### JDBC
|
||||
|
||||
使用`JDBC`是为了动态的根据数据库的已有数据源连接数据去获取数据源的连接,方便从多个数据库/多种数据库快速提取数据。
|
||||
|
||||
|
||||
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -5,10 +5,10 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
|
||||
<name>muyu</name>
|
||||
<name>gtl-ruoyi-server</name>
|
||||
|
||||
<description>微服务系统</description>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -11,7 +11,7 @@
|
|||
<artifactId>ruoyi-auth</artifactId>
|
||||
|
||||
<description>
|
||||
muyu-auth认证授权中心
|
||||
ruoyi-auth认证授权中心
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -52,6 +52,24 @@
|
|||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Sleuth -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Zipkin -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zipkin</artifactId>
|
||||
<version>2.2.8.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
*/
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class MuYuAuthApplication {
|
||||
public class GtlAuthApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(MuYuAuthApplication.class, args);
|
||||
SpringApplication.run(GtlAuthApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -14,14 +14,26 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 47.98.98.250:8848
|
||||
server-addr: 139.224.220.40:8848
|
||||
namespace: 143f1a53-e544-4782-8667-877c532e2c66
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 47.98.98.250:8848
|
||||
server-addr: 139.224.220.40:8848
|
||||
namespace: 143f1a53-e544-4782-8667-877c532e2c66
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
#配置zipkin
|
||||
zipkin:
|
||||
base-url: http://127.0.0.1:9411
|
||||
# 不要让nacos把zipkin注册进去(可以不写)
|
||||
discovery-client-enabled: false
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1.0
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi.auth: DEBUG
|
||||
config: classpath:logback-spring.xml
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
|
||||
<springProperty scope="context" name="springAppName"
|
||||
source="spring.application.name" />
|
||||
|
||||
<!-- 日志输出位置 -->
|
||||
<property name="LOG_FILE" value="${BUILD_FOLDER:-build}/${springAppName}" />
|
||||
|
||||
<!-- 日志格式 -->
|
||||
<!-- sleuth输出必需有的 = %clr(${LOG_LEVEL_PATTERN:-%5p} -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="%clr(%d{HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<!-- 日志输出编码 -->
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>utf8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- Logstash -->
|
||||
<!-- 为logstash输出的JSON格式的Appender -->
|
||||
<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>192.168.44.128:5044</destination>
|
||||
<!-- 日志输出编码 -->
|
||||
<encoder
|
||||
class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<timestamp>
|
||||
<timeZone>UTC</timeZone>
|
||||
</timestamp>
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"severity": "%level",
|
||||
"service": "${springAppName:-}",
|
||||
"trace": "%X{X-B3-TraceId:-}",
|
||||
"span": "%X{X-B3-SpanId:-}",
|
||||
"exportable": "%X{X-Span-Export:-}",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger{40}",
|
||||
"rest": "%message"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 日志输出级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="logstash" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -5,7 +5,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.common.cache;
|
||||
package com.ruoyi.common.cache;
|
||||
|
||||
import com.muyu.common.cache.decoration.DecorationKey;
|
||||
import com.ruoyi.common.cache.decoration.DecorationKey;
|
||||
|
||||
/**
|
||||
* 原子序列缓存基准
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.common.cache;
|
||||
package com.ruoyi.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存接口基类
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.common.cache;
|
||||
package com.ruoyi.common.cache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.common.cache.abs;
|
||||
package com.ruoyi.common.cache.abs;
|
||||
|
||||
import com.muyu.common.cache.AtomicSequenceCache;
|
||||
import com.ruoyi.common.cache.AtomicSequenceCache;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.common.cache.abs;
|
||||
package com.ruoyi.common.cache.abs;
|
||||
|
||||
import com.muyu.common.cache.Cache;
|
||||
import com.ruoyi.common.cache.Cache;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.concurrent.TimeUnit;
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.common.cache.abs;
|
||||
package com.ruoyi.common.cache.abs;
|
||||
|
||||
import com.muyu.common.cache.HashCache;
|
||||
import com.ruoyi.common.cache.HashCache;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.common.cache.decoration;
|
||||
package com.ruoyi.common.cache.decoration;
|
||||
|
||||
/**
|
||||
* 装饰key
|
|
@ -22,7 +22,12 @@ public class ServiceNameConstants {
|
|||
public static final String FILE_SERVICE = "ruoyi-file";
|
||||
|
||||
/**
|
||||
* 商品服务的serviceid
|
||||
* 数据接入服务的serviceid
|
||||
*/
|
||||
public static final String PRODUCT_SERVICE = "ruoyi-product";
|
||||
public static final String DATA_ACCESS_SERVICE = "ruoyi-data-asset";
|
||||
|
||||
/**
|
||||
* 规则引擎服务的serviceid
|
||||
*/
|
||||
public static final String RULE_ENGINE_SERVICE = "ruoyi-rule-engine";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.ruoyi.common.security.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 初始化认证:初始化项目时跳过权限认证
|
||||
*
|
||||
* @Author GuanTieLin
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
public @interface InitAuth {
|
||||
/**
|
||||
* 认证的url
|
||||
*/
|
||||
String value() default "";
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package com.ruoyi.common.security.aspect;
|
||||
|
||||
import com.ruoyi.common.security.service.InitAuthService;
|
||||
import com.ruoyi.common.core.utils.ServletUtils;
|
||||
import com.ruoyi.common.security.annotation.InitAuth;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.common.security.annotation.RequiresRoles;
|
||||
|
@ -9,9 +12,11 @@ import org.aspectj.lang.annotation.Around;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 基于 Spring Aop 的注解鉴权
|
||||
|
@ -21,12 +26,17 @@ import java.lang.reflect.Method;
|
|||
@Aspect
|
||||
@Component
|
||||
public class PreAuthorizeAspect {
|
||||
|
||||
@Autowired
|
||||
private InitAuthService initAuthService;
|
||||
|
||||
/**
|
||||
* 定义AOP签名 (切入所有使用鉴权注解的方法)
|
||||
*/
|
||||
public static final String POINTCUT_SIGN = " @annotation(com.ruoyi.common.security.annotation.RequiresLogin) || "
|
||||
+ "@annotation(com.ruoyi.common.security.annotation.RequiresPermissions) || "
|
||||
+ "@annotation(com.ruoyi.common.security.annotation.RequiresRoles)";
|
||||
+ "@annotation(com.ruoyi.common.security.annotation.RequiresRoles) ||"
|
||||
+ "@annotation(com.ruoyi.common.security.annotation.InitAuth)";
|
||||
|
||||
/**
|
||||
* 构建
|
||||
|
@ -52,13 +62,18 @@ public class PreAuthorizeAspect {
|
|||
*/
|
||||
@Around("pointcut()")
|
||||
public Object around (ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
HttpServletRequest httpServletRequest = ServletUtils.getRequest();
|
||||
String url=null;
|
||||
if(Objects.nonNull(httpServletRequest)){
|
||||
// 获取url
|
||||
url = httpServletRequest.getHeader("Init-Auth-Url");
|
||||
}
|
||||
// 注解鉴权
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod());
|
||||
checkMethodAnnotation(signature.getMethod(),url);
|
||||
try {
|
||||
// 执行原有逻辑
|
||||
Object obj = joinPoint.proceed();
|
||||
return obj;
|
||||
return joinPoint.proceed();
|
||||
} catch (Throwable e) {
|
||||
throw e;
|
||||
}
|
||||
|
@ -67,7 +82,22 @@ public class PreAuthorizeAspect {
|
|||
/**
|
||||
* 对一个Method对象进行注解检查
|
||||
*/
|
||||
public void checkMethodAnnotation (Method method) {
|
||||
public void checkMethodAnnotation (Method method,String url) {
|
||||
// 校验 @InitAuth 注解
|
||||
InitAuth initAuth = method.getAnnotation(InitAuth.class);
|
||||
// 有注解放行
|
||||
if (initAuth != null) {
|
||||
// 初始化访问权限
|
||||
initAuthService.init(initAuth.value());
|
||||
return;
|
||||
}
|
||||
// 有权限放行
|
||||
if(url!=null&& initAuthService.auth(url)){
|
||||
// 移除访问权限
|
||||
initAuthService.remove(url);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验 @RequiresLogin 注解
|
||||
RequiresLogin requiresLogin = method.getAnnotation(RequiresLogin.class);
|
||||
if (requiresLogin != null) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.ruoyi.common.core.utils.ip.IpUtils;
|
|||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -40,9 +39,11 @@ public class FeignRequestInterceptor implements RequestInterceptor {
|
|||
if (StringUtils.isNotEmpty(authentication)) {
|
||||
requestTemplate.header(SecurityConstants.AUTHORIZATION_HEADER, authentication);
|
||||
}
|
||||
|
||||
// 配置客户端IP
|
||||
requestTemplate.header("X-Forwarded-For", IpUtils.getIpAddr());
|
||||
}
|
||||
// 配置请求路径
|
||||
String url = requestTemplate.feignTarget().url()+requestTemplate.url().split("\\?")[0];
|
||||
requestTemplate.header("Init-Auth-Url",url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.ruoyi.common.security.service;
|
||||
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 初始化认证服务
|
||||
* @ClassName InitAuthService
|
||||
* @Author GuanTieLin
|
||||
* @Date 2024/5/15 12:44
|
||||
*/
|
||||
@Component
|
||||
public class InitAuthService {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private final String PREFIX="init-auth:";
|
||||
|
||||
/**
|
||||
* 初始化权限3分钟
|
||||
*/
|
||||
public void init(String url){
|
||||
redisService.setCacheObject(PREFIX+url,"",3L,TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证权限
|
||||
*/
|
||||
public boolean auth(String url){
|
||||
return redisService.hasKey(PREFIX + url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除权限
|
||||
*/
|
||||
public void remove(String url){
|
||||
if(redisService.hasKey(PREFIX + url)){
|
||||
redisService.deleteObject(PREFIX + url);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
com.ruoyi.common.security.config.WebMvcConfig
|
||||
com.ruoyi.common.security.service.TokenService
|
||||
com.ruoyi.common.security.service.InitAuthService
|
||||
com.ruoyi.common.security.aspect.PreAuthorizeAspect
|
||||
com.ruoyi.common.security.aspect.InnerAuthAspect
|
||||
com.ruoyi.common.security.handler.GlobalExceptionHandler
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<description>
|
||||
muyu-common通用模块
|
||||
ruoyi-common通用模块
|
||||
</description>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -11,7 +11,7 @@
|
|||
<artifactId>ruoyi-gateway</artifactId>
|
||||
|
||||
<description>
|
||||
muyu-gateway网关模块
|
||||
ruoyi-gateway网关模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -88,6 +88,19 @@
|
|||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Sleuth -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Zipkin -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zipkin</artifactId>
|
||||
<version>2.2.8.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
* @author muyu
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class MuYuGatewayApplication {
|
||||
public class GtlGatewayApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(MuYuGatewayApplication.class, args);
|
||||
SpringApplication.run(GtlGatewayApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -14,11 +14,11 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 47.98.98.250:8848
|
||||
server-addr: 139.224.220.40:8848
|
||||
namespace: 143f1a53-e544-4782-8667-877c532e2c66
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 47.98.98.250:8848
|
||||
server-addr: 139.224.220.40:8848
|
||||
namespace: 143f1a53-e544-4782-8667-877c532e2c66
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
|
@ -41,3 +41,11 @@ spring:
|
|||
groupId: DEFAULT_GROUP
|
||||
data-type: json
|
||||
rule-type: gw-flow
|
||||
#配置zipkin
|
||||
zipkin:
|
||||
base-url: http://127.0.0.1:9411
|
||||
# 不要让nacos把zipkin注册进去(可以不写)
|
||||
discovery-client-enabled: false
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1.0
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<artifactId>gtl-ruoyi-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -13,13 +13,16 @@
|
|||
<module>ruoyi-gen</module>
|
||||
<module>ruoyi-job</module>
|
||||
<module>ruoyi-file</module>
|
||||
<module>ruoyi-data_asset</module>
|
||||
<module>ruoyi-rule_engine</module>
|
||||
<module>ruoyi-data_transform</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>
|
||||
muyu-modules业务模块
|
||||
ruoyi-modules业务模块
|
||||
</description>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-data_asset</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<description>
|
||||
ruoyi-data_asset 数据资产模块
|
||||
</description>
|
||||
<modules>
|
||||
<module>ruoyi-data_asset-common</module>
|
||||
<module>ruoyi-data_asset-remote</module>
|
||||
<module>ruoyi-data_asset-server</module>
|
||||
<module>ruoyi-data_asset-client</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-data_asset-client</artifactId>
|
||||
<description>ruoyi-data_asset-client数据资产客户端模块</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceQueryReq;
|
||||
import com.ruoyi.dataAsset.remote.RemoteDataAssetService;
|
||||
import com.ruoyi.dataAsset.service.ConnectionPoolService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据资产应用程序运行程序
|
||||
* @ClassName DataAssetApplicationRunner
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/8 20:41
|
||||
*/
|
||||
@Log4j2
|
||||
public class DataAssetApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private RemoteDataAssetService remoteDataAssetService;
|
||||
|
||||
@Autowired
|
||||
private ConnectionPoolService connectionPoolService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
Result<TableDataInfo<DataSource>> result = remoteDataAssetService.list(new DataSourceQueryReq());
|
||||
if(Result.isSuccess(result)){
|
||||
// 过滤无效数据
|
||||
List<DataSource> dataSourceList = result.getData().getRows()
|
||||
.stream().filter(dataSource -> dataSource.getStatus().equals("Y")).toList();
|
||||
// 初始化连接池
|
||||
connectionPoolService.init(dataSourceList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 数据资产客户端配置
|
||||
* @ClassName DataAssetClientConfig
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/8 20:30
|
||||
*/
|
||||
@ComponentScan
|
||||
@Import(DataAssetApplicationRunner.class)
|
||||
public class DataAssetClientConfig {
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.ruoyi.dataAsset.context;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 数据库连接池上下文
|
||||
* @ClassName ConnectionPoolContextHolder
|
||||
* @Author GuanTieLin
|
||||
* @Date 2024/5/15 16:14
|
||||
*/
|
||||
@Component
|
||||
public class ConnectionPoolContextHolder {
|
||||
|
||||
/**
|
||||
* 存储容器
|
||||
*/
|
||||
private final Map<Long, DruidDataSource> druidDataSourceMap=new ConcurrentHashMap<>(16);
|
||||
|
||||
/**
|
||||
* 将数据源存入上下文中
|
||||
*/
|
||||
public void put(Long id,DruidDataSource druidDataSource){
|
||||
this.druidDataSourceMap.put(id,druidDataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过键获取数据源
|
||||
*/
|
||||
public DruidDataSource get(Long id){
|
||||
return this.druidDataSourceMap.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断key是否存在
|
||||
*/
|
||||
public boolean hasKey(Long id){
|
||||
return this.druidDataSourceMap.containsKey(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据源
|
||||
*/
|
||||
public void remove(Long id){
|
||||
this.druidDataSourceMap.remove(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.ruoyi.dataAsset.context.ConnectionPoolContextHolder;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.util.DataSourceUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库连接池服务
|
||||
* @ClassName ConnectionPoolService
|
||||
* @Author GuanTieLin
|
||||
* @Date 2024/5/15 16:25
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
public class ConnectionPoolService {
|
||||
|
||||
@Autowired
|
||||
private ConnectionPoolContextHolder connectionPoolContextHolder;
|
||||
|
||||
/**
|
||||
* 初始化连接池
|
||||
* @param dataSourceList 数据源集合
|
||||
*/
|
||||
public void init(List<DataSource> dataSourceList){
|
||||
for (DataSource dataSource : dataSourceList) {
|
||||
try {
|
||||
this.put(dataSource);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据源
|
||||
* @param dataSource 数据源
|
||||
* @return druid数据源
|
||||
*/
|
||||
public DruidDataSource createDataSource(DataSource dataSource) {
|
||||
try (Connection connection = DataSourceUtil.getConnection(dataSource)) {
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return DataSourceUtil.createDataSource(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭数据源
|
||||
* @param id 数据源编号
|
||||
*/
|
||||
public void closeDataSource(Long id){
|
||||
// 判断键是否存在
|
||||
if(hasKey(id)){
|
||||
// 获取数据源
|
||||
DruidDataSource druidDataSource = connectionPoolContextHolder.get(id);
|
||||
// 关闭数据源
|
||||
try {
|
||||
druidDataSource.close();
|
||||
} catch (Exception e) {
|
||||
log.error("关闭数据源key:{}失败",id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据源
|
||||
* @param id 数据源编号
|
||||
*/
|
||||
public void remove(Long id){
|
||||
// 判断键是否存在
|
||||
if(hasKey(id)){
|
||||
// 关闭
|
||||
this.closeDataSource(id);
|
||||
// 删除
|
||||
connectionPoolContextHolder.remove(id);
|
||||
}else {
|
||||
log.error("数据库连接池中不存在key:[{}]",id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建并添加数据源
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
public void put(DataSource dataSource){
|
||||
connectionPoolContextHolder.put(dataSource.getId(), createDataSource(dataSource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库连接
|
||||
* @param id 数据源编号
|
||||
* @return druid数据库连接
|
||||
* @throws SQLException sql异常
|
||||
*/
|
||||
public DruidPooledConnection getConnection(Long id) throws SQLException {
|
||||
DruidPooledConnection druidPooledConnection=null;
|
||||
// 判断键是否存在
|
||||
if(hasKey(id)){
|
||||
// 获取数据源
|
||||
DruidDataSource druidDataSource = connectionPoolContextHolder.get(id);
|
||||
// 获取链接
|
||||
druidPooledConnection=druidDataSource.getConnection();
|
||||
}else {
|
||||
log.error("数据库连接池中不存在key:[{}]",id);
|
||||
}
|
||||
return druidPooledConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断key是否存在
|
||||
* @param id 数据源编号
|
||||
* @return 是否
|
||||
*/
|
||||
public boolean hasKey(Long id){
|
||||
return connectionPoolContextHolder.hasKey(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.ruoyi.dataAsset.util;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 数据源工具类
|
||||
* @ClassName DataSourceUtil
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/10 14:37
|
||||
*/
|
||||
public class DataSourceUtil {
|
||||
|
||||
/**
|
||||
* 确认驱动类型
|
||||
* @param databaseType 数据库类型名
|
||||
* @return 驱动全类名
|
||||
*/
|
||||
public static String confirmDriverType(String databaseType){
|
||||
String driverType=null;
|
||||
if(databaseType.contains("mysql")){
|
||||
driverType="com.mysql.cj.jdbc.Driver";
|
||||
}else if(databaseType.contains("sqlserver")){
|
||||
driverType="com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
}
|
||||
return driverType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认驱动类型
|
||||
* @param dataSource 数据源
|
||||
* @return 驱动全类名
|
||||
*/
|
||||
public static String confirmUrl(DataSource dataSource){
|
||||
StringBuilder url= new StringBuilder("jdbc:" + dataSource.getDatabaseType() + dataSource.getIp() + ":" + dataSource.getPort());
|
||||
String databaseType = dataSource.getDatabaseType();
|
||||
if(databaseType.contains("mysql")){
|
||||
url.append("/").append(dataSource.getDatabases());
|
||||
if(StringUtils.isNotEmpty(dataSource.getConnectionParameter())){
|
||||
url.append("?").append(dataSource.getConnectionParameter());
|
||||
}
|
||||
}else if(databaseType.contains("sqlserver")){
|
||||
url.append(";DatabaseName=").append(dataSource.getDatabases()).append(";");
|
||||
if(StringUtils.isNotEmpty(dataSource.getConnectionParameter())){
|
||||
String[] params = dataSource.getConnectionParameter().split("&");
|
||||
for (String param : params) {
|
||||
url.append(param).append(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* druid数据库连接池连接失败的情况下问题较多,需要先用JDBC测试一下可用性
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
public static Connection getConnection(DataSource dataSource) throws SQLException {
|
||||
//设置驱动
|
||||
try {
|
||||
Class.forName(confirmDriverType(dataSource.getDatabaseType()));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//设置连接超时
|
||||
DriverManager.setLoginTimeout(3);
|
||||
//获取连接
|
||||
return DriverManager.getConnection(confirmUrl(dataSource), dataSource.getUsername(), dataSource.getPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Druid连接池数据源
|
||||
* @param dataSource 数据源
|
||||
* @return Druid数据源
|
||||
*/
|
||||
public static DruidDataSource createDataSource(DataSource dataSource) {
|
||||
//手动创建数据源
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
druidDataSource.setName(dataSource.getId().toString());
|
||||
druidDataSource.setDriverClassName(confirmDriverType(dataSource.getDatabaseType()));
|
||||
druidDataSource.setUrl(confirmUrl(dataSource));
|
||||
druidDataSource.setUsername(dataSource.getUsername());
|
||||
druidDataSource.setPassword(dataSource.getPassword());
|
||||
//设置连接配置
|
||||
if(StringUtils.isNotEmpty(dataSource.getConnectionConfig())){
|
||||
String[] configs = dataSource.getConnectionConfig().split(",");
|
||||
for (String config : configs) {
|
||||
String[] split = config.split("=");
|
||||
if(config.contains("initNum")){
|
||||
//初始化连接池大小
|
||||
druidDataSource.setInitialSize(split.length>1&&!split[1].equals("null")&&StringUtils.isNotEmpty(split[1])? Convert.toInt(split[1]):5);
|
||||
}else if(config.contains("maxNum")){
|
||||
//最大连接数
|
||||
druidDataSource.setMaxActive(split.length>1&&!split[1].equals("null")&&StringUtils.isNotEmpty(split[1])?Convert.toInt(split[1]):20);
|
||||
}else if(config.contains("minIdle")){
|
||||
//最小空闲数
|
||||
druidDataSource.setMinIdle(split.length>1&&!split[1].equals("null")&&StringUtils.isNotEmpty(split[1])?Convert.toInt(split[1]):5);
|
||||
}else {
|
||||
//获取连接最大等待时间,单位毫秒
|
||||
druidDataSource.setMaxWait(split.length>1&&!split[1].equals("null")&&StringUtils.isNotEmpty(split[1])?Convert.toInt(split[1]):4000);
|
||||
}
|
||||
}
|
||||
}
|
||||
String validationQuery = "select 1";
|
||||
//申请连接时执行validationQuery检测连接是否有效,防止取到的连接不可用
|
||||
druidDataSource.setTestOnBorrow(true);
|
||||
druidDataSource.setValidationQuery(validationQuery);
|
||||
//防止DruidDataSource一直尝试获取连接,导致服务卡死
|
||||
druidDataSource.setConnectionErrorRetryAttempts(0);
|
||||
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||
//设置连接超时时间
|
||||
druidDataSource.setConnectTimeout(2000);
|
||||
try {
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
com.ruoyi.dataAsset.config.DataAssetClientConfig
|
||||
com.ruoyi.dataAsset.context.ConnectionPoolContextHolder
|
||||
com.ruoyi.dataAsset.service.ConnectionPoolService
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-data_asset-common</artifactId>
|
||||
<description>
|
||||
ruoyi-data_asset-common 数据资产公共模块
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- MuYu Common Core-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- 阿里 druid 数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.20</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.dataAsset.constant;
|
||||
|
||||
/**
|
||||
* 消息队列常量
|
||||
* @ClassName QueueConstants
|
||||
* @Author 森静若林
|
||||
*/
|
||||
public class QueueConstants {
|
||||
|
||||
//新增队列
|
||||
public static final String INSERT_QUEUE="insert";
|
||||
|
||||
//删除队列
|
||||
public static final String DELETE_QUEUE="delete";
|
||||
|
||||
//新增消息队列名称
|
||||
public static final String DATASOURCE_INSERT_MESSAGE = "datasource_insert_message";
|
||||
|
||||
//删除消息队列名称
|
||||
public static final String DATASOURCE_DELETE_MESSAGE = "datasource_delete_message";
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.dataAsset.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.AssetAuthInfoSaveReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("asset_auth_info")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "AssetAuthInfo", description = "资产授权")
|
||||
public class AssetAuthInfo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 授权编号 */
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号", required = true)
|
||||
private Long authId;
|
||||
|
||||
/** 编号类型 dept/user */
|
||||
@ApiModelProperty(name = "编号类型 dept/user", value = "编号类型 dept/user", required = true)
|
||||
private String idType;
|
||||
|
||||
/** 授权数据 */
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据", required = true)
|
||||
private String authData;
|
||||
|
||||
/** 授权类型 datasource/database/table */
|
||||
@ApiModelProperty(name = "授权类型 datasource/database/table", value = "授权类型 datasource/database/table", required = true)
|
||||
private String authType;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static AssetAuthInfo queryBuild( AssetAuthInfoQueryReq assetAuthInfoQueryReq){
|
||||
return AssetAuthInfo.builder()
|
||||
.authId(assetAuthInfoQueryReq.getAuthId())
|
||||
.idType(assetAuthInfoQueryReq.getIdType())
|
||||
.authData(assetAuthInfoQueryReq.getAuthData())
|
||||
.authType(assetAuthInfoQueryReq.getAuthType())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static AssetAuthInfo saveBuild(AssetAuthInfoSaveReq assetAuthInfoSaveReq,Supplier<String> createBy){
|
||||
return AssetAuthInfo.builder()
|
||||
.authId(assetAuthInfoSaveReq.getAuthId())
|
||||
.idType(assetAuthInfoSaveReq.getIdType())
|
||||
.authData(assetAuthInfoSaveReq.getAuthData())
|
||||
.authType(assetAuthInfoSaveReq.getAuthType())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 资产模型数据
|
||||
* @ClassName AssetModuleData
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 21:16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AssetModelData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 唯一键 */
|
||||
@TableField("`key`")
|
||||
private String key;
|
||||
|
||||
/** 映射类型 */
|
||||
private String type;
|
||||
|
||||
/** 值 */
|
||||
private String value;
|
||||
|
||||
/** 表编号 */
|
||||
private Long tableId;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字段详情
|
||||
* @ClassName ColumnInfo
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 21:16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ColumnInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 字段名 */
|
||||
private String name;
|
||||
|
||||
/** 数据库类型 */
|
||||
private String type;
|
||||
|
||||
/** 映射类型 */
|
||||
private String javaType;
|
||||
|
||||
/** 是否主键 */
|
||||
private String isKey;
|
||||
|
||||
/** 长度 */
|
||||
private Integer length;
|
||||
|
||||
/** 小数位 */
|
||||
private String scale;
|
||||
|
||||
/** 是否为空 */
|
||||
private String isNullable;
|
||||
|
||||
/** 默认值 */
|
||||
private String defaultValue;
|
||||
|
||||
/** 注释 */
|
||||
private String comment;
|
||||
|
||||
/** 表编号 */
|
||||
private Long tableId;
|
||||
|
||||
/** 是否字典 */
|
||||
private String isDict;
|
||||
|
||||
/** 数据字典编号 */
|
||||
private Long dataDictType;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictDataSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictDataEditReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典数据对象 data_dict_data
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("data_dict_data")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "DataDictData", description = "字典数据")
|
||||
public class DataDictData extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典编码 */
|
||||
@TableId(value = "dict_code",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "字典编码", value = "字典编码")
|
||||
private Long dictCode;
|
||||
|
||||
/** 字典标签 */
|
||||
@Excel(name = "字典标签")
|
||||
@ApiModelProperty(name = "字典标签", value = "字典标签", required = true)
|
||||
private String dictLabel;
|
||||
|
||||
/** 字典键值 */
|
||||
@Excel(name = "字典键值")
|
||||
@ApiModelProperty(name = "字典键值", value = "字典键值", required = true)
|
||||
private String dictValue;
|
||||
|
||||
/** 字典类型编号 */
|
||||
@Excel(name = "字典类型编号")
|
||||
@ApiModelProperty(name = "字典类型编号", value = "字典类型编号", required = true)
|
||||
private Long dictTypeId;
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static DataDictData saveBuild(DataDictDataSaveReq dataDictDataSaveReq,Supplier<String> createBy){
|
||||
return DataDictData.builder()
|
||||
.dictLabel(dataDictDataSaveReq.getDictLabel())
|
||||
.dictValue(dataDictDataSaveReq.getDictValue())
|
||||
.dictTypeId(dataDictDataSaveReq.getDictTypeId())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static DataDictData editBuild(Long dictCode, DataDictDataEditReq dataDictDataEditReq, Supplier<String> updateBy){
|
||||
return DataDictData.builder()
|
||||
.dictCode(dictCode)
|
||||
.dictLabel(dataDictDataEditReq.getDictLabel())
|
||||
.dictValue(dataDictDataEditReq.getDictValue())
|
||||
.dictTypeId(dataDictDataEditReq.getDictTypeId())
|
||||
.updateBy(updateBy.get())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.dataAsset.domain.resp.DataDictResp;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictTypeSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictTypeEditReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 字典类型对象 data_dict_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("data_dict_type")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "DataDictType", description = "字典类型")
|
||||
public class DataDictType extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典主键 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "字典主键", value = "字典主键")
|
||||
private Long id;
|
||||
|
||||
/** 字典名称 */
|
||||
@Excel(name = "字典名称")
|
||||
@ApiModelProperty(name = "字典名称", value = "字典名称", required = true)
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
@Excel(name = "字典类型")
|
||||
@ApiModelProperty(name = "字典类型", value = "字典类型", required = true)
|
||||
private String dictType;
|
||||
|
||||
/** 数据源编号 */
|
||||
@Excel(name = "数据源编号")
|
||||
@ApiModelProperty(name = "数据源编号", value = "数据源编号", required = true)
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static DataDictType saveBuild(DataDictTypeSaveReq dataDictTypeSaveReq,Supplier<String> createBy){
|
||||
return DataDictType.builder()
|
||||
.dictName(dataDictTypeSaveReq.getDictName())
|
||||
.dictType(dataDictTypeSaveReq.getDictType())
|
||||
.dataSourceId(dataDictTypeSaveReq.getDataSourceId())
|
||||
.remark(dataDictTypeSaveReq.getRemark())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static DataDictType editBuild(Long id, DataDictTypeEditReq dataDictTypeEditReq, Supplier<String> updateBy){
|
||||
return DataDictType.builder()
|
||||
.id(id)
|
||||
.dictName(dataDictTypeEditReq.getDictName())
|
||||
.dictType(dataDictTypeEditReq.getDictType())
|
||||
.dataSourceId(dataDictTypeEditReq.getDataSourceId())
|
||||
.remark(dataDictTypeEditReq.getRemark())
|
||||
.updateBy(updateBy.get())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public DataDictResp toDataDictResp(List<DataDictData> list) {
|
||||
return DataDictResp.builder()
|
||||
.id(this.getId())
|
||||
.dictName(this.getDictName())
|
||||
.dictType(this.getDictType())
|
||||
.dataSourceId(this.getDataSourceId())
|
||||
.columnData(list)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceEditReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据接入对象 data_source
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("data_source")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "DataSource", description = "数据接入")
|
||||
public class DataSource extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 链接名 */
|
||||
@Excel(name = "链接名")
|
||||
@ApiModelProperty(name = "链接名", value = "链接名", required = true)
|
||||
private String dataSourceName;
|
||||
|
||||
/** 来源系统名称 */
|
||||
@Excel(name = "来源系统名称")
|
||||
@ApiModelProperty(name = "来源系统名称", value = "来源系统名称", required = true)
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 数据库类型 */
|
||||
@Excel(name = "数据库类型")
|
||||
@ApiModelProperty(name = "数据库类型", value = "数据库类型", required = true)
|
||||
private String databaseType;
|
||||
|
||||
/** ip地址 */
|
||||
@Excel(name = "ip地址")
|
||||
@ApiModelProperty(name = "ip地址", value = "ip地址", required = true)
|
||||
private String ip;
|
||||
|
||||
/** 端口号 */
|
||||
@Excel(name = "端口号")
|
||||
@ApiModelProperty(name = "端口号", value = "端口号", required = true)
|
||||
private String port;
|
||||
|
||||
/** 用户名 */
|
||||
@Excel(name = "用户名")
|
||||
@ApiModelProperty(name = "用户名", value = "用户名", required = true)
|
||||
private String username;
|
||||
|
||||
/** 密码 */
|
||||
@Excel(name = "密码")
|
||||
@ApiModelProperty(name = "密码", value = "密码", required = true)
|
||||
private String password;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
@ApiModelProperty(name = "类型", value = "类型", required = true)
|
||||
private String type;
|
||||
|
||||
/** 连接参数 */
|
||||
@Excel(name = "连接参数")
|
||||
@ApiModelProperty(name = "连接参数", value = "连接参数")
|
||||
private String connectionParameter;
|
||||
|
||||
/** 连接配置 */
|
||||
@Excel(name = "连接配置")
|
||||
@ApiModelProperty(name = "连接配置", value = "连接配置")
|
||||
private String connectionConfig;
|
||||
|
||||
/** 拥有的数据库 */
|
||||
@Excel(name = "拥有的数据库")
|
||||
@TableField("`databases`")
|
||||
@ApiModelProperty(name = "拥有的数据库", value = "拥有的数据库")
|
||||
private String databases;
|
||||
|
||||
/** 表的总数 */
|
||||
@Excel(name = "表的总数")
|
||||
@ApiModelProperty(name = "表的总数", value = "表的总数")
|
||||
private Integer tableTotal;
|
||||
|
||||
/** 记录总数 */
|
||||
@Excel(name = "记录总数")
|
||||
@ApiModelProperty(name = "记录总数", value = "记录总数")
|
||||
private Integer recordsTotal;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static DataSource queryBuild( DataSourceQueryReq dataSourceQueryReq){
|
||||
return DataSource.builder()
|
||||
.dataSourceName(dataSourceQueryReq.getDataSourceName())
|
||||
.dataSourceSystemName(dataSourceQueryReq.getDataSourceSystemName())
|
||||
.databaseType(dataSourceQueryReq.getDatabaseType())
|
||||
.ip(dataSourceQueryReq.getIp())
|
||||
.port(dataSourceQueryReq.getPort())
|
||||
.username(dataSourceQueryReq.getUsername())
|
||||
.password(dataSourceQueryReq.getPassword())
|
||||
.type(dataSourceQueryReq.getType())
|
||||
.connectionParameter(dataSourceQueryReq.getConnectionParameter())
|
||||
.connectionConfig(dataSourceQueryReq.getConnectionConfig())
|
||||
.status(dataSourceQueryReq.getStatus())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static DataSource saveBuild(DataSourceSaveReq dataSourceSaveReq,Supplier<String> createBy){
|
||||
return DataSource.builder()
|
||||
.dataSourceName(dataSourceSaveReq.getDataSourceName())
|
||||
.dataSourceSystemName(dataSourceSaveReq.getDataSourceSystemName())
|
||||
.databaseType(dataSourceSaveReq.getDatabaseType())
|
||||
.databases(dataSourceSaveReq.getDatabases())
|
||||
.ip(dataSourceSaveReq.getIp())
|
||||
.port(dataSourceSaveReq.getPort())
|
||||
.username(dataSourceSaveReq.getUsername())
|
||||
.password(dataSourceSaveReq.getPassword())
|
||||
.type(dataSourceSaveReq.getType())
|
||||
.connectionParameter(dataSourceSaveReq.getConnectionParameter())
|
||||
.connectionConfig(dataSourceSaveReq.getConnectionConfig())
|
||||
.status(dataSourceSaveReq.getStatus())
|
||||
.remark(dataSourceSaveReq.getRemark())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static DataSource editBuild(Long id, DataSourceEditReq dataSourceEditReq, Supplier<String> updateBy){
|
||||
return DataSource.builder()
|
||||
.id(id)
|
||||
.dataSourceName(dataSourceEditReq.getDataSourceName())
|
||||
.dataSourceSystemName(dataSourceEditReq.getDataSourceSystemName())
|
||||
.databaseType(dataSourceEditReq.getDatabaseType())
|
||||
.databases(dataSourceEditReq.getDatabases())
|
||||
.ip(dataSourceEditReq.getIp())
|
||||
.port(dataSourceEditReq.getPort())
|
||||
.username(dataSourceEditReq.getUsername())
|
||||
.password(dataSourceEditReq.getPassword())
|
||||
.type(dataSourceEditReq.getType())
|
||||
.connectionParameter(dataSourceEditReq.getConnectionParameter())
|
||||
.connectionConfig(dataSourceEditReq.getConnectionConfig())
|
||||
.status(dataSourceEditReq.getStatus())
|
||||
.remark(dataSourceEditReq.getRemark())
|
||||
.updateBy(updateBy.get())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeEditReq;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据库类型对象 database_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("database_type")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "DatabaseType", description = "数据库类型")
|
||||
public class DatabaseType extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
@ApiModelProperty(name = "名称", value = "名称")
|
||||
private String name;
|
||||
|
||||
/** 值 */
|
||||
@Excel(name = "值")
|
||||
@ApiModelProperty(name = "值", value = "值")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static DatabaseType queryBuild( DatabaseTypeQueryReq databaseTypeQueryReq){
|
||||
return DatabaseType.builder()
|
||||
.name(databaseTypeQueryReq.getName())
|
||||
.value(databaseTypeQueryReq.getValue())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static DatabaseType saveBuild(DatabaseTypeSaveReq databaseTypeSaveReq,Supplier<String> createBy){
|
||||
return DatabaseType.builder()
|
||||
.name(databaseTypeSaveReq.getName())
|
||||
.value(databaseTypeSaveReq.getValue())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static DatabaseType editBuild(Long id, DatabaseTypeEditReq databaseTypeEditReq, Supplier<String> updateBy){
|
||||
return DatabaseType.builder()
|
||||
.id(id)
|
||||
.name(databaseTypeEditReq.getName())
|
||||
.value(databaseTypeEditReq.getValue())
|
||||
.updateBy(updateBy.get())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.ruoyi.dataAsset.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.dataAsset.domain.resp.AssetStructureResp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表详情
|
||||
* @ClassName TableInfo
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 21:16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TableInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 表名 */
|
||||
private String name;
|
||||
|
||||
/** 表注释 */
|
||||
private String comment;
|
||||
|
||||
/** 记录总条数 */
|
||||
private Integer recordsTotal;
|
||||
|
||||
/** 数据源编号 */
|
||||
private Long dataSourceId;
|
||||
|
||||
public AssetStructureResp toAssetStructureResp(List<ColumnInfo> list) {
|
||||
return AssetStructureResp.builder()
|
||||
.id(this.getId())
|
||||
.name(this.getName())
|
||||
.comment(this.getComment())
|
||||
.recordsTotal(this.getRecordsTotal())
|
||||
.columnInfoList(list)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "AssetAuthInfoQueryReq", description = "资产授权")
|
||||
public class AssetAuthInfoQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 授权编号 */
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||
private Long authId;
|
||||
|
||||
/** 编号类型 dept/user */
|
||||
@ApiModelProperty(name = "编号类型 dept/user", value = "编号类型 dept/user")
|
||||
private String idType;
|
||||
|
||||
/** 授权数据 */
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据")
|
||||
private String authData;
|
||||
|
||||
/** 授权类型 datasource/database/table */
|
||||
@ApiModelProperty(name = "授权类型 datasource/database/table", value = "授权类型 datasource/database/table")
|
||||
private String authType;
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 资产授权对象 asset_auth_info
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "AssetAuthInfoSaveReq", description = "资产授权")
|
||||
public class AssetAuthInfoSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 授权编号 */
|
||||
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号", required = true)
|
||||
private Long authId;
|
||||
|
||||
/** 编号类型 dept/user */
|
||||
|
||||
@ApiModelProperty(name = "编号类型 dept/user", value = "编号类型 dept/user", required = true)
|
||||
private String idType;
|
||||
|
||||
/** 授权数据 */
|
||||
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据", required = true)
|
||||
private String authData;
|
||||
|
||||
/** 授权类型 datasource/database/table */
|
||||
|
||||
@ApiModelProperty(name = "授权类型 datasource/database/table", value = "授权类型 datasource/database/table", required = true)
|
||||
private String authType;
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字段详情
|
||||
* @ClassName ColumnInfoReq
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 21:16
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ColumnInfoReq implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
private Long id;
|
||||
|
||||
/** 是否字典 */
|
||||
private String isDict;
|
||||
|
||||
/** 数据字典编号 */
|
||||
private Long dataDictType;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 字典数据对象 data_dict_data
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataDictDataEditReq", description = "字典数据")
|
||||
public class DataDictDataEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典标签 */
|
||||
@ApiModelProperty(name = "字典标签", value = "字典标签", required = true)
|
||||
private String dictLabel;
|
||||
|
||||
/** 字典键值 */
|
||||
@ApiModelProperty(name = "字典键值", value = "字典键值", required = true)
|
||||
private String dictValue;
|
||||
|
||||
/** 字典类型编号 */
|
||||
@ApiModelProperty(name = "字典类型编号", value = "字典类型编号", required = true)
|
||||
private Long dictTypeId;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 字典数据对象 data_dict_data
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataDictDataSaveReq", description = "字典数据")
|
||||
public class DataDictDataSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典编码 */
|
||||
|
||||
@ApiModelProperty(name = "字典编码", value = "字典编码")
|
||||
private Long dictCode;
|
||||
|
||||
/** 字典标签 */
|
||||
|
||||
@ApiModelProperty(name = "字典标签", value = "字典标签", required = true)
|
||||
private String dictLabel;
|
||||
|
||||
/** 字典键值 */
|
||||
|
||||
@ApiModelProperty(name = "字典键值", value = "字典键值", required = true)
|
||||
private String dictValue;
|
||||
|
||||
/** 字典类型编号 */
|
||||
|
||||
@ApiModelProperty(name = "字典类型编号", value = "字典类型编号", required = true)
|
||||
private Long dictTypeId;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 字典类型对象 data_dict_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataDictTypeEditReq", description = "字典类型")
|
||||
public class DataDictTypeEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典名称 */
|
||||
@ApiModelProperty(name = "字典名称", value = "字典名称", required = true)
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
@ApiModelProperty(name = "字典类型", value = "字典类型", required = true)
|
||||
private String dictType;
|
||||
|
||||
/** 数据源编号 */
|
||||
@ApiModelProperty(name = "数据源编号", value = "数据源编号", required = true)
|
||||
private Long dataSourceId;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 字典类型对象 data_dict_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataDictTypeSaveReq", description = "字典类型")
|
||||
public class DataDictTypeSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典主键 */
|
||||
|
||||
@ApiModelProperty(name = "字典主键", value = "字典主键")
|
||||
private Long id;
|
||||
|
||||
/** 字典名称 */
|
||||
|
||||
@ApiModelProperty(name = "字典名称", value = "字典名称", required = true)
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
|
||||
@ApiModelProperty(name = "字典类型", value = "字典类型", required = true)
|
||||
private String dictType;
|
||||
|
||||
/** 数据源编号 */
|
||||
|
||||
@ApiModelProperty(name = "数据源编号", value = "数据源编号", required = true)
|
||||
private Long dataSourceId;
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据接入对象 data_source
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceEditReq", description = "数据接入")
|
||||
public class DataSourceEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 链接名 */
|
||||
@ApiModelProperty(name = "链接名", value = "链接名", required = true)
|
||||
private String dataSourceName;
|
||||
|
||||
/** 数据库来源系统名称 */
|
||||
@ApiModelProperty(name = "数据库来源系统名称", value = "数据库来源系统名称", required = true)
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 数据库类型 */
|
||||
@ApiModelProperty(name = "数据库类型", value = "数据库类型", required = true)
|
||||
private String databaseType;
|
||||
|
||||
/** 数据库名称 */
|
||||
@ApiModelProperty(name = "数据库名称", value = "数据库名称", required = true)
|
||||
private String databases;
|
||||
|
||||
/** ip地址 */
|
||||
@ApiModelProperty(name = "ip地址", value = "ip地址", required = true)
|
||||
private String ip;
|
||||
|
||||
/** 端口号 */
|
||||
@ApiModelProperty(name = "端口号", value = "端口号", required = true)
|
||||
private String port;
|
||||
|
||||
/** 用户名 */
|
||||
@ApiModelProperty(name = "用户名", value = "用户名", required = true)
|
||||
private String username;
|
||||
|
||||
/** 密码 */
|
||||
@ApiModelProperty(name = "密码", value = "密码", required = true)
|
||||
private String password;
|
||||
|
||||
/** 类型 */
|
||||
@ApiModelProperty(name = "类型", value = "类型", required = true)
|
||||
private String type;
|
||||
|
||||
/** 连接参数 */
|
||||
@ApiModelProperty(name = "连接参数", value = "连接参数")
|
||||
private String connectionParameter;
|
||||
|
||||
/** 连接配置 */
|
||||
@ApiModelProperty(name = "连接配置", value = "连接配置")
|
||||
private String connectionConfig;
|
||||
|
||||
/** 状态 */
|
||||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据接入对象 data_source
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceQueryReq", description = "数据接入")
|
||||
public class DataSourceQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 链接名 */
|
||||
@ApiModelProperty(name = "链接名", value = "链接名")
|
||||
private String dataSourceName;
|
||||
|
||||
/** 数据库来源系统名称 */
|
||||
@ApiModelProperty(name = "数据库来源系统名称", value = "数据库来源系统名称")
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 数据库类型 */
|
||||
@ApiModelProperty(name = "数据库类型", value = "数据库类型")
|
||||
private String databaseType;
|
||||
|
||||
/** ip地址 */
|
||||
@ApiModelProperty(name = "ip地址", value = "ip地址")
|
||||
private String ip;
|
||||
|
||||
/** 端口号 */
|
||||
@ApiModelProperty(name = "端口号", value = "端口号")
|
||||
private String port;
|
||||
|
||||
/** 用户名 */
|
||||
@ApiModelProperty(name = "用户名", value = "用户名")
|
||||
private String username;
|
||||
|
||||
/** 密码 */
|
||||
@ApiModelProperty(name = "密码", value = "密码")
|
||||
private String password;
|
||||
|
||||
/** 类型 */
|
||||
@ApiModelProperty(name = "类型", value = "类型")
|
||||
private String type;
|
||||
|
||||
/** 连接参数 */
|
||||
@ApiModelProperty(name = "连接参数", value = "连接参数")
|
||||
private String connectionParameter;
|
||||
|
||||
/** 连接配置 */
|
||||
@ApiModelProperty(name = "连接配置", value = "连接配置")
|
||||
private String connectionConfig;
|
||||
|
||||
/** 状态 */
|
||||
@ApiModelProperty(name = "状态", value = "状态")
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据接入对象 data_source
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceSaveReq", description = "数据接入")
|
||||
public class DataSourceSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 链接名 */
|
||||
|
||||
@ApiModelProperty(name = "链接名", value = "链接名", required = true)
|
||||
private String dataSourceName;
|
||||
|
||||
/** 来源系统名称 */
|
||||
|
||||
@ApiModelProperty(name = "来源系统名称", value = "来源系统名称", required = true)
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 数据库类型 */
|
||||
|
||||
@ApiModelProperty(name = "数据库类型", value = "数据库类型", required = true)
|
||||
private String databaseType;
|
||||
|
||||
/** 数据库名称 */
|
||||
|
||||
@ApiModelProperty(name = "数据库名称", value = "数据库名称", required = true)
|
||||
private String databases;
|
||||
|
||||
/** ip地址 */
|
||||
|
||||
@ApiModelProperty(name = "ip地址", value = "ip地址", required = true)
|
||||
private String ip;
|
||||
|
||||
/** 端口号 */
|
||||
|
||||
@ApiModelProperty(name = "端口号", value = "端口号", required = true)
|
||||
private String port;
|
||||
|
||||
/** 用户名 */
|
||||
|
||||
@ApiModelProperty(name = "用户名", value = "用户名", required = true)
|
||||
private String username;
|
||||
|
||||
/** 密码 */
|
||||
|
||||
@ApiModelProperty(name = "密码", value = "密码", required = true)
|
||||
private String password;
|
||||
|
||||
/** 类型 */
|
||||
|
||||
@ApiModelProperty(name = "类型", value = "类型", required = true)
|
||||
private String type;
|
||||
|
||||
/** 连接参数 */
|
||||
|
||||
@ApiModelProperty(name = "连接参数", value = "连接参数")
|
||||
private String connectionParameter;
|
||||
|
||||
/** 连接配置 */
|
||||
|
||||
@ApiModelProperty(name = "连接配置", value = "连接配置")
|
||||
private String connectionConfig;
|
||||
|
||||
/** 状态 'Y'/'N' */
|
||||
|
||||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据库类型对象 database_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DatabaseTypeEditReq", description = "数据库类型")
|
||||
public class DatabaseTypeEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 名称 */
|
||||
@ApiModelProperty(name = "名称", value = "名称")
|
||||
private String name;
|
||||
|
||||
/** 值 */
|
||||
@ApiModelProperty(name = "值", value = "值")
|
||||
private String value;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据库类型对象 database_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DatabaseTypeQueryReq", description = "数据库类型")
|
||||
public class DatabaseTypeQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 名称 */
|
||||
@ApiModelProperty(name = "名称", value = "名称")
|
||||
private String name;
|
||||
|
||||
/** 值 */
|
||||
@ApiModelProperty(name = "值", value = "值")
|
||||
private String value;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ruoyi.dataAsset.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据库类型对象 database_type
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DatabaseTypeSaveReq", description = "数据库类型")
|
||||
public class DatabaseTypeSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 名称 */
|
||||
|
||||
@ApiModelProperty(name = "名称", value = "名称")
|
||||
private String name;
|
||||
|
||||
/** 值 */
|
||||
|
||||
@ApiModelProperty(name = "值", value = "值")
|
||||
private String value;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ruoyi.dataAsset.domain.resp;
|
||||
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产结构对象 AssetStructureResp
|
||||
* @ClassName AssetStructureResp
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 11:05
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "AssetStructureResp", description = "资产结构")
|
||||
public class AssetStructureResp {
|
||||
|
||||
/** 编号 */
|
||||
private Long id;
|
||||
|
||||
/** 表名 */
|
||||
private String name;
|
||||
|
||||
/** 表注释 */
|
||||
private String comment;
|
||||
|
||||
/** 记录总条数 */
|
||||
private Integer recordsTotal;
|
||||
|
||||
/** 字段数据集合 */
|
||||
private List<ColumnInfo> columnInfoList;
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.ruoyi.dataAsset.domain.resp;
|
||||
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典类型对象 DataDictResp
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataDictResp", description = "字典类型")
|
||||
public class DataDictResp implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典主键 */
|
||||
private Long id;
|
||||
|
||||
/** 字典名称 */
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
private String dictType;
|
||||
|
||||
/** 数据源编号 */
|
||||
private Long dataSourceId;
|
||||
|
||||
/** 字段数据 */
|
||||
private List<DataDictData> columnData;
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-data_asset-remote</artifactId>
|
||||
<description>
|
||||
ruoyi-data_asset-remote 数据资产远调模块
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 数据资产公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- MuYu 公共 安全模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
package com.ruoyi.dataAsset.remote;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.annotation.InitAuth;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceQueryReq;
|
||||
import com.ruoyi.dataAsset.remote.factory.RemoteDataAssetFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 数据资产远程调用业务层
|
||||
* @ClassName RemoteDataAssetService
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/7 13:54
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteDataAssetService",
|
||||
value = ServiceNameConstants.DATA_ACCESS_SERVICE,
|
||||
fallbackFactory = RemoteDataAssetFactory.class,
|
||||
path = "/source"
|
||||
)
|
||||
public interface RemoteDataAssetService {
|
||||
/**
|
||||
* 查询数据接入列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@InitAuth("http://ruoyi-data-asset/source/list")
|
||||
public Result<TableDataInfo<DataSource>> list(@RequestParam("dataSourceQueryReq") DataSourceQueryReq dataSourceQueryReq);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.dataAsset.remote.factory;
|
||||
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceQueryReq;
|
||||
import com.ruoyi.dataAsset.remote.RemoteDataAssetService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
/**
|
||||
* 数据资产远程调用熔断器
|
||||
* @ClassName RemoteDataAssetFactory
|
||||
* @Author 森静若林
|
||||
* @Date 2024/5/7 11:59
|
||||
*/
|
||||
public class RemoteDataAssetFactory implements FallbackFactory<RemoteDataAssetService> {
|
||||
@Override
|
||||
public RemoteDataAssetService create(Throwable cause) {
|
||||
return new RemoteDataAssetService() {
|
||||
|
||||
@Override
|
||||
public Result<TableDataInfo<DataSource>> list(DataSourceQueryReq dataSourceQueryReq) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.ruoyi.dataAsset.remote.factory.RemoteDataAssetFactory
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-data_asset-server</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<description>
|
||||
muyu-data_asset-server 数据资产服务模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- ruoyi-data_asset-common 数据资产公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-data_asset-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- ruoyi-data_asset-client 数据资产客户端模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-data_asset-client</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sql Server 驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<version>9.4.0.jre8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- rabbitMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.dataAsset;
|
||||
|
||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||
import com.ruoyi.common.security.annotation.EnableMyFeignClients;
|
||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* data_asset服务模块
|
||||
*
|
||||
* @author gtl
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class GtlDataAssetApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GtlDataAssetApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 消息发送到 broker 的确认
|
||||
* @ClassName: ConfirmFallbackConfig
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/1/15
|
||||
*/
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
public class ConfirmFallbackConfig implements RabbitTemplate.ConfirmCallback {
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* ConfirmFallbackConfig 初始化的时候执行 设置 rabbitTemplate 发送的回调是 当前类 对象
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.rabbitTemplate.setConfirmCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送到 broker的回调方法 消息发送成功或者失败都会执行这个方法
|
||||
* @param correlationData correlation data for the callback.
|
||||
* @param ack true for ack, false for nack
|
||||
* @param cause An optional cause, for nack, when available, otherwise null.
|
||||
*/
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
if (ack) {
|
||||
// 消息发送成功
|
||||
log.info("消息发送成功");
|
||||
} else {
|
||||
// 消息发送是吧
|
||||
log.info("消息发送失败,错误原因:{}", cause);
|
||||
// 获取到发送失败消息的内容
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* RabbitAdmin是RabbitMQ的一个Java客户端库,它提供了管理RabbitMQ资源的功能。它是通过与RabbitMQ服务器进行交互来执行管理操作的。
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitAdminConfig {
|
||||
|
||||
@Value("${spring.rabbitmq.host}")
|
||||
private String host;
|
||||
@Value("${spring.rabbitmq.username}")
|
||||
private String username;
|
||||
@Value("${spring.rabbitmq.password}")
|
||||
private String password;
|
||||
@Value("${spring.rabbitmq.virtualhost}")
|
||||
private String virtualhost;
|
||||
|
||||
/**
|
||||
* 构建 RabbitMQ的连接工厂
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ConnectionFactory connectionFactory() {
|
||||
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
|
||||
connectionFactory.setAddresses(host);
|
||||
connectionFactory.setUsername(username);
|
||||
connectionFactory.setPassword(password);
|
||||
connectionFactory.setVirtualHost(virtualhost);
|
||||
// 配置发送确认回调时,次配置必须配置,否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
|
||||
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
|
||||
connectionFactory.setPublisherReturns(true);
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自己初始化 RabbitAdmin
|
||||
* @param connectionFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
|
||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
||||
rabbitAdmin.setAutoStartup(true);
|
||||
return rabbitAdmin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitmqConfig {
|
||||
// 消息转换配置
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter(){
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.ruoyi.dataAsset.config;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.ReturnedMessage;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 消息发送打 队列的回调
|
||||
* @ClassName: ConfirmFallbackConfig
|
||||
* @Author: 森静若林
|
||||
* @Date: 2024/1/15
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
public class ReturnsFallbackConfig implements RabbitTemplate.ReturnsCallback {
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 设置 rabbitTemplate 发送消息到 队列的 回调 使用 ReturnsFallbackConfig
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.rabbitTemplate.setReturnsCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送到队列失败的回调
|
||||
* @param returned the returned message and metadata.
|
||||
*/
|
||||
@Override
|
||||
public void returnedMessage(ReturnedMessage returned) {
|
||||
log.info("消息内容:{},被交换机:{}退回,退回的原因:{}",
|
||||
returned.getMessage().toString(), returned.getExchange(), returned.getReplyText());
|
||||
// TODO 将发送到队列失败的消息 存入到 mysql | redis 后续可以进行补救 或者 先关处理
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.*;
|
||||
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.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.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.AssetAuthInfo;
|
||||
import com.ruoyi.dataAsset.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.AssetAuthInfoSaveReq;
|
||||
import com.ruoyi.dataAsset.service.AssetAuthInfoService;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 资产授权Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Api(tags = "资产授权")
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AssetAuthInfoController extends BaseController {
|
||||
@Autowired
|
||||
private AssetAuthInfoService assetAuthInfoService;
|
||||
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*/
|
||||
@ApiOperation("获取资产授权列表")
|
||||
@RequiresPermissions("dataAsset:auth:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<AssetAuthInfo>> list(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||
startPage();
|
||||
List<AssetAuthInfo> list = assetAuthInfoService.list(AssetAuthInfo.queryBuild(assetAuthInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增资产授权
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:auth:add")
|
||||
@Log(title = "资产授权", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增资产授权")
|
||||
public Result<String> add(@RequestBody AssetAuthInfoSaveReq assetAuthInfoSaveReq) {
|
||||
return toAjax(assetAuthInfoService.save(AssetAuthInfo.saveBuild(assetAuthInfoSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除资产授权
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:auth:remove")
|
||||
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除资产授权")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(assetAuthInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.AssetModelData;
|
||||
import com.ruoyi.dataAsset.service.AssetModelDataService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产数据展示Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Api(tags = "资产数据模型")
|
||||
@RestController
|
||||
@RequestMapping("/model")
|
||||
public class AssetModelDataController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private AssetModelDataService assetModelDataService;
|
||||
|
||||
/**
|
||||
* 查询资产模型数据列表
|
||||
*/
|
||||
@ApiOperation("查询资产模型数据列表")
|
||||
@RequiresPermissions("dataAsset:model:query")
|
||||
@GetMapping("/getAssetModelData/{tableId}")
|
||||
public Result<List<AssetModelData>> list(@PathVariable Long tableId) {
|
||||
return Result.success(assetModelDataService.list(tableId));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
import com.ruoyi.dataAsset.domain.req.ColumnInfoReq;
|
||||
import com.ruoyi.dataAsset.domain.resp.AssetStructureResp;
|
||||
import com.ruoyi.dataAsset.service.AssetStructureService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产结构Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Api(tags = "资产结构")
|
||||
@RestController
|
||||
@RequestMapping("/structure")
|
||||
public class AssetStructureController{
|
||||
|
||||
@Autowired
|
||||
private AssetStructureService assetStructureService;
|
||||
|
||||
/**
|
||||
* 通过用户权限查询可查看的数据源信息
|
||||
*/
|
||||
@ApiOperation("通过用户权限查询可查看的数据源信息")
|
||||
@RequiresPermissions("dataAsset:structure:query")
|
||||
@GetMapping("/getDataSourceData")
|
||||
public Result<List<DataSource>> getDataSourceData() {
|
||||
return Result.success(assetStructureService.getDataSourceData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过数据源编号获取数据库表数据
|
||||
*/
|
||||
@ApiOperation("通过数据库名查询表信息")
|
||||
@RequiresPermissions("dataAsset:structure:query")
|
||||
@GetMapping("/getAssetData/{dataSourceId}")
|
||||
public Result<List<TableInfo>> getAssetData(@PathVariable Long dataSourceId) {
|
||||
return Result.success(assetStructureService.getAssetData(dataSourceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过数据源编号查询资产结构数据
|
||||
*/
|
||||
@ApiOperation("通过数据源编号查询资产结构数据")
|
||||
@RequiresPermissions("dataAsset:structure:query")
|
||||
@GetMapping("/getAssetStructureData/{dataSourceId}")
|
||||
public Result<List<AssetStructureResp>> getAssetStructureData(@PathVariable Long dataSourceId) {
|
||||
return Result.success(assetStructureService.getAssetStructureData(dataSourceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字段信息编号查询字段信息
|
||||
*/
|
||||
@ApiOperation("通过字段信息编号查询字段信息")
|
||||
@RequiresPermissions("dataAsset:structure:query")
|
||||
@GetMapping("/getTableData/{tableInfoId}")
|
||||
public Result<AssetStructureResp> getTableData(@PathVariable Long tableInfoId) {
|
||||
return Result.success(assetStructureService.getTableData(tableInfoId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改表映射字段数据
|
||||
*/
|
||||
@ApiOperation("修改表映射字段数据")
|
||||
@RequiresPermissions("dataAsset:structure:edit")
|
||||
@PutMapping
|
||||
public Result<String> columnInfoEdit(@RequestBody ColumnInfoReq columnInfoReq) {
|
||||
assetStructureService.columnInfoEdit(columnInfoReq);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictDataSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictDataEditReq;
|
||||
import com.ruoyi.dataAsset.service.DataDictDataService;
|
||||
|
||||
/**
|
||||
* 字典数据Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Api(tags = "字典数据")
|
||||
@RestController
|
||||
@RequestMapping("/dictData")
|
||||
public class DataDictDataController extends BaseController {
|
||||
@Autowired
|
||||
private DataDictDataService dataDictDataService;
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictData:add")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增字典数据")
|
||||
public Result<String> add(@RequestBody DataDictDataSaveReq dataDictDataSaveReq) {
|
||||
return toAjax(dataDictDataService.save(DataDictData.saveBuild(dataDictDataSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictData:edit")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{dictCode}")
|
||||
@ApiOperation("修改字典数据")
|
||||
public Result<String> edit(@PathVariable Long dictCode, @RequestBody DataDictDataEditReq dataDictDataEditReq) {
|
||||
return toAjax(dataDictDataService.updateById(DataDictData.editBuild(dictCode,dataDictDataEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictData:remove")
|
||||
@Log(title = "字典数据", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
@ApiOperation("删除字典数据")
|
||||
@ApiImplicitParam(name = "dictCode", value = "dictCode", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> dictCodes) {
|
||||
return toAjax(dataDictDataService.removeBatchByIds(dictCodes));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.dataAsset.domain.resp.DataDictResp;
|
||||
import io.swagger.annotations.*;
|
||||
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.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.DataDictType;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictTypeSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataDictTypeEditReq;
|
||||
import com.ruoyi.dataAsset.service.DataDictTypeService;
|
||||
|
||||
/**
|
||||
* 字典类型Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Api(tags = "字典类型")
|
||||
@RestController
|
||||
@RequestMapping("/dictType")
|
||||
public class DataDictTypeController extends BaseController {
|
||||
@Autowired
|
||||
private DataDictTypeService dataDictTypeService;
|
||||
|
||||
/**
|
||||
* 查询字典类型列表
|
||||
*/
|
||||
@ApiOperation("获取字典类型列表")
|
||||
@RequiresPermissions("dataAsset:dictType:list")
|
||||
@GetMapping({"/list/{dataSourceId}","/list"})
|
||||
public Result<List<DataDictResp>> list(@PathVariable(required = false) Long dataSourceId) {
|
||||
DataDictType dataDictType = new DataDictType();
|
||||
if(Objects.nonNull(dataSourceId)){
|
||||
dataDictType.setDataSourceId(dataSourceId);
|
||||
}
|
||||
return Result.success(dataDictTypeService.list(dataDictType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典类型详细信息
|
||||
*/
|
||||
@ApiOperation("获取字典类型详细信息")
|
||||
@RequiresPermissions("dataAsset:dictType:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<DataDictType> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(dataDictTypeService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictType:add")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增字典类型")
|
||||
public Result<String> add(@RequestBody DataDictTypeSaveReq dataDictTypeSaveReq) {
|
||||
return toAjax(dataDictTypeService.save(DataDictType.saveBuild(dataDictTypeSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictType:edit")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改字典类型")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody DataDictTypeEditReq dataDictTypeEditReq) {
|
||||
return toAjax(dataDictTypeService.updateById(DataDictType.editBuild(id,dataDictTypeEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:dictType:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除字典类型")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(dataDictTypeService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.*;
|
||||
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.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DataSourceEditReq;
|
||||
import com.ruoyi.dataAsset.service.DataSourceService;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 数据接入Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Api(tags = "数据接入")
|
||||
@RestController
|
||||
@RequestMapping("/source")
|
||||
public class DataSourceController extends BaseController {
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
/**
|
||||
* 查询数据接入列表
|
||||
*/
|
||||
@ApiOperation("获取数据接入列表")
|
||||
@RequiresPermissions("dataAsset:source:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DataSource>> list(DataSourceQueryReq dataSourceQueryReq) {
|
||||
startPage();
|
||||
List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据接入列表
|
||||
*/
|
||||
@ApiOperation("导出数据接入列表")
|
||||
@RequiresPermissions("dataAsset:source:export")
|
||||
@Log(title = "数据接入", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DataSource dataSource) {
|
||||
List<DataSource> list = dataSourceService.list(dataSource);
|
||||
ExcelUtil<DataSource> util = new ExcelUtil<DataSource>(DataSource.class);
|
||||
util.exportExcel(response, list, "数据接入数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据接入详细信息
|
||||
*/
|
||||
@ApiOperation("获取数据接入详细信息")
|
||||
@RequiresPermissions("dataAsset:source:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<DataSource> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(dataSourceService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试数据源连接
|
||||
*/
|
||||
@ApiOperation("测试数据源连接")
|
||||
@RequiresPermissions("dataAsset:source:query")
|
||||
@PostMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<Integer> testConnect(@PathVariable("id") Long id) throws SQLException {
|
||||
dataSourceService.testConnect(id);
|
||||
return Result.success(null,"连接成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步数据结构
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:source:add")
|
||||
@Log(title = "数据接入", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/syncData/{dataSourceId}")
|
||||
@ApiOperation("同步数据结构")
|
||||
public Result<String> syncData(@PathVariable Long dataSourceId) {
|
||||
dataSourceService.SynchronousDataStructure(dataSourceId);
|
||||
return Result.success(null,"同步成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据接入
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:source:add")
|
||||
@Log(title = "数据接入", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增数据接入")
|
||||
public Result<String> add(@RequestBody DataSourceSaveReq dataSourceSaveReq) {
|
||||
return toAjax(dataSourceService.save(DataSource.saveBuild(dataSourceSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据接入
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:source:edit")
|
||||
@Log(title = "数据接入", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改数据接入")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody DataSourceEditReq dataSourceEditReq) {
|
||||
return toAjax(dataSourceService.updateById(DataSource.editBuild(id,dataSourceEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据接入
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:source:remove")
|
||||
@Log(title = "数据接入", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除数据接入")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(dataSourceService.removeBatch(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.ruoyi.dataAsset.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.*;
|
||||
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.ruoyi.common.core.domain.Result;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.dataAsset.domain.DatabaseType;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeQueryReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeSaveReq;
|
||||
import com.ruoyi.dataAsset.domain.req.DatabaseTypeEditReq;
|
||||
import com.ruoyi.dataAsset.service.DatabaseTypeService;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 数据库类型Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Api(tags = "数据库类型")
|
||||
@RestController
|
||||
@RequestMapping("/type")
|
||||
public class DatabaseTypeController extends BaseController {
|
||||
@Autowired
|
||||
private DatabaseTypeService databaseTypeService;
|
||||
|
||||
/**
|
||||
* 查询数据库类型列表
|
||||
*/
|
||||
@ApiOperation("获取数据库类型列表")
|
||||
@RequiresPermissions("dataAsset:type:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DatabaseType>> list(DatabaseTypeQueryReq databaseTypeQueryReq) {
|
||||
startPage();
|
||||
List<DatabaseType> list = databaseTypeService.list(DatabaseType.queryBuild(databaseTypeQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据库类型列表
|
||||
*/
|
||||
@ApiOperation("导出数据库类型列表")
|
||||
@RequiresPermissions("dataAsset:type:export")
|
||||
@Log(title = "数据库类型", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DatabaseType databaseType) {
|
||||
List<DatabaseType> list = databaseTypeService.list(databaseType);
|
||||
ExcelUtil<DatabaseType> util = new ExcelUtil<DatabaseType>(DatabaseType.class);
|
||||
util.exportExcel(response, list, "数据库类型数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型详细信息
|
||||
*/
|
||||
@ApiOperation("获取数据库类型详细信息")
|
||||
@RequiresPermissions("dataAsset:type:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<DatabaseType> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(databaseTypeService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据库类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:type:add")
|
||||
@Log(title = "数据库类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增数据库类型")
|
||||
public Result<String> add(@RequestBody DatabaseTypeSaveReq databaseTypeSaveReq) {
|
||||
return toAjax(databaseTypeService.save(DatabaseType.saveBuild(databaseTypeSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据库类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:type:edit")
|
||||
@Log(title = "数据库类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改数据库类型")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody DatabaseTypeEditReq databaseTypeEditReq) {
|
||||
return toAjax(databaseTypeService.updateById(DatabaseType.editBuild(id,databaseTypeEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据库类型
|
||||
*/
|
||||
@RequiresPermissions("dataAsset:type:remove")
|
||||
@Log(title = "数据库类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除数据库类型")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(databaseTypeService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.AssetAuthInfo;
|
||||
|
||||
/**
|
||||
* 资产授权Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetAuthInfoMapper extends BaseMapper<AssetAuthInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.AssetModelData;
|
||||
|
||||
/**
|
||||
* 资产授权Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetModelDataMapper extends BaseMapper<AssetModelData> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
|
||||
/**
|
||||
* 字段信息Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface ColumnInfoMapper extends BaseMapper<ColumnInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
|
||||
/**
|
||||
* 字典数据Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
public interface DataDictDataMapper extends BaseMapper<DataDictData> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataDictType;
|
||||
|
||||
/**
|
||||
* 字典类型Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
public interface DataDictTypeMapper extends BaseMapper<DataDictType> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
|
||||
/**
|
||||
* 数据接入Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface DataSourceMapper extends BaseMapper<DataSource> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.DatabaseType;
|
||||
|
||||
/**
|
||||
* 数据库类型Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface DatabaseTypeMapper extends BaseMapper<DatabaseType> {
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
|
||||
/**
|
||||
* 表信息Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface TableInfoMapper extends BaseMapper<TableInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.dataAsset.queue;
|
||||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @ClassName NormalQueue
|
||||
* @Description 普通的队列
|
||||
* @Author 森静若林
|
||||
* @Date 2024/1/16 18:38
|
||||
*/
|
||||
@Component
|
||||
public class NormalQueue {
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
public <T> void sendUUIDMsg(String queueName,T msg){
|
||||
rabbitTemplate.convertAndSend(queueName,msg,message -> {
|
||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
return message;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.dataAsset.domain.AssetAuthInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 资产授权Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetAuthInfoService extends IService<AssetAuthInfo> {
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*
|
||||
* @param assetAuthInfo 资产授权
|
||||
* @return 资产授权集合
|
||||
*/
|
||||
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo);
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.dataAsset.domain.AssetModelData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产授权Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
public interface AssetModelDataService extends IService<AssetModelData> {
|
||||
/**
|
||||
* 查询资产模型数据列表
|
||||
* @param tableId 表编号
|
||||
* @return 资产模型数据集合
|
||||
*/
|
||||
public List<AssetModelData> list(Long tableId);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
import com.ruoyi.dataAsset.domain.req.ColumnInfoReq;
|
||||
import com.ruoyi.dataAsset.domain.resp.AssetStructureResp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产结构service接口
|
||||
* @ClassName AssetStructureService
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 11:00
|
||||
*/
|
||||
public interface AssetStructureService {
|
||||
/**
|
||||
* 通过用户权限获取数据源数据
|
||||
*
|
||||
* @return 数据源集合
|
||||
*/
|
||||
List<DataSource> getDataSourceData();
|
||||
|
||||
/**
|
||||
* 通过数据源编号和用户权限获取资产结构数据
|
||||
* @param dataSourceId 数据源编号
|
||||
* @return 资产结构响应集合
|
||||
*/
|
||||
List<AssetStructureResp> getAssetStructureData(Long dataSourceId);
|
||||
|
||||
/**
|
||||
* 修改字段信息中的映射字典
|
||||
* @param columnInfoReq 字段信息
|
||||
*/
|
||||
void columnInfoEdit(ColumnInfoReq columnInfoReq);
|
||||
|
||||
/**
|
||||
* 获取单个表的字段信息
|
||||
* @param tableInfoId 表信息编号
|
||||
* @return 表的字段信息
|
||||
*/
|
||||
AssetStructureResp getTableData(Long tableInfoId);
|
||||
|
||||
/**
|
||||
* 通过数据源编号和用户权限获取资产数据
|
||||
* @param dataSourceId 数据源编号
|
||||
* @return 表信息集合
|
||||
*/
|
||||
List<TableInfo> getAssetData(Long dataSourceId);
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
|
||||
/**
|
||||
* 字段信息service接口
|
||||
* @ClassName ColumnInfoService
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 11:00
|
||||
*/
|
||||
public interface ColumnInfoService extends IService<ColumnInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 字典数据Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
public interface DataDictDataService extends IService<DataDictData> {
|
||||
/**
|
||||
* 查询字典数据列表
|
||||
*
|
||||
* @param dataDictData 字典数据
|
||||
* @return 字典数据集合
|
||||
*/
|
||||
public List<DataDictData> list(DataDictData dataDictData);
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.dataAsset.domain.DataDictType;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.dataAsset.domain.resp.DataDictResp;
|
||||
|
||||
/**
|
||||
* 字典类型Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
public interface DataDictTypeService extends IService<DataDictType> {
|
||||
/**
|
||||
* 查询字典类型列表
|
||||
*
|
||||
* @param dataDictType 字典类型
|
||||
* @return 字典类型集合
|
||||
*/
|
||||
List<DataDictResp> list(DataDictType dataDictType);
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 数据接入Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface DataSourceService extends IService<DataSource> {
|
||||
/**
|
||||
* 查询数据接入列表
|
||||
*
|
||||
* @param dataSource 数据接入
|
||||
* @return 数据接入集合
|
||||
*/
|
||||
public List<DataSource> list(DataSource dataSource);
|
||||
|
||||
/**
|
||||
* 测试数据源连接
|
||||
*
|
||||
* @param id 数据源id
|
||||
*/
|
||||
void testConnect(Long id) throws SQLException;
|
||||
|
||||
/**
|
||||
* 同步数据结构
|
||||
* @param dataSourceId 数据源编号
|
||||
*/
|
||||
void SynchronousDataStructure(Long dataSourceId);
|
||||
|
||||
/**
|
||||
* 批量删除接入数据源
|
||||
* @param ids 数据源编号
|
||||
* @return 是否
|
||||
*/
|
||||
boolean removeBatch(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.dataAsset.domain.DatabaseType;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 数据库类型Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface DatabaseTypeService extends IService<DatabaseType> {
|
||||
/**
|
||||
* 查询数据库类型列表
|
||||
*
|
||||
* @param databaseType 数据库类型
|
||||
* @return 数据库类型集合
|
||||
*/
|
||||
public List<DatabaseType> list(DatabaseType databaseType);
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.dataAsset.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
|
||||
/**
|
||||
* 表信息service接口
|
||||
* @ClassName TableInfoService
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 11:00
|
||||
*/
|
||||
public interface TableInfoService extends IService<TableInfo> {
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.dataAsset.mapper.AssetAuthInfoMapper;
|
||||
import com.ruoyi.dataAsset.domain.AssetAuthInfo;
|
||||
import com.ruoyi.dataAsset.service.AssetAuthInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 资产授权Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AssetAuthInfoServiceImpl extends ServiceImpl<AssetAuthInfoMapper, AssetAuthInfo> implements AssetAuthInfoService {
|
||||
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*
|
||||
* @param assetAuthInfo 资产授权
|
||||
* @return 资产授权
|
||||
*/
|
||||
@Override
|
||||
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo) {
|
||||
if (Objects.isNull(assetAuthInfo.getIdType())){
|
||||
throw new ServiceException("id类型不能为空");
|
||||
}
|
||||
if (Objects.isNull(assetAuthInfo.getAuthType())){
|
||||
throw new ServiceException("授权类型不能为空");
|
||||
}
|
||||
|
||||
return list(new LambdaQueryWrapper<AssetAuthInfo>()
|
||||
.eq(AssetAuthInfo::getIdType, assetAuthInfo.getIdType())
|
||||
.eq(AssetAuthInfo::getAuthType, assetAuthInfo.getAuthType()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.dataAsset.domain.AssetModelData;
|
||||
import com.ruoyi.dataAsset.mapper.AssetModelDataMapper;
|
||||
import com.ruoyi.dataAsset.service.AssetModelDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产模型数据Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AssetModelDataServiceImpl extends ServiceImpl<AssetModelDataMapper, AssetModelData> implements AssetModelDataService {
|
||||
|
||||
@Override
|
||||
public List<AssetModelData> list(Long tableId) {
|
||||
return this.list(new LambdaQueryWrapper<AssetModelData>()
|
||||
.eq(AssetModelData::getTableId,tableId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.common.system.domain.SysUser;
|
||||
import com.ruoyi.dataAsset.domain.AssetAuthInfo;
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
import com.ruoyi.dataAsset.domain.req.ColumnInfoReq;
|
||||
import com.ruoyi.dataAsset.domain.resp.AssetStructureResp;
|
||||
import com.ruoyi.dataAsset.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
/**
|
||||
* 资产结构service业务层处理
|
||||
* @ClassName AssetStructureService
|
||||
* @Author 森静若林
|
||||
* @Date 2024/4/21 11:00
|
||||
*/
|
||||
@Service
|
||||
public class AssetStructureServiceImpl implements AssetStructureService {
|
||||
|
||||
@Autowired
|
||||
private AssetAuthInfoService assetAuthInfoService;
|
||||
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
@Autowired
|
||||
private TableInfoService tableInfoService;
|
||||
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 通过用户权限获取数据源数据
|
||||
*
|
||||
* @return 数据源集合
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> getDataSourceData() {
|
||||
LambdaQueryWrapper<DataSource> queryWrapper = new LambdaQueryWrapper<DataSource>().eq(DataSource::getStatus, "Y");
|
||||
//不是管理员
|
||||
if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
|
||||
Map<String,String> authDataMap=new HashMap<>();
|
||||
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
|
||||
//用户and部门权限
|
||||
List<AssetAuthInfo> deptAuthInfoList = assetAuthInfoService.list(new LambdaQueryWrapper<AssetAuthInfo>()
|
||||
.eq(AssetAuthInfo::getAuthId, sysUser.getDeptId())
|
||||
.eq(AssetAuthInfo::getIdType, "dept")
|
||||
.or(qw-> qw.eq(AssetAuthInfo::getAuthId, sysUser.getUserId())
|
||||
.eq(AssetAuthInfo::getIdType, "user")));
|
||||
List<Long> dataSourceIdList = deptAuthInfoList.stream().map(assetAuthInfo -> {
|
||||
//授权为整个数据源
|
||||
if (assetAuthInfo.getAuthType().equals("dataSource")) {
|
||||
authDataMap.put(assetAuthInfo.getAuthData(), null);
|
||||
return Convert.toLong(assetAuthInfo.getAuthData());
|
||||
} else {
|
||||
String[] longs = assetAuthInfo.getAuthData().split(",");
|
||||
String dataSourceId = longs[0];
|
||||
String tableName = longs[1];
|
||||
if (authDataMap.containsKey(dataSourceId)) {
|
||||
String string = authDataMap.get(dataSourceId);
|
||||
//如果不是数据源权限
|
||||
if (Objects.nonNull(string)) {
|
||||
//拼接表权限
|
||||
string += "," + tableName;
|
||||
//更新数据
|
||||
authDataMap.put(dataSourceId, string);
|
||||
}
|
||||
} else {
|
||||
authDataMap.put(dataSourceId, tableName);
|
||||
}
|
||||
return Convert.toLong(dataSourceId);
|
||||
}
|
||||
}).toList();
|
||||
if(dataSourceIdList.isEmpty()){
|
||||
queryWrapper.eq(DataSource::getId,0L);
|
||||
}else {
|
||||
queryWrapper.in(DataSource::getId,dataSourceIdList);
|
||||
}
|
||||
//缓存权限数据
|
||||
redisService.setCacheMap("userDataAssetAuth:"+SecurityUtils.getUserId(),authDataMap);
|
||||
}
|
||||
return dataSourceService.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过数据源编号和用户权限获取资产结构数据
|
||||
* @param dataSourceId 数据源编号
|
||||
* @return 资产结构响应集合
|
||||
*/
|
||||
@Override
|
||||
public List<AssetStructureResp> getAssetStructureData(Long dataSourceId) {
|
||||
DataSource dataSource = dataSourceService.getById(dataSourceId);
|
||||
if(Objects.isNull(dataSource.getRecordsTotal())){
|
||||
throw new ServiceException("暂无数据库信息,请先同步数据");
|
||||
}
|
||||
LambdaQueryWrapper<TableInfo> queryWrapper = new LambdaQueryWrapper<TableInfo>().eq(TableInfo::getDataSourceId, dataSourceId);
|
||||
//如果不是管理员
|
||||
if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
|
||||
String authData = redisService.getCacheMapValue("userDataAssetAuth:" + SecurityUtils.getUserId(), dataSourceId.toString());
|
||||
if(Objects.nonNull(authData)){
|
||||
List<String> longs = stream(authData.split(",")).toList();
|
||||
queryWrapper.in(TableInfo::getName,longs);
|
||||
}
|
||||
}
|
||||
return tableInfoService.list(queryWrapper)
|
||||
.stream().map(tableInfo -> {
|
||||
List<ColumnInfo> list = columnInfoService.list(new LambdaQueryWrapper<ColumnInfo>()
|
||||
.eq(ColumnInfo::getTableId, tableInfo.getId()));
|
||||
return tableInfo.toAssetStructureResp(list);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字段信息中的映射字典
|
||||
* @param columnInfoReq 字段信息
|
||||
*/
|
||||
@Override
|
||||
public void columnInfoEdit(ColumnInfoReq columnInfoReq) {
|
||||
columnInfoService.update(new LambdaUpdateWrapper<ColumnInfo>()
|
||||
.set(ColumnInfo::getIsDict,columnInfoReq.getIsDict())
|
||||
.set(ColumnInfo::getDataDictType,columnInfoReq.getDataDictType())
|
||||
.eq(ColumnInfo::getId,columnInfoReq.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个表的字段信息
|
||||
* @param tableInfoId 表信息编号
|
||||
* @return 表的字段信息
|
||||
*/
|
||||
@Override
|
||||
public AssetStructureResp getTableData(Long tableInfoId) {
|
||||
return tableInfoService.getById(tableInfoId).toAssetStructureResp(columnInfoService.list(new LambdaQueryWrapper<ColumnInfo>()
|
||||
.eq(ColumnInfo::getTableId, tableInfoId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过数据源编号和用户权限获取资产数据
|
||||
* @param dataSourceId 数据源编号
|
||||
* @return 表信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<TableInfo> getAssetData(Long dataSourceId) {
|
||||
DataSource dataSource = dataSourceService.getById(dataSourceId);
|
||||
if(Objects.isNull(dataSource.getRecordsTotal())){
|
||||
throw new ServiceException("暂无数据库信息,请先同步数据");
|
||||
}
|
||||
LambdaQueryWrapper<TableInfo> queryWrapper = new LambdaQueryWrapper<TableInfo>().eq(TableInfo::getDataSourceId, dataSourceId);
|
||||
//如果不是管理员
|
||||
if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
|
||||
String authData = redisService.getCacheMapValue("userDataAssetAuth:" + SecurityUtils.getUserId(), dataSourceId.toString());
|
||||
if(Objects.nonNull(authData)){
|
||||
List<String> longs = stream(authData.split(",")).toList();
|
||||
queryWrapper.in(TableInfo::getName,longs);
|
||||
}
|
||||
}
|
||||
return tableInfoService.list(queryWrapper);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
import com.ruoyi.dataAsset.mapper.ColumnInfoMapper;
|
||||
import com.ruoyi.dataAsset.service.ColumnInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 字段信息Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ColumnInfoServiceImpl extends ServiceImpl<ColumnInfoMapper, ColumnInfo> implements ColumnInfoService {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.ObjUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.dataAsset.mapper.DataDictDataMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
import com.ruoyi.dataAsset.service.DataDictDataService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 字典数据Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataDictDataServiceImpl extends ServiceImpl<DataDictDataMapper, DataDictData> implements DataDictDataService {
|
||||
|
||||
/**
|
||||
* 查询字典数据列表
|
||||
*
|
||||
* @param dataDictData 字典数据
|
||||
* @return 字典数据
|
||||
*/
|
||||
@Override
|
||||
public List<DataDictData> list(DataDictData dataDictData) {
|
||||
LambdaQueryWrapper<DataDictData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(dataDictData.getDictLabel())){
|
||||
queryWrapper.eq(DataDictData::getDictLabel, dataDictData.getDictLabel());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataDictData.getDictValue())){
|
||||
queryWrapper.eq(DataDictData::getDictValue, dataDictData.getDictValue());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataDictData.getDictTypeId())){
|
||||
queryWrapper.eq(DataDictData::getDictTypeId, dataDictData.getDictTypeId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.ObjUtils;
|
||||
import com.ruoyi.dataAsset.domain.DataDictData;
|
||||
import com.ruoyi.dataAsset.domain.resp.DataDictResp;
|
||||
import com.ruoyi.dataAsset.service.DataDictDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.dataAsset.mapper.DataDictTypeMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataDictType;
|
||||
import com.ruoyi.dataAsset.service.DataDictTypeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 字典类型Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataDictTypeServiceImpl extends ServiceImpl<DataDictTypeMapper, DataDictType> implements DataDictTypeService {
|
||||
|
||||
@Autowired
|
||||
private DataDictDataService dataDictDataService;
|
||||
|
||||
/**
|
||||
* 查询字典类型列表
|
||||
*
|
||||
* @param dataDictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Override
|
||||
public List<DataDictResp> list(DataDictType dataDictType) {
|
||||
LambdaQueryWrapper<DataDictType> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (ObjUtils.notNull(dataDictType.getDataSourceId())){
|
||||
queryWrapper.eq(DataDictType::getDataSourceId, dataDictType.getDataSourceId());
|
||||
}
|
||||
|
||||
return list(queryWrapper).stream().map(dataDict -> {
|
||||
List<DataDictData> list = dataDictDataService.list(new LambdaQueryWrapper<DataDictData>()
|
||||
.eq(DataDictData::getDictTypeId, dataDict.getId()));
|
||||
return dataDict.toDataDictResp(list);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,382 @@
|
|||
package com.ruoyi.dataAsset.service.impl;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.ObjUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.dataAsset.constant.QueueConstants;
|
||||
import com.ruoyi.dataAsset.domain.AssetModelData;
|
||||
import com.ruoyi.dataAsset.domain.ColumnInfo;
|
||||
import com.ruoyi.dataAsset.domain.TableInfo;
|
||||
import com.ruoyi.dataAsset.queue.NormalQueue;
|
||||
import com.ruoyi.dataAsset.service.*;
|
||||
import com.ruoyi.dataAsset.util.DataSourceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.dataAsset.mapper.DataSourceMapper;
|
||||
import com.ruoyi.dataAsset.domain.DataSource;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 数据接入Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements DataSourceService {
|
||||
|
||||
@Autowired
|
||||
private ColumnInfoService columnInfoService;
|
||||
|
||||
@Autowired
|
||||
private TableInfoService tableInfoService;
|
||||
|
||||
@Autowired
|
||||
private AssetModelDataService assetModuleDataService;
|
||||
|
||||
@Autowired
|
||||
private ConnectionPoolService connectionPoolService;
|
||||
|
||||
@Autowired
|
||||
private NormalQueue normalQueue;
|
||||
|
||||
/**
|
||||
* 查询数据接入列表
|
||||
*
|
||||
* @param dataSource 数据接入
|
||||
* @return 数据接入
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> list(DataSource dataSource) {
|
||||
LambdaQueryWrapper<DataSource> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDataSourceName())){
|
||||
queryWrapper.like(DataSource::getDataSourceName, dataSource.getDataSourceName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDataSourceSystemName())){
|
||||
queryWrapper.like(DataSource::getDataSourceSystemName, dataSource.getDataSourceSystemName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDatabaseType())){
|
||||
queryWrapper.eq(DataSource::getDatabaseType, dataSource.getDatabaseType());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getType())){
|
||||
queryWrapper.eq(DataSource::getType, dataSource.getType());
|
||||
}
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试数据源连接
|
||||
* @param id 数据源id
|
||||
*/
|
||||
@Override
|
||||
public void testConnect(Long id){
|
||||
DataSource dataSource = this.getById(id);
|
||||
Connection connection=null;
|
||||
try {
|
||||
connection = DataSourceUtil.getConnection(dataSource);
|
||||
} catch (SQLException e) {
|
||||
//连接失败,如果为可用修改为不可用
|
||||
if(dataSource.getStatus().equals("Y")){
|
||||
dataSource.setStatus("N");
|
||||
dataSource.setUpdateTime(new Date());
|
||||
dataSource.setUpdateBy(SecurityUtils.getUsername());
|
||||
this.updateById(dataSource);
|
||||
}
|
||||
throw new ServiceException("数据源连接失败");
|
||||
}finally {
|
||||
try {
|
||||
if(connection!=null){
|
||||
connection.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
//异步更新数据源
|
||||
CompletableFuture.runAsync(()->{
|
||||
this.renewalDataSource(dataSource,QueueConstants.INSERT_QUEUE);
|
||||
});
|
||||
//如果为不可用修改为可用
|
||||
if(dataSource.getStatus().equals("N")){
|
||||
dataSource.setStatus("Y");
|
||||
dataSource.setUpdateTime(new Date());
|
||||
dataSource.setUpdateBy(SecurityUtils.getUsername());
|
||||
this.updateById(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除接入数据源
|
||||
* @param ids 数据源编号
|
||||
* @return 是否
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean removeBatch(List<Long> ids) {
|
||||
// 处理相关数据
|
||||
ids.forEach(id->{
|
||||
// 查找相关表信息
|
||||
tableInfoService.list(new LambdaQueryWrapper<TableInfo>()
|
||||
.eq(TableInfo::getDataSourceId,id))
|
||||
.forEach(tableInfo->{
|
||||
// 删除
|
||||
this.removeRelevantData(tableInfo.getName(),id);
|
||||
});
|
||||
CompletableFuture.runAsync(()->{
|
||||
DataSource dataSource = this.getById(id);
|
||||
// 如果是有效数据源
|
||||
if(dataSource.getStatus().equals("Y")){
|
||||
// 刷新
|
||||
this.renewalDataSource(dataSource,QueueConstants.DELETE_QUEUE);
|
||||
}
|
||||
});
|
||||
});
|
||||
// 删除数据源
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步数据结构
|
||||
* @param dataSourceId 数据源编号
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void SynchronousDataStructure(Long dataSourceId){
|
||||
//获取数据源
|
||||
DataSource dataSource = this.getById(dataSourceId);
|
||||
if(dataSource.getStatus().equals("N")){
|
||||
throw new SecurityException("数据源不可用,请先确认数据源信息,测试连接后再同步");
|
||||
}
|
||||
String sql=null;
|
||||
if(dataSource.getDatabaseType().contains("mysql")){
|
||||
sql="SELECT COUNT(*) tableTotal,SUM(table_rows) recordsTotal FROM information_schema.tables WHERE table_schema = '"+dataSource.getDatabases()+"';";
|
||||
}else if(dataSource.getDatabaseType().contains("sqlserver")) {
|
||||
sql="SELECT COUNT(*) tableTotal,SUM(b.rows) recordsTotal FROM sysobjects AS a \n" +
|
||||
"INNER JOIN sysindexes AS b ON a.id = b.id WHERE ( a.type = 'u' ) AND ( b.indid IN ( 0, 1 ) );";
|
||||
}
|
||||
try {
|
||||
DruidPooledConnection connection = connectionPoolService.getConnection(dataSourceId);
|
||||
//总的记录数,总的表数量
|
||||
ResultSet result = connection.prepareStatement(sql).executeQuery();
|
||||
while (result.next()){
|
||||
dataSource.setTableTotal(result.getInt("tableTotal"));
|
||||
dataSource.setRecordsTotal(result.getInt("recordsTotal"));
|
||||
}
|
||||
//异步同步表结构并等待所有任务结束
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
this.SynchronousTableStructure(dataSource);
|
||||
return "end";
|
||||
}).get();
|
||||
//修改数据
|
||||
this.updateById(dataSource);
|
||||
result.close();
|
||||
connection.close();
|
||||
} catch (SQLException | InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步表结构
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
public void SynchronousTableStructure(DataSource dataSource){
|
||||
try {
|
||||
List<CompletableFuture<String>> runAsyncList=new ArrayList<>();
|
||||
DruidPooledConnection connection = connectionPoolService.getConnection(dataSource.getId());
|
||||
ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), "dbo", "%", new String[] { "TABLE" });
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME");
|
||||
String comment = tables.getString("REMARKS");
|
||||
String sql="SELECT COUNT(*) recordsTotal FROM "+tableName+";";
|
||||
ResultSet resultSet = connection.prepareStatement(sql).executeQuery();
|
||||
int recordsTotal =0;
|
||||
while (resultSet.next()){
|
||||
recordsTotal = resultSet.getInt("recordsTotal");
|
||||
}
|
||||
resultSet.close();
|
||||
TableInfo tableInfo = TableInfo.builder().name(tableName).comment(comment).recordsTotal(recordsTotal).dataSourceId(dataSource.getId()).build();
|
||||
//可能同步过,先删除
|
||||
this.removeRelevantData(tableName, dataSource.getId());
|
||||
//添加
|
||||
tableInfoService.save(tableInfo);
|
||||
//异步存储表数据
|
||||
runAsyncList.add(CompletableFuture.supplyAsync(() -> {
|
||||
this.SynchronousColumnInfo(tableName, tableInfo.getId(), dataSource);
|
||||
return "end";
|
||||
}));
|
||||
}
|
||||
//等待所有任务结束
|
||||
CompletableFuture.allOf(runAsyncList.toArray(CompletableFuture[]::new)).join();
|
||||
tables.close();
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步字段信息
|
||||
* @param tableName 表名
|
||||
* @param tableId 表编号
|
||||
*/
|
||||
public void SynchronousColumnInfo(String tableName,Long tableId,DataSource dataSource) {
|
||||
//声明字段信息空集合
|
||||
List<ColumnInfo> list=new ArrayList<>();
|
||||
//声明资产模型数据空集合
|
||||
List<AssetModelData> moduleDataList=new ArrayList<>();
|
||||
try {
|
||||
DruidPooledConnection connection = connectionPoolService.getConnection(dataSource.getId());
|
||||
ResultSet columns = connection.getMetaData().getColumns(connection.getCatalog(), null, tableName, "%");
|
||||
ResultSet primaryKeys = connection.getMetaData().getPrimaryKeys(connection.getCatalog(), null, tableName);
|
||||
String primaryKeyName=null;
|
||||
while (primaryKeys.next()){
|
||||
primaryKeyName=primaryKeys.getString("COLUMN_NAME");
|
||||
}
|
||||
primaryKeys.close();
|
||||
//sqlserver获取字段注解
|
||||
ResultSet sqlServerSet=null;
|
||||
if (dataSource.getDatabaseType().contains("sqlserver")) {
|
||||
String sql="SELECT C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id\n" +
|
||||
"LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id WHERE A.name = '"+tableName+"'";
|
||||
sqlServerSet = connection.prepareStatement(sql).executeQuery();
|
||||
}
|
||||
int index=1;
|
||||
//获取表的第一条数据
|
||||
String selectFirst="select * from " + tableName ;
|
||||
if (dataSource.getDatabaseType().contains("mysql")) {
|
||||
selectFirst+=" limit 1;";
|
||||
}else if (dataSource.getDatabaseType().contains("sqlserver")){
|
||||
selectFirst+=" order by "+primaryKeyName+" offset 0 rows fetch next 1 rows only;";
|
||||
}
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(selectFirst);
|
||||
ResultSetMetaData data = preparedStatement.getMetaData();
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
boolean next = resultSet.next();
|
||||
//循环获取字段信息
|
||||
while(columns.next()) {
|
||||
//字段名
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
//长度
|
||||
Integer columnSize = columns.getInt("COLUMN_SIZE");
|
||||
//数据库类型
|
||||
String datatype = columns.getString("TYPE_NAME");
|
||||
//映射类型
|
||||
String javaType = data.getColumnClassName(index);
|
||||
//是否主键
|
||||
String isKey=columnName.equals(primaryKeyName)?"Y":"N";
|
||||
//是否为空
|
||||
String isNullable = columns.getString("IS_NULLABLE").equals("YES")?"Y":"N";
|
||||
//小数位
|
||||
String scale = columns.getString("DECIMAL_DIGITS");
|
||||
if(StringUtils.isEmpty(scale)){
|
||||
scale="-";
|
||||
}
|
||||
//默认值
|
||||
String defaultValue = columns.getString("COLUMN_DEF");
|
||||
if(StringUtils.isEmpty(defaultValue)){
|
||||
defaultValue="-";
|
||||
}
|
||||
//注解
|
||||
String columnComment = columns.getString("REMARKS");
|
||||
if(sqlServerSet!=null){
|
||||
sqlServerSet.next();
|
||||
columnComment=sqlServerSet.getString("column_description");
|
||||
}
|
||||
list.add(ColumnInfo.builder().name(columnName).type(datatype).scale(scale)
|
||||
.javaType(javaType).isKey(isKey).comment(columnComment).defaultValue(defaultValue)
|
||||
.length(columnSize).isNullable(isNullable).tableId(tableId).isDict("N").dataDictType(null).build());
|
||||
//获取资产模型数据
|
||||
if(next){
|
||||
String string = resultSet.getString(index++);
|
||||
moduleDataList.add(AssetModelData.builder().key(dataSource.getDataSourceName()+"."+tableName+"."+columnName)
|
||||
.type(javaType).value(string==null?"null":string).tableId(tableId).build());
|
||||
}
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
//批量添加字段信息
|
||||
columnInfoService.saveBatch(list);
|
||||
//查询是否已有资产模型数据
|
||||
List<Long> longList = assetModuleDataService.list(new LambdaQueryWrapper<AssetModelData>().eq(AssetModelData::getTableId, tableId))
|
||||
.stream().map(AssetModelData::getId).toList();
|
||||
if(!longList.isEmpty()){
|
||||
//批量删除
|
||||
assetModuleDataService.removeBatchByIds(longList);
|
||||
}
|
||||
//批量添加
|
||||
assetModuleDataService.saveBatch(moduleDataList);
|
||||
});
|
||||
//关闭连接
|
||||
if(sqlServerSet!=null){
|
||||
sqlServerSet.close();
|
||||
}
|
||||
columns.close();
|
||||
resultSet.close();
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除相关数据
|
||||
* @param tableName 表名
|
||||
* @param dataSourceId 数据源编号
|
||||
*/
|
||||
public void removeRelevantData(String tableName,Long dataSourceId){
|
||||
// 查询表信息
|
||||
TableInfo one = tableInfoService.getOne(new LambdaQueryWrapper<TableInfo>()
|
||||
.eq(TableInfo::getName, tableName)
|
||||
.eq(TableInfo::getDataSourceId, dataSourceId));
|
||||
// 存在
|
||||
if(Objects.nonNull(one)){
|
||||
// 删除表
|
||||
tableInfoService.removeById(one.getId());
|
||||
// 删除字段
|
||||
columnInfoService.remove(new LambdaQueryWrapper<ColumnInfo>()
|
||||
.eq(ColumnInfo::getTableId,one.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据源
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
public void renewalDataSource(DataSource dataSource,String type){
|
||||
String queueName=null;
|
||||
Long id = dataSource.getId();
|
||||
// 如果已经存在
|
||||
if(connectionPoolService.hasKey(id)){
|
||||
// 关闭旧的
|
||||
connectionPoolService.closeDataSource(id);
|
||||
}
|
||||
if(QueueConstants.INSERT_QUEUE.equals(type)){
|
||||
queueName= QueueConstants.DATASOURCE_INSERT_MESSAGE;
|
||||
// 新增或替换数据源
|
||||
connectionPoolService.put(dataSource);
|
||||
}else{
|
||||
queueName= QueueConstants.DATASOURCE_DELETE_MESSAGE;
|
||||
// 删除数据源
|
||||
connectionPoolService.remove(id);
|
||||
}
|
||||
// 发送消息
|
||||
normalQueue.sendUUIDMsg(queueName,dataSource);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue