回滚了
parent
78683f698c
commit
af1bc4fc94
|
@ -0,0 +1,27 @@
|
|||
<?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-access</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-access-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-access-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
package com.muyu.data.access.client.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@ComponentScan
|
||||
@Import(value = {DataAccessClientRunner.class})
|
||||
public class DataAccessClientConfig {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.data.access.client.config;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import com.nuyu.data.access.remote.RemoteDataAccessService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
|
||||
@Log4j2
|
||||
public class DataAccessClientRunner implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private RemoteDataAccessService remoteDataAccessService;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Result<TableDataInfo<DataSource>> result = remoteDataAccessService.list(new DataSource());
|
||||
List<DataSource> dataSourceList = result.getData().getRows();
|
||||
MyDataSource.info(dataSourceList);
|
||||
String key=dataSourceList.get(0).getDataSourceName()+"_"+dataSourceList.get(0).getId();
|
||||
System.out.println("查看连接池:");
|
||||
MyDataSource.size(key);
|
||||
Thread.sleep(500);
|
||||
System.out.println("取出一个链接,查看连接池:");
|
||||
Connection con = MyDataSource.getCon(key);
|
||||
MyDataSource.size(key);
|
||||
Thread.sleep(500);
|
||||
System.out.println("返回一个链接,查看连接池:");
|
||||
MyDataSource.addBack(con);
|
||||
MyDataSource.size(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.etl.config.DataAccessClientConfig
|
|
@ -0,0 +1,100 @@
|
|||
<?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-access</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-access-common</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>
|
||||
<!-- Maven 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- PostgreSQL JDBC驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</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>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
package com.muyu;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.muyu.etl.datasource;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.muyu.etl.domain.DataSource;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName MyDataSource
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/5/9 19:36
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class MyDataSource {
|
||||
private static HashMap<String, DruidDataSource> pools = new HashMap<>();
|
||||
|
||||
public static void info(List<DataSource> dataSourceList){
|
||||
dataSourceList.stream().forEach(dataSource -> {
|
||||
String jdbcUrl = "jdbc:"+dataSource.getType().toLowerCase()+"://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
|
||||
// 创建德鲁伊数据源
|
||||
DruidDataSource druidSource = new DruidDataSource();
|
||||
|
||||
// 配置数据库连接信息
|
||||
druidSource.setUrl(jdbcUrl);
|
||||
druidSource.setUsername(dataSource.getUsername());
|
||||
druidSource.setPassword(dataSource.getPassword());
|
||||
// 配置连接池大小
|
||||
druidSource.setInitialSize(Integer.valueOf(dataSource.getInitNum().toString()));
|
||||
druidSource.setMinIdle(5);
|
||||
druidSource.setMaxActive(Integer.valueOf(dataSource.getMaxNum().toString()));
|
||||
try {
|
||||
druidSource.init();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
pools.put(dataSource.getDataSourceName()+"_"+dataSource.getId(),druidSource);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static Connection getCon(String key){
|
||||
try {
|
||||
//根据key获取连接池
|
||||
DruidDataSource druidDataSource = pools.get(key);
|
||||
// 从连接池中获取第一个链接
|
||||
return druidDataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 4 提供非静态方法,用来归还链接
|
||||
public static void addBack(Connection connection){
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void size(String key){
|
||||
//根据key获取连接池
|
||||
DruidDataSource druidDataSource = pools.get(key);
|
||||
//获取正在使用的连接数量
|
||||
int activeCount = druidDataSource.getActiveCount();
|
||||
//获取线程池中的连接数量
|
||||
int poolingCount = druidDataSource.getPoolingCount();
|
||||
log.info(key+" 连接池中正在使用连接: "+activeCount+"个 ,线程池中线程数量: "+poolingCount+"个");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 asset_accredit
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AssetAccredit extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 部门id */
|
||||
@Excel(name = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 数据表id */
|
||||
@Excel(name = "数据表id")
|
||||
private Long dataAssetId;
|
||||
|
||||
|
||||
/** 用户id */
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 asset_model
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-22
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AssetModel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 数据资产ID */
|
||||
@Excel(name = "数据资产ID")
|
||||
private Long dataAssetId;
|
||||
|
||||
/** 字段名 */
|
||||
@Excel(name = "字段名")
|
||||
private String name;
|
||||
|
||||
/** 字段备注 */
|
||||
@Excel(name = "字段备注")
|
||||
private String comment;
|
||||
|
||||
/** 是否主键 */
|
||||
@Excel(name = "是否主键")
|
||||
private String isPrimaryKey;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String type;
|
||||
|
||||
/** 映射数据类型 */
|
||||
@Excel(name = "映射数据类型")
|
||||
private String mappingType;
|
||||
|
||||
/** 长度 */
|
||||
@Excel(name = "长度")
|
||||
private String length;
|
||||
|
||||
/** 小数位 */
|
||||
@Excel(name = "小数位")
|
||||
private String decimalPlaces;
|
||||
|
||||
/** 是否不可为空 */
|
||||
@Excel(name = "是否不可为空")
|
||||
private String isNull;
|
||||
|
||||
/** 是否字典 */
|
||||
@Excel(name = "是否字典")
|
||||
private String isDict;
|
||||
|
||||
/** 默认值 */
|
||||
@Excel(name = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/** 字典key */
|
||||
@Excel(name = "字典key")
|
||||
private String dictKey;
|
||||
/** 字典id */
|
||||
@Excel(name = "字典key")
|
||||
private Long dictionaryId;
|
||||
|
||||
/** 字典信息 */
|
||||
@Excel(name = "字典信息")
|
||||
private List<DictionaryData> dictionaryDatas;
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 data_asset
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-22
|
||||
*/
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataAsset extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 数据接入ID */
|
||||
@Excel(name = "数据接入ID")
|
||||
private Long dataSourceId;
|
||||
|
||||
/** 表名称 */
|
||||
@Excel(name = "表名称")
|
||||
private String tableName;
|
||||
|
||||
/** 表备注 */
|
||||
@Excel(name = "表备注")
|
||||
private String tableComment;
|
||||
|
||||
/** 数据量 */
|
||||
@Excel(name = "数据量")
|
||||
private Long tableCount;
|
||||
|
||||
/** 资产模型 */
|
||||
@Excel(name = "资产模型")
|
||||
private Long fields;
|
||||
|
||||
public DataAsset dataAssetBuilder(DataSource dataSource, ResultSet resultSet) {
|
||||
try {
|
||||
return DataAsset.builder()
|
||||
.tableName(resultSet.getString("t_name"))
|
||||
.tableComment(resultSet.getString("table_comment") == null ? "-":resultSet.getString("table_comment"))
|
||||
.tableCount(Long.valueOf(resultSet.getString("table_rows")))
|
||||
.fields(Long.valueOf(resultSet.getString("fields")))
|
||||
.dataSourceId(dataSource.getId())
|
||||
.createBy(SecurityUtils.getUsername())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 data_source
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DataSource extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String dataSourceName;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String linkAddress;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String port;
|
||||
private String sql;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String databaseName;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String username;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String password;
|
||||
|
||||
private String tableName;
|
||||
|
||||
/** 数据连接参数 */
|
||||
@Excel(name = "数据连接参数")
|
||||
private String connectionParam;
|
||||
|
||||
/** 初始连接数量 */
|
||||
@Excel(name = "初始连接数量")
|
||||
private Long initNum;
|
||||
|
||||
/** 最大连接数量 */
|
||||
@Excel(name = "最大连接数量")
|
||||
private Long maxNum;
|
||||
private Long count;
|
||||
|
||||
/** 最大等待时间 */
|
||||
@Excel(name = "最大等待时间")
|
||||
private Long maxWaitTime;
|
||||
|
||||
/** 最大等待次数 */
|
||||
@Excel(name = "最大等待次数")
|
||||
private Long maxWaitSize;
|
||||
|
||||
/** $column.columnComment */
|
||||
private String type;
|
||||
|
||||
/** 数据来源名称 */
|
||||
@Excel(name = "数据来源名称")
|
||||
private String systemName;
|
||||
/** 连接驱动名称 */
|
||||
@Excel(name = "连接驱动名称")
|
||||
private String jdbcDriver;
|
||||
|
||||
/** 模式名称 */
|
||||
@Excel(name = "数据来源名称")
|
||||
private String modeName;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 dictionary
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class Dictionary extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 字典名称 */
|
||||
@Excel(name = "字典名称")
|
||||
private String dictionaryName;
|
||||
|
||||
/** 字典key */
|
||||
@Excel(name = "字典key")
|
||||
private String dictionaryKey;
|
||||
|
||||
/** 数据源ID */
|
||||
@Excel(name = "数据源ID")
|
||||
private Long dataSourceId;
|
||||
|
||||
/** 字典数据集合 */
|
||||
@Excel(name = "数据源ID")
|
||||
private List<DictionaryData> dictionaryDataList;
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 dictionary_data
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-24
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DictionaryData extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 字典表ID */
|
||||
@Excel(name = "字典表ID")
|
||||
private Long dictionaryId;
|
||||
|
||||
/** 字典标签 */
|
||||
@Excel(name = "字典标签")
|
||||
private String label;
|
||||
|
||||
/** 字典值 */
|
||||
@Excel(name = "字典值")
|
||||
private String val;
|
||||
|
||||
/** 是否修改 */
|
||||
@Excel(name = "字典值")
|
||||
private Boolean isEdit=false;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 source_accredit
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class SourceAccredit extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 部门id */
|
||||
@Excel(name = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 数据源id */
|
||||
@Excel(name = "数据源id")
|
||||
private Long dataSourceId;
|
||||
|
||||
|
||||
/** 用户id */
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.etl.domain.custom;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName AssetsModule
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/21 9:54
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AssetsModule {
|
||||
private HashMap<String, String> structure;
|
||||
private List<Map<String, VTClass>> kvtList;
|
||||
|
||||
private List<TableAssets> tableAssets;
|
||||
private TableDetail tableDetail;
|
||||
|
||||
public AssetsModule assetsModuleBuilder(List<Map<String, VTClass>> kvtList, HashMap<String, String> map) {
|
||||
return AssetsModule.builder()
|
||||
.kvtList(kvtList)
|
||||
.structure(map)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.muyu.etl.domain.custom;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName Statistics
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/23 20:43
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Statistics {
|
||||
private Long dataAsset;
|
||||
private Long assetModel;
|
||||
private Long dataModel;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.etl.domain.custom;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName TableAssets
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/21 11:20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableAssets {
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 字段注释
|
||||
*/
|
||||
private String comment;
|
||||
/**
|
||||
* 是否主键
|
||||
*/
|
||||
private String isPrimaryKey;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 映射类型
|
||||
*/
|
||||
private String mappingType;
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
private String length;
|
||||
/**
|
||||
* 小数位
|
||||
*/
|
||||
private String decimalPlaces;
|
||||
/**
|
||||
* 是否可为空
|
||||
*/
|
||||
private String isNull;
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private String defaultValue;
|
||||
/**
|
||||
* 是否字典
|
||||
*/
|
||||
private String isDict;
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
private String dictKey;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.etl.domain.custom;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName TableDetail
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/21 18:27
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableDetail {
|
||||
private String tableName;
|
||||
private String tableComment;
|
||||
private Long tableCount;
|
||||
private List<TableAssets> tableAssets;
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.etl.domain.custom;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName TestClass
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/4/19 20:31
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VTClass {
|
||||
private String value;
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?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-access</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-access-remote</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-access-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- PostgreSQL JDBC驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</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>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package com.nuyu.data.access.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.etl.domain.DataSource;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteDataAccessService",
|
||||
value = ServiceNameConstants.DATA_ACCESS_SERVICE,
|
||||
fallbackFactory = DataAccessFallbackFactory.class)
|
||||
public interface RemoteDataAccessService {
|
||||
@PostMapping("/source/list")
|
||||
public Result<TableDataInfo<DataSource>> list(@RequestBody DataSource dataSource);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.nuyu.data.access.remote.factory;
|
||||
|
||||
public class DataManageFactory {
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.etl.factory.DataAccessFallbackFactory
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.etl.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AccreditModel {
|
||||
|
||||
/**
|
||||
* 用于存储与用户认证相关的模型ID
|
||||
*/
|
||||
private List<Long> userAccreditModelIds;
|
||||
|
||||
/**
|
||||
* 用于存储与部门认证相关的模型ID
|
||||
*/
|
||||
private List<Long> deptAccreditModelIds;
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.etl.domain.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class AssetAccreditReq {
|
||||
|
||||
/**
|
||||
* 存储部门ID的列表。
|
||||
*/
|
||||
private List<Long> deptIds;
|
||||
|
||||
/**
|
||||
* 用户ID。
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 数据资产ID。
|
||||
*/
|
||||
private Long dataAssetId;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.etl.domain.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SourceAccreditReq {
|
||||
|
||||
/**
|
||||
* 存储需要授权的部门ID列表。
|
||||
*/
|
||||
private List<Long> deptIds;
|
||||
|
||||
/**
|
||||
* 请求授权的用户ID。
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 源数据ID,标识了要授权的数据源。
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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-access</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>muyu-data-access-server</module>
|
||||
<module>muyu-data-access-client</module>
|
||||
<module>muyu-data-access-remote</module>
|
||||
<module>muyu-data-access-common</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,100 @@
|
|||
<?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-access</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-access-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>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-access-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- PostgreSQL JDBC驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</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>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
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;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class DataUnitApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataUnitApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9212
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
redis:
|
||||
host: 101.34.248.9
|
||||
port: 6379
|
||||
password: jp@123
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-data-unit
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 101.34.248.9:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 101.34.248.9:8848
|
||||
namespace: b9d88e07-8713-4ccd-8e98-d7c19f40fe74
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.rule.engine.mapper: DEBUG
|
|
@ -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-data-unit"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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>
|
|
@ -0,0 +1,27 @@
|
|||
<?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-rule-engine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-rule-engine-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-rule-engine-remote</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.rule.engine.client.config;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.rule.engine.RemoteRuleEngineService;
|
||||
import com.muyu.rule.engine.domain.EngineMaintenance;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RuleEngineClientRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RemoteRuleEngineService remoteRuleEngineService;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Result<TableDataInfo<EngineMaintenance>> result = remoteRuleEngineService.list(new EngineMaintenance());
|
||||
List<EngineMaintenance> engineMaintenanceList = result.getData().getRows();
|
||||
log.info(engineMaintenanceList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.muyu.rule.engine.client.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@ComponentScan
|
||||
@Import({RuleEngineClientRunner.class})
|
||||
public class RuleEngineClineConfig {
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.rule.engine.client.config.RuleEngineClineConfig
|
|
@ -0,0 +1,85 @@
|
|||
<?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-rule-engine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-rule-engine-common</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>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.rule.engine.constant;
|
||||
|
||||
/**
|
||||
* @ClassName GenerateConstant
|
||||
* @Description 描述
|
||||
* @Author Xin.Yao
|
||||
* @Date 2024/5/7 19:45
|
||||
*/
|
||||
public class GenerateConstant {
|
||||
public static final String ACTION_IMPORT = "import com.muyu.rule.engine.action.ActionDiscard;";
|
||||
public static final String SCOPE_IMPORT = "import com.muyu.rule.engine.scope.";
|
||||
public static final String PACKAGE_PATH = "package com.muyu.rule.rule.engine.";
|
||||
public static final String str = "package com.muyu.rule.rule.engine.custom;\n" +
|
||||
"import com.muyu.rule.engine.action.ActionDiscard;\n" +
|
||||
"import com.muyu.rule.engine.scope.DataSetEngine;\n" +
|
||||
"\n" +
|
||||
"/**\n" +
|
||||
" * @Author: YaoXin\n" +
|
||||
" * @date: 2024/05/06\n" +
|
||||
" * @Description: 测试-test\n" +
|
||||
" * @Version: 1.0\n" +
|
||||
" */\n" +
|
||||
"public class engine_custom_testThree_test extends DataSetEngine {\n" +
|
||||
" @Override\n" +
|
||||
" public void execution () {\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.muyu.rule.engine.constant;
|
||||
|
||||
public class PathConstant {
|
||||
public static final String JAVA_PATH = "D:\\work\\ruoyi-cloud-server\\muyu-modules\\muyu-rule-engine\\src\\main\\java\\com\\muyu\\rule\\engine\\custom\\";
|
||||
public static final String CLASS_PATH = "D:\\work\\ruoyi-cloud-server\\muyu-modules\\muyu-rule-engine\\target\\classes\\";
|
||||
public static final String PACKAGE_PATH_SERVICE = "com.muyu.rule.engine.custom";
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Engine extends BaseEntity {
|
||||
/**
|
||||
* 规则主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 规则类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 引擎编码
|
||||
*/
|
||||
|
||||
private String code;
|
||||
/**
|
||||
* 级别
|
||||
*/
|
||||
private String level;
|
||||
/**
|
||||
*引擎规范
|
||||
*/
|
||||
private String engineCode;
|
||||
|
||||
/**
|
||||
* 是否激活
|
||||
*/
|
||||
private String isActivate;
|
||||
/**
|
||||
* 规则状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 编辑文本
|
||||
*/
|
||||
private String codeText;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
private List<EngineVersion> versionList;
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EngineVersion extends BaseEntity {
|
||||
private Long id;
|
||||
private Long ruleEngineId;
|
||||
private String name;
|
||||
private String code;
|
||||
private Integer status;
|
||||
private String codeIng;
|
||||
private String versionCode;
|
||||
private Integer isActivate;
|
||||
private String isTest;
|
||||
private String description;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package com.muyu.rule.engine.domain;
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
|
||||
public class RuleHhhClass {
|
||||
public void test() {
|
||||
System.out.println("亮哥好!!!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
|
||||
public class RuleLalalaClass {
|
||||
public void test() {
|
||||
System.out.println("亮哥好!!!五一快乐");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
|
||||
public class RuleMmClass {
|
||||
public void test() {
|
||||
System.out.println("4444788788878744");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
|
||||
public class RuleMnmClass {
|
||||
public void test() {
|
||||
System.out.println("444444");
|
||||
}
|
||||
}
|
|
@ -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>muyu-rule-engine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-rule-engine-remote</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-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-rule-engine-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.rule.engine;
|
||||
|
||||
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.rule.engine.domain.Engine;
|
||||
import com.muyu.rule.engine.factory.RemoteRuleEngineFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteRuleEngineService",
|
||||
value = ServiceNameConstants.RULE_ENGINE_SERVICE,
|
||||
fallbackFactory = RemoteRuleEngineFallbackFactory.class)
|
||||
public interface RemoteRuleEngineService {
|
||||
@PostMapping("/maintenance/list")
|
||||
public Result<TableDataInfo<Engine>> list(@RequestBody Engine engine);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.rule.engine.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.rule.engine.RemoteRuleEngineService;
|
||||
import com.muyu.rule.engine.domain.EngineMaintenance;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RemoteRuleEngineFallbackFactory implements FallbackFactory<RemoteRuleEngineService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteRuleEngineFallbackFactory.class);
|
||||
@Override
|
||||
public RemoteRuleEngineService create(Throwable cause) {
|
||||
return new RemoteRuleEngineService() {
|
||||
@Override
|
||||
public Result<TableDataInfo<EngineMaintenance>> list(EngineMaintenance engineMaintenance) {
|
||||
return Result.error("规则引擎列表获取失败");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.rule.engine.factory.RemoteRuleEngineFallbackFactory
|
|
@ -0,0 +1,85 @@
|
|||
<?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-rule-engine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-rule-engine-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>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
package com.muyu.engine.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.engine.domain.Engine;
|
||||
import com.muyu.engine.service.EngineService;
|
||||
import org.apache.catalina.Engine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/maintenance")
|
||||
public class EngineController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private EngineService engineService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Engine>> list(Engine engine)
|
||||
{
|
||||
startPage();
|
||||
List<Engine> list = engineService.selectEngineList(engine);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出【请填写功能名称】列表
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Engine engine)
|
||||
{
|
||||
List<Engine> list = engineService.selectEngineList(engine);
|
||||
ExcelUtil<Engine> util = new ExcelUtil<Engine>(Engine.class);
|
||||
util.exportExcel(response, list, "【请填写功能名称】数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(engineService.selectEngineById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试方法
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/TestMethod")
|
||||
public Result testMethod(@RequestParam("code") String code)
|
||||
{
|
||||
return EngineService.testMethod(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@PostMapping
|
||||
public Result add(@RequestBody Engine Engine)
|
||||
{
|
||||
return toAjax(EngineService.insertEngine(Engine));
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化规则引擎类
|
||||
*/
|
||||
@PostMapping("/InitializeRuleEngine")
|
||||
public Result initializeRuleEngine(@RequestBody Engine Engine)
|
||||
{
|
||||
return EngineService.initializeRuleEngine(Engine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody Engine Engine)
|
||||
{
|
||||
return toAjax(EngineService.updateEngine(Engine));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*/
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(EngineService.deleteEngineByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎是否激活
|
||||
*/
|
||||
@PostMapping("/updIsActivate")
|
||||
public Result updIsActivate(@RequestParam("id") Long id,@RequestParam("isActivate") String isActivate) {
|
||||
EngineService.updIsActivate(id,isActivate);
|
||||
return Result.success();
|
||||
}
|
||||
/**
|
||||
* 修改引擎状态
|
||||
*/
|
||||
@PostMapping("updStatus")
|
||||
public Result updStatus(@RequestParam("id") Long id,@RequestParam("status") String status) {
|
||||
EngineService.updStatus(id,status);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.rule.engine.domain;
|
||||
|
||||
|
||||
public class RuleLalalaClass {
|
||||
public void test() {
|
||||
System.out.println("亮哥好!!!五一快乐");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.engine.mapper;
|
||||
|
||||
import com.muyu.engine.domain.Engine;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface EngineMapper {
|
||||
|
||||
List<Engine> selectEngineList(Engine engine);
|
||||
|
||||
Engine selectEngineById(Long id);
|
||||
|
||||
int updateEngine(Engine engine);
|
||||
|
||||
int deleteEngineByIds(Long[] ids);
|
||||
|
||||
int deleteEngineById(Long id);
|
||||
|
||||
int insertEngine(Engine engine);
|
||||
|
||||
void updIsActivate(@Param("id") Long id, @Param("isActivate") String isActivate);
|
||||
|
||||
void updStatus(@Param("id") Long id, @Param("status") String status);
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.engine.service;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import org.apache.catalina.Engine;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface EngineService {
|
||||
|
||||
List<Engine> selectEngineList(Engine engine);
|
||||
|
||||
Engine selectEngineById(Long id);
|
||||
|
||||
Result testMethod(String code);
|
||||
|
||||
int insertEngine(Engine engine);
|
||||
|
||||
Result initializeRuleEngine(Engine engine);
|
||||
|
||||
|
||||
int updateEngine(Engine engine);
|
||||
|
||||
int deleteEngineByIds(Long[] ids);
|
||||
int deleteEngineById(Long id);
|
||||
|
||||
void updIsActivate(Long id,String isActivate);
|
||||
|
||||
void updStatus(Long id, String status);
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
package com.muyu.engine.service.impl;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.engine.ClassLoading.CustomClassLoader;
|
||||
import com.muyu.engine.domain.Engine;
|
||||
import com.muyu.engine.domain.EngineVersion;
|
||||
import com.muyu.engine.mapper.EngineMapper;
|
||||
import com.muyu.engine.service.EngineService;
|
||||
import com.muyu.engine.service.EngineVersionService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class EngineServiceImpl implements EngineService {
|
||||
|
||||
@Autowired
|
||||
private EngineMapper engineMapper;
|
||||
|
||||
@Autowired
|
||||
private EngineVersionService engineVersionService;
|
||||
@Override
|
||||
public List<Engine> selectEngineList(Engine engine) {
|
||||
List<Engine> engines = engineMapper.selectEngineList(engine);
|
||||
return engines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine selectEngineById(Long id) {
|
||||
List<EngineVersion> versionList = engineVersionService.byId(id);
|
||||
Engine engine = engineMapper.selectEngineById(id);
|
||||
engine.setVersionList(versionList);
|
||||
|
||||
return engine;
|
||||
}
|
||||
/**
|
||||
* 插入一个新的引擎信息到数据库。
|
||||
* @param engine 引擎对象,包含引擎的相关信息。
|
||||
* @return 返回插入操作影响的行数。
|
||||
*/
|
||||
@Override
|
||||
public int insertEngine(Engine engine) {
|
||||
// 生成引擎类的名称,规则是首字母大写,后面跟引擎代码,再加"class"后缀
|
||||
String className= "Rule"+Character.toUpperCase(engine.getCode().charAt(0))+engine.getCode().substring(1)+"Class";
|
||||
|
||||
// 设置创建者为当前登录用户的用户名
|
||||
engine.setCreateBy(SecurityUtils.getUsername());
|
||||
// 设置创建时间为当前时间
|
||||
engine.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
// 设置引擎的代码文本,生成一个空的Java类
|
||||
engine.setCodeText("package com.muyu.engine.domain;\n\n\n"+
|
||||
"public class " +className+"{\n"+
|
||||
"}");
|
||||
// 调用mapper层执行插入操作,并返回影响的行数
|
||||
return engineMapper.insertEngine(engine);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试方法,通过传入的代码字符串动态加载类并执行其中的方法。
|
||||
* @param code 代表要加载的规则类的代码标识,将用于构造类名。
|
||||
* @return 返回执行结果,成功则返回"测试成功",失败则返回错误信息。
|
||||
*/
|
||||
@Override
|
||||
public Result testMethod(String code) {
|
||||
String className = "com.muyu.rule.engine.domain.Rule"+Character.toUpperCase(code.charAt(0)) + code.substring(1)+"Class";
|
||||
String classPath = "D:\\work\\2108A\\sxh\\muyu-modules\\muyu-rule-engine\\muyu-rule-engine-server\\target\\classes\\"+className.replace(".", "\\")+".class";
|
||||
try {
|
||||
// 读取类文件
|
||||
byte[] classData = Files.readAllBytes(Paths.get(classPath));
|
||||
CustomClassLoader customClassLoader = new CustomClassLoader();
|
||||
Class<?> aClass = customClassLoader.defineClassFromBytes(className,classData);
|
||||
// 实例化类
|
||||
Object obj = aClass.newInstance();
|
||||
//获取类中所有方法
|
||||
Method[] methods = aClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
method.invoke(obj);
|
||||
}
|
||||
customClassLoader = null;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
Result.error("测试失败");
|
||||
}
|
||||
|
||||
return Result.success("测试成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化规则引擎。
|
||||
* 根据给定的引擎代码动态生成Java类,并编译该类。
|
||||
*
|
||||
* @param engine 引擎对象,包含引擎的代码文本。
|
||||
* @return 返回初始化结果,成功则返回带有成功信息的Result对象,失败则返回带有失败信息的Result对象。
|
||||
*/
|
||||
@Override
|
||||
public Result initializeRuleEngine(Engine engine) {
|
||||
try{
|
||||
// 根据引擎代码生成类名
|
||||
String className= "Rule"+Character.toUpperCase(engine.getCode().charAt(0))+engine.getCode().substring(1)+"Class";
|
||||
// 设置类文件路径
|
||||
String classPath = "D:\\work\\2108A\\sxh\\muyu-modules\\muyu-rule-engine\\muyu-rule-engine-server\\target\\classes\\";
|
||||
// 设置Java源文件路径
|
||||
String javaPath = "D:\\work\\2108A\\sxh\\muyu-modules\\muyu-rule-engine\\muyu-rule-engine-server\\src\\main\\java\\com\\muyu\\engine\\domain\\";
|
||||
// 拼接文件完整路径名
|
||||
String fileName=javaPath+className+".java";
|
||||
// 创建或获取文件及其父目录
|
||||
File file = new File(fileName);
|
||||
File filePath = file.getParentFile();
|
||||
if (!filePath.exists()){
|
||||
filePath.mkdir();
|
||||
}
|
||||
// 如果文件已存在,则删除
|
||||
if (file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
// 创建新文件
|
||||
file.createNewFile();
|
||||
// 写入引擎代码文本到文件
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
fileWriter.write(engine.getCodeText());
|
||||
fileWriter.flush();
|
||||
fileWriter.close();
|
||||
|
||||
// 使用系统Java编译器编译Java文件
|
||||
JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
// 获取标准的Java文件管理器
|
||||
StandardJavaFileManager fileManager = systemJavaCompiler.getStandardFileManager(null, null, null);
|
||||
// 将文件名转换为Java文件对象的可迭代集合
|
||||
Iterable javaFileObjects = fileManager.getJavaFileObjects(fileName);
|
||||
// 设置编译选项,指定输出路径
|
||||
List<String> list = Arrays.asList("-d", classPath);
|
||||
// 创建编译任务
|
||||
JavaCompiler.CompilationTask task = systemJavaCompiler.getTask(null, fileManager, null, list, null, javaFileObjects);
|
||||
// 执行编译任务并返回结果
|
||||
Boolean call = task.call();
|
||||
// 关闭文件管理器
|
||||
fileManager.close();
|
||||
|
||||
// 根据编译结果返回初始化结果
|
||||
if (call){
|
||||
return Result.success("初始化成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("初始化失败");
|
||||
Result.error("初始化失败");
|
||||
}
|
||||
|
||||
return Result.success("初始化失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateEngine(Engine engine) {
|
||||
engine.setUpdateBy(SecurityUtils.getUsername());
|
||||
engine.setUpdateTime(new Date());
|
||||
return engineMapper.updateEngine(engine);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteEngineByIds(Long[] ids) {
|
||||
return engineMapper.deleteEngineByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteEngineById(Long id) {
|
||||
return engineMapper.deleteEngineById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updIsActivate(Long id,String isActivate) {
|
||||
if (isActivate.equals("1")){
|
||||
engineMapper.updIsActivate(id,"2");
|
||||
}else if (isActivate.equals("2")){
|
||||
engineMapper.updIsActivate(id,"1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updStatus(Long id, String status) {
|
||||
if (status.equals("0")){
|
||||
engineMapper.updStatus(id,"1");
|
||||
}else if (status.equals("1")){
|
||||
engineMapper.updStatus(id,"0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.muyu.engine.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.engine.domain.EngineVersion;
|
||||
import com.muyu.engine.mapper.EngineVersionMapper;
|
||||
import com.muyu.engine.service.EngineVersionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-05-06
|
||||
*/
|
||||
@Service
|
||||
public class EngineVersionServiceImpl implements EngineVersionService {
|
||||
|
||||
@Autowired
|
||||
private EngineVersionMapper engineVersionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public EngineVersion selectEngineVersionById(Long id)
|
||||
{
|
||||
return engineVersionMapper.selectEngineVersionById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param engineVersion 【请填写功能名称】
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<EngineVersion> selectEngineVersionList(EngineVersion engineVersion)
|
||||
{
|
||||
return engineVersionMapper.selectEngineVersionList(engineVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param engineVersion 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEngineVersion(EngineVersion engineVersion)
|
||||
{
|
||||
engineVersion.setCreateTime(DateUtils.getNowDate());
|
||||
engineVersion.setCreateBy(SecurityUtils.getUsername());
|
||||
engineVersion.setIsTest("1");
|
||||
return engineVersionMapper.insertEngineVersion(engineVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param engineVersion 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateEngineVersion(EngineVersion engineVersion)
|
||||
{
|
||||
engineVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
return engineVersionMapper.updateEngineVersion(engineVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEngineVersionByIds(Long[] ids)
|
||||
{
|
||||
|
||||
return engineVersionMapper.deleteEngineVersionByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEngineVersionById(Long id)
|
||||
{
|
||||
return engineVersionMapper.deleteEngineVersionById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EngineVersion> byId(Long id) {
|
||||
List<EngineVersion> engineVersion = engineVersionMapper.byId(id);
|
||||
return engineVersion;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue