feat: 引擎维护回显操作

master
baize 2024-05-10 18:50:41 +08:00
parent a1b3652704
commit a0cf7e7c3a
49 changed files with 1063 additions and 54 deletions

View File

@ -13,7 +13,7 @@
<description> <description>
muyu-auth认证授权中心 muyu-auth认证授权中心
</description> </description>
<packaging>jar</packaging>
<dependencies> <dependencies>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9200 port: 9100
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -20,4 +20,9 @@ public class ServiceNameConstants {
* serviceid * serviceid
*/ */
public static final String FILE_SERVICE = "muyu-file"; public static final String FILE_SERVICE = "muyu-file";
/**
*
*/
public static final String DATA_SOURCE_SERVICE = "muyu-data-source";
} }

View File

@ -10,7 +10,7 @@
</parent> </parent>
<artifactId>muyu-common-system</artifactId> <artifactId>muyu-common-system</artifactId>
<packaging>jar</packaging>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>

View File

@ -13,6 +13,7 @@
<description> <description>
muyu-gateway网关模块 muyu-gateway网关模块
</description> </description>
<packaging>jar</packaging>
<dependencies> <dependencies>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 8080 port: 18080
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
@ -29,12 +30,12 @@ spring:
eager: true eager: true
transport: transport:
# 控制台地址 # 控制台地址
dashboard: 115.159.81.159:8718 dashboard: 43.142.149.172:8718
# nacos配置持久化 # nacos配置持久化
datasource: datasource:
ds1: ds1:
nacos: nacos:
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
dataId: sentinel-muyu-gateway dataId: sentinel-muyu-gateway
groupId: DEFAULT_GROUP groupId: DEFAULT_GROUP
data-type: json data-type: json

View File

@ -0,0 +1,38 @@
<?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>muyu-data-source</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-data-source-client</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>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-source-remote</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-source-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
package com.muyu.data.source.client.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
/**
* DataSourceConfig
*
* @author DeKangLiu
* Date 2024/5/9 20:56
*/
@ComponentScan
@Import(value = {DataSourceClientRunner.class})
public class DataSourceClientConfig {
}

View File

@ -0,0 +1,35 @@
package com.muyu.data.source.client.config;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.data.source.domain.DataSource;
import com.muyu.data.source.domain.req.DataSourceQueryReq;
import com.muyu.data.source.remote.RemoteDataManagerService;
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;
/**
* DataSourceClientRunner
*
* @author DeKangLiu
* Date 2024/5/9 21:00
*/
@Log4j2
public class DataSourceClientRunner implements ApplicationRunner {
@Autowired
private RemoteDataManagerService remoteDataManagerService;
/**
*
* @param args
* @throws Exception
*/
@Override
public void run(ApplicationArguments args) throws Exception {
Result<List<DataSource>> dataSourceList = remoteDataManagerService.postList(new DataSourceQueryReq());
log.info(dataSourceList);
}
}

View File

@ -0,0 +1,24 @@
package com.muyu.data.source.client.pool;
/**
*
*
* @author WangLei
* @Date 2024/4/29 029 14:30
*/
public class BaseConfig {
/**
* mysql
*/
public static final String MYSQLJDBCPRO = "jdbc:mysql://";
public static void driver(String driverName){
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,41 @@
package com.muyu.data.source.client.pool;
/**
*
*
* @author WangLei
* @Date 2024/4/29 029 14:41
*/
public interface BasePool<T> {
/**
*
*/
public void init();
/**
*
*/
public T getConn();
/**
*
* @param conn
*/
public void reaplase(T conn);
/**
*
* @return
*/
public T creatConnection();
/**
*
*/
public void closeConn();
}

View File

@ -0,0 +1,13 @@
package com.muyu.data.source.client.pool;
/**
* Mysql
*
* @author WangLei
* @Date 2024/4/29 029 15:17
*/
public class MysqlConnException extends RuntimeException{
public MysqlConnException(String message) {
super(message);
}
}

View File

@ -0,0 +1,191 @@
package com.muyu.data.source.client.pool;
import com.muyu.data.source.client.pool.config.MysqlPoolConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Mysql
*
* @author WangLei
* @Date 2024/4/29 029 14:36
*/
@Component
public class MysqlPool implements BasePool<Connection> {
/**
*
*/
private static final Logger log = LoggerFactory.getLogger(MysqlPool.class);
/**
*
*/
private Queue<Connection> mysqlConnQueue = null;
/**
*
*/
private Queue<Connection> activeMysqlQueue = null;
/**
*
*/
private AtomicInteger count = new AtomicInteger();
public MysqlPoolConfig mysqlPoolConfig;
/**
*
*/
public MysqlPool(MysqlPoolConfig mysqlPoolConfig) {
log.info("Mysql连接池实例化完成");
this.mysqlPoolConfig = mysqlPoolConfig;
BaseConfig.driver(this.mysqlPoolConfig.getDriverName());
}
/**
*
*/
@Override
public void init() {
int maxTotal = Integer.parseInt(this.mysqlPoolConfig.getMaximumQuantity());
int initTotal = Integer.parseInt(this.mysqlPoolConfig.getInitialQuantity());
this.mysqlConnQueue = new LinkedBlockingQueue<>();
this.activeMysqlQueue = new LinkedBlockingQueue<>();
for (int i = 0; i < initTotal; i++) {
this.mysqlConnQueue.offer(creatConnection());
count.incrementAndGet();
}
log.info("Mysql连接池初始化完成");
}
@Override
public Connection getConn() {
long startTime = System.currentTimeMillis();
//从空闲队列当中取出放入活动队列当中
Connection conn = this.mysqlConnQueue.poll();
if (conn == null) {
this.activeMysqlQueue.offer(conn);
return conn;
}
//如果当前连接数小于最大连接数进行创建新的连接
Integer maximumQuantity = Integer.valueOf(this.mysqlPoolConfig.getMaximumQuantity());
if (count.get() <maximumQuantity) {
Connection connection = creatConnection();
this.activeMysqlQueue.offer(connection);
count.incrementAndGet();
return connection;
}
if (System.currentTimeMillis() - startTime > this.mysqlPoolConfig.getMaximumTime()) {
throw new MysqlConnException("连接超时");
}
return null;
}
/**
*
*
* @param conn
*/
@Override
public void reaplase(Connection conn) {
//删除活动队列当中的连接
if (this.activeMysqlQueue.remove(conn)) {
//把这个连接放入空闲队列当中
this.mysqlConnQueue.offer(conn);
}
}
/**
* mysql
*/
@Override
public Connection creatConnection() {
String url = this.mysqlPoolConfig.getUrl();
String userName = this.mysqlPoolConfig.getDatabaseUserName();
String password = this.mysqlPoolConfig.getDatabaseUserPassword();
Connection connection = null;
try {
connection = DriverManager.getConnection(url, userName, password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
log.info("初始化了一个数据库连接:{ip: " + this.mysqlPoolConfig.getHostAddress() + " port: " + this.mysqlPoolConfig.getHostPort() + " databaseName: " + this.mysqlPoolConfig.getDatabaseName() + "}");
return connection;
}
/**
*
*/
@Override
public void closeConn() {
closeBaseConn();
closeActiveConn();
}
/**
*
*/
public void closeBaseConn() {
Connection poll = this.mysqlConnQueue.poll();
if (poll != null) {
try {
poll.close();
} catch (SQLException e) {
e.printStackTrace();
try{
if (!poll.isClosed()) {
this.mysqlConnQueue.offer(poll);
}
}catch (Exception e1){
e1.printStackTrace();
}
} finally {
closeBaseConn();
}
}
}
public void closeActiveConn() {
Connection poll = this.activeMysqlQueue.poll();
if (poll != null) {
try {
poll.close();
} catch (SQLException e) {
e.printStackTrace();
try{
if (!poll.isClosed()) {
this.activeMysqlQueue.offer(poll);
}
}catch (Exception e1){
e1.printStackTrace();
}
} finally {
closeBaseConn();
}
}
}
}

View File

@ -0,0 +1,134 @@
package com.muyu.data.source.client.pool.config;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.data.source.client.pool.BaseConfig;
import com.muyu.data.source.domain.SysDataSource;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
/**
* mysql
*
* @author WangLei
* @Date 2024/4/29 029 14:24
*/
@Data
@Builder
public class MysqlPoolConfig extends BaseConfig {
private static final long serialVersionUID = 1L;
/** 数据管理id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "数据管理id", value = "数据管理id")
private Long id;
/** 接入源名称 */
@Excel(name = "接入源名称")
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
private String accessSourceName;
/** 数据来源系统名称 */
@Excel(name = "数据来源系统名称")
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
private String dataSourceSystemName;
/** 主机地址 */
@Excel(name = "主机地址")
@ApiModelProperty(name = "主机地址", value = "主机地址")
private String hostAddress;
/** 主机端口 */
@Excel(name = "主机端口")
@ApiModelProperty(name = "主机端口", value = "主机端口")
private String hostPort;
/** 数据连接类型ID */
@Excel(name = "数据连接类型ID")
@ApiModelProperty(name = "数据连接类型ID", value = "数据连接类型ID")
private Long dataAccessTypeId;
/** 数据库名称 */
@Excel(name = "数据库名称")
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
private String databaseName;
/** 数据连接参数 */
@Excel(name = "数据连接参数")
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
private String dataConnectionParameter;
/** 初始连接数量 */
@Excel(name = "初始连接数量")
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
private String initialQuantity;
/** 最大连接数量 */
@Excel(name = "最大连接数量")
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
private String maximumQuantity;
/** 最大等待时间 */
@Excel(name = "最大等待时间")
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
private Long maximumTime;
/** 最大等待次数 */
@Excel(name = "最大等待次数")
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
private String maximumFrequency;
/** 数据库用户名 */
@Excel(name = "数据库用户名")
@ApiModelProperty(name = "数据库用户名", value = "数据库用户名")
private String databaseUserName;
/** 数据库用户密码 */
@Excel(name = "数据库用户密码")
@ApiModelProperty(name = "数据库用户密码", value = "数据库用户密码")
private String databaseUserPassword;
/** 驱动名称 */
@Excel(name = "驱动名称")
@ApiModelProperty(name = "驱动名称", value = "驱动名称")
private String driverName;
public static MysqlPoolConfig buildConfig(SysDataSource sysDataSource) {
return MysqlPoolConfig.builder()
.id(sysDataSource.getId())
.initialQuantity(sysDataSource.getInitialQuantity())
.maximumFrequency(sysDataSource.getMaximumFrequency())
.maximumQuantity(sysDataSource.getMaximumQuantity())
.driverName(sysDataSource.getDriverName())
.hostAddress(sysDataSource.getHostAddress())
.hostPort(sysDataSource.getHostPort())
.databaseName(sysDataSource.getDatabaseName())
.dataConnectionParameter(sysDataSource.getDataConnectionParameter())
.databaseUserName(sysDataSource.getDatabaseUserName())
.databaseUserPassword(sysDataSource.getDatabaseUserPassword())
.build();
}
/**
*
*/
public String getUrl() {
StringBuilder urlSb = new StringBuilder(BaseConfig.MYSQLJDBCPRO);
urlSb.append(this.hostAddress);
urlSb.append(":");
urlSb.append(this.hostPort);
urlSb.append("/");
urlSb.append(this.databaseName);
urlSb.append("?");
urlSb.append(this.dataConnectionParameter);
return urlSb.toString();
};
}

View File

@ -51,7 +51,7 @@ public class AssetStructure{
private String hostAddress; private String hostAddress;
/**主机端口*/ /**主机端口*/
private Integer hostPort; private String hostPort;
/**数据库用户名*/ /**数据库用户名*/
private String databaseUserName; private String databaseUserName;

View File

@ -0,0 +1,99 @@
package com.muyu.data.source.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* SysDataSource
*
* @author DeKangLiu
* Date 2024/5/9 22:38
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class SysDataSource {
private static final long serialVersionUID = 1L;
/** 数据管理id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "数据管理id", value = "数据管理id")
private Long id;
/** 接入源名称 */
@Excel(name = "接入源名称")
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
private String accessSourceName;
/** 数据来源系统名称 */
@Excel(name = "数据来源系统名称")
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
private String dataSourceSystemName;
/** 主机地址 */
@Excel(name = "主机地址")
@ApiModelProperty(name = "主机地址", value = "主机地址")
private String hostAddress;
/** 主机端口 */
@Excel(name = "主机端口")
@ApiModelProperty(name = "主机端口", value = "主机端口")
private String hostPort;
/** 数据连接类型ID */
@Excel(name = "数据连接类型ID")
@ApiModelProperty(name = "数据连接类型ID", value = "数据连接类型ID")
private Long dataAccessTypeId;
/** 数据库名称 */
@Excel(name = "数据库名称")
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
private String databaseName;
/** 数据连接参数 */
@Excel(name = "数据连接参数")
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
private String dataConnectionParameter;
/** 初始连接数量 */
@Excel(name = "初始连接数量")
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
private String initialQuantity;
/** 最大连接数量 */
@Excel(name = "最大连接数量")
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
private String maximumQuantity;
/** 最大等待时间 */
@Excel(name = "最大等待时间")
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
private Long maximumTime;
/** 驱动名*/
@Excel(name = "驱动名")
@ApiModelProperty(name = "驱动名", value = "驱动名")
private String driverName;
/** 最大等待次数 */
@Excel(name = "最大等待次数")
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
private String maximumFrequency;
/** 数据库用户名 */
@Excel(name = "数据库用户名")
@ApiModelProperty(name = "数据库用户名", value = "数据库用户名")
private String databaseUserName;
/** 数据库用户密码 */
@Excel(name = "数据库用户密码")
@ApiModelProperty(name = "数据库用户密码", value = "数据库用户密码")
private String databaseUserPassword;
}

View File

@ -16,5 +16,25 @@
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-source-common</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-security</artifactId>
</dependency>
</dependencies>
</project> </project>

View File

@ -0,0 +1,31 @@
package com.muyu.data.source.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.data.source.domain.DataSource;
import com.muyu.data.source.domain.req.DataSourceQueryReq;
import com.muyu.data.source.remote.factory.DataManagerFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* RemoteDataManagerService
*
* @author DeKangLiu
* Date 2024/5/9 17:23
*/
@FeignClient(
contextId = "RemoteSys",
value = ServiceNameConstants.DATA_SOURCE_SERVICE,
fallbackFactory = DataManagerFactory.class,
path = "/source"
)
public interface RemoteDataManagerService {
@PostMapping("/DataSourceList")
public Result<List<DataSource>> postList(DataSourceQueryReq dataSourceQueryReq);
}

View File

@ -0,0 +1,28 @@
package com.muyu.data.source.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.data.source.domain.DataSource;
import com.muyu.data.source.domain.req.DataSourceQueryReq;
import com.muyu.data.source.remote.RemoteDataManagerService;
import org.springframework.cloud.openfeign.FallbackFactory;
import java.util.List;
/**
* DataManagerFactory
*
* @author DeKangLiu
* Date 2024/5/9 17:32
*/
public class DataManagerFactory implements FallbackFactory<RemoteDataManagerService> {
@Override
public RemoteDataManagerService create(Throwable cause) {
return new RemoteDataManagerService() {
@Override
public Result<List<DataSource>> postList(DataSourceQueryReq dataSourceQueryReq) {
return Result.error(cause.getMessage());
}
};
}
}

View File

@ -22,7 +22,7 @@ import java.util.List;
* Controller * Controller
* *
* @ClassName AssetAuthInfoController * @ClassName AssetAuthInfoController
* @Author AnNan.Wang * @Author DekangLiu
* @Date 2024/5/5 15:38 * @Date 2024/5/5 15:38
*/ */

View File

@ -43,6 +43,14 @@ public class DataSourceController extends BaseController {
List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq)); List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
return getDataTable(list); return getDataTable(list);
} }
/**
* post
*/
@PostMapping("/DataSourceList")
public Result<List<DataSource>> postList(DataSourceQueryReq dataSourceQueryReq) {
List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
return Result.success(list);
}
/** /**
* *
@ -198,4 +206,9 @@ public class DataSourceController extends BaseController {
public Result updateDatabaseTable(@RequestBody DataBaseTable dataBaseTable){ public Result updateDatabaseTable(@RequestBody DataBaseTable dataBaseTable){
return dataSourceService.updateDatabaseTable(dataBaseTable); return dataSourceService.updateDatabaseTable(dataBaseTable);
} }
@PostMapping("/findDataSourceByDataBaseId")
public Result findDataSourceByDataBaseId(@RequestParam Integer id){
return dataSourceService.findDataSourceByDataBaseId(id);
}
} }

View File

@ -6,7 +6,7 @@ import com.muyu.data.source.domain.AssetAuthInfo;
/** /**
* AssetAuthInfo Mapper * AssetAuthInfo Mapper
* *
* @author AnNan.Wang * @author DekangLiu
* @ClassName: AssetAuthInfoMapper * @ClassName: AssetAuthInfoMapper
* @createTime: 2024/5/5 18:30 * @createTime: 2024/5/5 18:30
*/ */

View File

@ -50,6 +50,8 @@ public interface DataSourceMapper extends BaseMapper<DataSource> {
Integer updateDatabaseTable(@Param("dataBaseTable") DataBaseTable dataBaseTable); Integer updateDatabaseTable(@Param("dataBaseTable") DataBaseTable dataBaseTable);
DataBaseTable findDataBaseTableId(@Param("id") Integer id);
// AssetStructure findDatabaseName(DataSource dataSource); // AssetStructure findDatabaseName(DataSource dataSource);
// void updateAssets(@Param("assetStructure") AssetStructure assetStructure, @Param("id") Long id); // void updateAssets(@Param("assetStructure") AssetStructure assetStructure, @Param("id") Long id);

View File

@ -10,7 +10,7 @@ import java.util.List;
/** /**
* AssetAuthInfo Service * AssetAuthInfo Service
* *
* @author AnNan.Wang * @author DekangLiu
* @ClassName: AssetAuthInfoService * @ClassName: AssetAuthInfoService
* @createTime: 2024/5/5 15:40 * @createTime: 2024/5/5 15:40
*/ */

View File

@ -46,4 +46,6 @@ public interface DataSourceService extends IService<DataSource> {
Result<List<DatabaseTableInformation>> dataBaseTableInformation(); Result<List<DatabaseTableInformation>> dataBaseTableInformation();
Result updateDatabaseTable(DataBaseTable dataBaseTable); Result updateDatabaseTable(DataBaseTable dataBaseTable);
Result findDataSourceByDataBaseId(Integer id);
} }

View File

@ -18,7 +18,7 @@ import java.util.Objects;
* AssetAuthInfo Impl * AssetAuthInfo Impl
* *
* @ClassName AssetAuthInfoServiceImpl * @ClassName AssetAuthInfoServiceImpl
* @Author AnNan.Wang * @Author DekangLiu
* @Date 2024/5/5 18:29 * @Date 2024/5/5 18:29
*/ */

View File

@ -168,6 +168,10 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
assetStructure.setDatabaseTableName(rsmd.getTableName(1)); assetStructure.setDatabaseTableName(rsmd.getTableName(1));
assetStructure.setDataVolume(rsmd.getColumnDisplaySize(1)); assetStructure.setDataVolume(rsmd.getColumnDisplaySize(1));
assetStructure.setDataQuantity(rsmd.getColumnDisplaySize(1)); assetStructure.setDataQuantity(rsmd.getColumnDisplaySize(1));
assetStructure.setDatabaseUserName(dataSource.getDatabaseUserName());
assetStructure.setDatabaseUserPassword(dataSource.getDatabaseUserPassword());
assetStructure.setHostAddress(dataSource.getHostAddress());
assetStructure.setHostPort(dataSource.getHostPort());
if (list.size()==0){ if (list.size()==0){
return Result.error("数据库没有内容"); return Result.error("数据库没有内容");
} }
@ -322,5 +326,41 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
return Result.success("修改成功"); return Result.success("修改成功");
} }
@Override
public Result findDataSourceByDataBaseId(Integer id) {
DataBaseTable dataBaseTable=dataSourceMapper.findDataBaseTableId(id);
DatabaseTableInformation databaseTableInformation=dataSourceMapper.findDataBaseTableBy(Long.valueOf(dataBaseTable.getInformationId()));
AssetStructure assetStructure=dataSourceMapper.findAssetsById(databaseTableInformation.getStructureId());
//连接驱动
String user=assetStructure.getDatabaseUserName();
String password=assetStructure.getDatabaseUserPassword();
String jdbcDriver="com.mysql.cj.jdbc.Driver";
String url = "jdbc:mysql://" + assetStructure.getHostAddress() + ":" + assetStructure.getHostPort() + "/" + assetStructure.getDatabaseName();
//查询条件
String query="select * from "+databaseTableInformation.getName()+"limit 1 ";
try (Connection con = DriverManager.getConnection(url, user, password)){
PreparedStatement preparedStatement = con.prepareStatement(query);
ResultSet executeQuery = preparedStatement.executeQuery();
System.out.println("13");
return Result.success(executeQuery);
// ResultSetMetaData metaData1 = executeQuery.getMetaData();
// ResultSetMetaData metaData = preparedStatement.getMetaData();
// ParameterMetaData parameterMetaData = preparedStatement.getParameterMetaData();
// System.out.println(parameterMetaData);
// return Result.success(metaData1);
// System.out.println(metaData);
// return Result.success(metaData);
}catch (Exception e){
System.out.println("连接失败"+e.getMessage());
return Result.error("连接失败");
}
}
} }

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9527 port: 9101
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false"> <configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-system"/> <property name="log.path" value="logs/muyu-data-unit"/>
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>

View File

@ -215,6 +215,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="dataBaseTableInformation" resultType="com.muyu.data.source.domain.DatabaseTableInformation"> <select id="dataBaseTableInformation" resultType="com.muyu.data.source.domain.DatabaseTableInformation">
select *from database_table_information select *from database_table_information
</select> </select>
<select id="findDataBaseTableId" resultType="com.muyu.data.source.domain.DataBaseTable">
select * from database_table where id=#{id}
</select>
<!-- <select id="findDatabaseName" resultType="com.muyu.data.source.domain.AssetStructure">--> <!-- <select id="findDatabaseName" resultType="com.muyu.data.source.domain.AssetStructure">-->
<!-- select * from asset_structure--> <!-- select * from asset_structure-->
<!-- <where>--> <!-- <where>-->

View File

@ -15,8 +15,7 @@
<module>muyu-data-source-common</module> <module>muyu-data-source-common</module>
<module>muyu-data-source-remote</module> <module>muyu-data-source-remote</module>
<module>muyu-data-source-server</module> <module>muyu-data-source-server</module>
<module>muyu-data-source-access-server</module> <module>muyu-data-source-client</module>
<module>muyu-data-source-access-client</module>
</modules> </modules>
<properties> <properties>

View File

@ -0,0 +1,131 @@
<?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>muyu-modules</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-data-unit</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>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-source-client</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-rule-engine-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>
</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>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.muyu.ruleEngine.DeKangLiuRuleEngineApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,23 @@
package com.muyu.data.unit;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* DataSourceApplication
*
* @author DeKangLiu
* Date 2024/5/9 21:05
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class DataSourceUnitApplication {
public static void main(String[] args) {
SpringApplication.run(DataSourceUnitApplication.class, args);
}
}

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,30 @@
# Tomcat
server:
port: 9112
# Spring
spring:
application:
# 应用名称
name: muyu-data-unit
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.data.source.mapper: DEBUG

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-system"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9300 port: 9102
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9202 port: 9103
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9203 port: 9104
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -5,11 +5,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>muyu-data-source</artifactId> <artifactId>muyu-ruleengine</artifactId>
<version>3.6.3</version> <version>3.6.3</version>
</parent> </parent>
<artifactId>muyu-data-source-access-client</artifactId> <artifactId>muyu-ruleengine-client</artifactId>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>

View File

@ -20,7 +20,7 @@ import java.util.List;
/** /**
* ruleengine * ruleengine
* *
* @author WangLei * @author 43.142.149.172Lei
* @date 2024-04-24 * @date 2024-04-24
*/ */
@Data @Data

View File

@ -5,11 +5,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>muyu-data-source</artifactId> <artifactId>muyu-ruleengine</artifactId>
<version>3.6.3</version> <version>3.6.3</version>
</parent> </parent>
<artifactId>muyu-data-source-access-server</artifactId> <artifactId>muyu-ruleengine-remote</artifactId>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9216 port: 9105
# Spring # Spring
spring: spring:
@ -14,12 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -18,6 +18,8 @@
<modules> <modules>
<module>muyu-ruleengine-common</module> <module>muyu-ruleengine-common</module>
<module>muyu-ruleengine-server</module> <module>muyu-ruleengine-server</module>
<module>muyu-ruleengine-remote</module>
<module>muyu-ruleengine-client</module>
</modules> </modules>
</project> </project>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9201 port: 9111
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -15,6 +15,7 @@
<module>muyu-file</module> <module>muyu-file</module>
<module>muyu-data-source</module> <module>muyu-data-source</module>
<module>muyu-ruleengine</module> <module>muyu-ruleengine</module>
<module>muyu-data-unit</module>
</modules> </modules>
<artifactId>muyu-modules</artifactId> <artifactId>muyu-modules</artifactId>

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9100 port: 9106
# Spring # Spring
spring: spring:
@ -14,11 +14,12 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 115.159.81.159:8848 server-addr: 43.142.149.172:8848
namespace: f394dee0-fead-4010-8359-2955bacca31f namespace: fa965f4b-c851-46c9-8ddb-dbc5cb4aa039
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置