feat():分离客户端

master
Saisai Liu 2024-05-09 21:55:18 +08:00
parent 8750b7d1cb
commit 8ec267ac4b
69 changed files with 789 additions and 48 deletions

View File

@ -16,6 +16,11 @@ public class ServiceNameConstants {
*/
public static final String SYSTEM_SERVICE = "muyu-system";
/**
* serviceid
*/
public static final String ENGINE_SERVICE = "muyu-engine";
/**
* serviceid
*/

View File

@ -0,0 +1,126 @@
<?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-etl</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-etl-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>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.8</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</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>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-remote</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
package com.muyu;
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.cloud.openfeign.EnableFeignClients;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@EnableFeignClients
@SpringBootApplication
public class EtlClientApplication {
public static void main(String[] args) {
SpringApplication.run(EtlClientApplication.class);
}
}

View File

@ -0,0 +1,33 @@
package com.muyu.etl;
import com.etl.RemoteAssetService;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.etl.domain.BasicConfigInfo;
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;
/**
* @ClassName EtlRunner
* @Description
* @Author SaiSai.Liu
* @Date 2024/5/9 21:26
*/
@Component
@Log4j2
public class EtlRunner implements ApplicationRunner {
@Autowired
private RemoteAssetService remoteAssetService;
@Override
public void run(ApplicationArguments args) throws Exception {
List<BasicConfigInfo> rows = remoteAssetService.list(null, SecurityConstants.INNER).getData().getRows();
log.info(rows);
}
}

View File

@ -0,0 +1,17 @@
package com.muyu.etl.config;
import com.muyu.etl.EtlRunner;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
/**
* @ClassName AssetClientConfig
* @Description
* @Author SaiSai.Liu
* @Date 2024/5/9 21:45
*/
@Component
@Import(value = {EtlRunner.class})
public class AssetClientConfig {
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyv-etl</artifactId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>

View File

@ -0,0 +1,59 @@
package com.muyu.etl.domain.req;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @ClassName TableInfoScopeReq
* @Description
* @Author SaiSai.Liu
* @Date 2024/5/9 14:15
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class TableInfoScopeReq {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long basicId;
/** 表名称/数据库 */
@Excel(name = "表名称/数据库")
private String tableName;
/** 表备注 */
@Excel(name = "表备注")
private String tableRemark;
/** 表备注 */
@Excel(name = "数据来源类型")
private String type;
/** 数据量 */
@Excel(name = "数据量")
private Long dataNum;
/** 是否核心 'Y'是 'N'不是 */
@Excel(name = "是否核心 'Y'是 'N'不是")
private String center;
private Long parentId;
/**
*
*/
private String level;
}

View File

@ -0,0 +1,97 @@
package com.muyu.etl.domain.resp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.etl.domain.Structure;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @ClassName StructureValueResp
* @Description
* @Author SaiSai.Liu
* @Date 2024/5/9 15:08
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class StructureValueResp {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/** 表id */
@Excel(name = "表id")
private Long tableId;
/** 字段名称 */
@Excel(name = "字段名称")
private String columnName;
/** 字段注释 */
@Excel(name = "字段注释")
private String columnRemark;
/** 是否主键 'Y'是主键 'N'不是主键 */
@Excel(name = "是否主键 'Y'是主键 'N'不是主键")
private String isPrimary;
/** 数据类型 */
@Excel(name = "数据类型")
private String columnType;
/** 映射类型 */
@Excel(name = "映射类型")
private String javaType;
/** 字段长度 */
@Excel(name = "字段长度")
private String columnLength;
/** 小数位数 */
@Excel(name = "小数位数")
private String columnDecimals;
/** 是否为空 'Y'是 'N'不是 */
@Excel(name = "是否为空 'Y'是 'N'不是")
private String isNull;
/** 默认值 */
@Excel(name = "默认值")
private String defaultValue;
/** 是否字典 'Y'是 'N'不是 */
@Excel(name = "是否字典 'Y'是 'N'不是")
private String isDictionary;
/** 映射字典 */
@Excel(name = "映射字典")
private String dictionaryTable;
private String value;
public static StructureValueResp saveBuilder(Structure structure, String value) {
return StructureValueResp.builder()
.id(structure.getId())
.columnDecimals(structure.getColumnDecimals())
.columnLength(structure.getColumnLength())
.columnName(structure.getColumnName())
.columnType(structure.getColumnType())
.columnRemark(structure.getColumnRemark())
.defaultValue(structure.getDefaultValue())
.dictionaryTable(structure.getDictionaryTable())
.isNull(structure.getIsNull())
.isPrimary(structure.getIsPrimary())
.isDictionary(structure.getIsDictionary())
.javaType(structure.getJavaType())
.tableId(structure.getTableId())
.value(value)
.build();
}
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyv-etl</artifactId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>
@ -23,6 +23,14 @@
<artifactId>spring-cloud-openfeign-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,32 @@
package com.etl;
import com.etl.factory.RemoteAssetFallbackFactory;
import com.muyu.common.core.constant.SecurityConstants;
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.BasicConfigInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
/**
*
*
* @author muyu
*/
@FeignClient(contextId = "remoteRuleEngineService", value = ServiceNameConstants.ENGINE_SERVICE, fallbackFactory = RemoteAssetFallbackFactory.class)
public interface RemoteAssetService {
/**
*
*
* @param basicConfigInfo
* @param source
* @return
*/
@GetMapping("/list")
public Result<TableDataInfo<BasicConfigInfo>> list(BasicConfigInfo basicConfigInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

View File

@ -0,0 +1,32 @@
package com.etl.factory;
import com.etl.RemoteAssetService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.BasicConfigInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
*
*
* @author muyu
*/
@Component
public class RemoteAssetFallbackFactory implements FallbackFactory<RemoteAssetService> {
private static final Logger log = LoggerFactory.getLogger(RemoteAssetFallbackFactory.class);
@Override
public RemoteAssetService create(Throwable throwable) {
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteAssetService() {
@Override
public Result<TableDataInfo<BasicConfigInfo>> list(BasicConfigInfo basicConfigInfo, String source) {
return Result.error("查询接入信息失败");
}
};
}
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyv-etl</artifactId>
<artifactId>muyu-etl</artifactId>
<version>3.6.3</version>
</parent>

View File

@ -7,10 +7,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.etl.domain.AssetDataDict;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.*;
import com.muyu.etl.domain.req.TableInfoScopeReq;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
@ -114,16 +112,6 @@ public class BasicConfigInfoController extends BaseController {
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
}
// /**
// * 获取成功链接中的
// * @return
// */
// @RequiresPermissions("etl:info:test")
// @Log(title = "获取成功链接中的")
// @GetMapping("/dataConstruct")
// public Result<TableDataInfo<List>> getData() {
// return getDataTable(basicConfigInfoService.getDataByEtl());
// }
/**
*
@ -211,6 +199,30 @@ public class BasicConfigInfoController extends BaseController {
return Result.success(structureService.updateStructureInfoDict(structure), "修改成功");
}
/**
*
* @return
*/
@RequiresPermissions("etl:table:list")
@Log(title = "描述")
@PostMapping("/getTable")
public Result<List<TableInfo>> getTableList(@RequestBody BasicConfigInfo basicConfigInfo){
return Result.success(tableInfoService.getTableList(basicConfigInfo));
}
/**
*
* @return
*/
@RequiresPermissions("etl:table:list")
@Log(title = "描述")
@PostMapping("/structureInfo")
public Result<List> structureInfo(@RequestBody TableInfoScopeReq tableInfoScopeReq){
return Result.success(basicConfigInfoService.structureInfo(tableInfoScopeReq));
}
// /**
// * 模板
// * @return

View File

@ -64,4 +64,6 @@ public interface TableInfoMapper extends BaseMapper<TableInfo>
TableInfo selectTableInfoByName(TableInfo table);
TableInfo selectTableInfoByBasicAndParentId(TableInfo table);
}

View File

@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.req.TableInfoScopeReq;
import com.muyu.etl.domain.resp.BasicTableInfoResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import javax.servlet.ServletException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
/**
@ -67,6 +70,8 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo>
*/
public int deleteBasicConfigInfoById(Long id);
Connection getConn(BasicConfigInfo basicConfigInfo) throws SQLException;
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
// List getDataByEtl();
@ -76,4 +81,6 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo>
TableInfoStructureResp getTableInfo(Long tableId);
BasicTableInfoResp getBasicTableInfo(Long tableId);
List structureInfo(TableInfoScopeReq tableInfoScopeReq);
}

View File

@ -3,7 +3,9 @@ package com.muyu.etl.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.domain.req.TableInfoScopeReq;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
/**
@ -64,4 +66,6 @@ public interface TableInfoService extends IService<TableInfo>
TableInfo selectTableInfoByName(TableInfo build);
List<TableInfo> getTableList(BasicConfigInfo basicConfigInfo);
}

View File

@ -7,7 +7,9 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.domain.req.TableInfoScopeReq;
import com.muyu.etl.domain.resp.BasicTableInfoResp;
import com.muyu.etl.domain.resp.StructureValueResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.mapper.BasicConfigInfoMapper;
@ -23,8 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletException;
import java.sql.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@ -115,6 +117,23 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
return basicConfigInfoMapper.deleteBasicConfigInfoById(id);
}
@Override
public Connection getConn(BasicConfigInfo basicConfigInfo) throws SQLException {
// //定义下面需要的对象
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
String user = basicConfigInfo.getUsername();
String password = basicConfigInfo.getPassword();
Connection conn = null;
conn = DriverManager.getConnection(url, user, password);
return conn;
}
/**
*
*
@ -125,17 +144,9 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
@Override
@Transactional
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
//定义下面需要的对象
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
String user = basicConfigInfo.getUsername();
String password = basicConfigInfo.getPassword();
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
Connection conn = getConn(basicConfigInfo);
basicConfigInfo.setIsTest("1");
this.update(basicConfigInfo, new LambdaUpdateWrapper<BasicConfigInfo>() {{
eq(BasicConfigInfo::getId, basicConfigInfo.getId());
@ -375,18 +386,11 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
public BasicTableInfoResp getBasicTableInfo(Long tableId) {
TableInfo tableInfo = tableInfoService.selectTableInfoById(tableId);
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
String user = basicConfigInfo.getUsername();
String password = basicConfigInfo.getPassword();
Long totalNum = null;
BasicTableInfoResp basicTableInfoResp = null;
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
conn = this.getConn(basicConfigInfo);
PreparedStatement ps = conn.prepareStatement("select Count(0) from " + tableInfo.getTableName());
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()) {
@ -411,4 +415,54 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
return basicTableInfoResp;
}
@Override
public List structureInfo(TableInfoScopeReq tableInfoScopeReq) {
//表--数据结构
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>() {{
eq(Structure::getTableId, tableInfoScopeReq.getId());
}});
//字段级
if (tableInfoScopeReq.getLevel().equals("data-field")) {
return getList(tableInfoScopeReq, structureList, 1);
}
//行级
if (tableInfoScopeReq.getLevel().equals("data-record")) {
return getList(tableInfoScopeReq, structureList, 5);
}
//页级
if (tableInfoScopeReq.getLevel().equals("data-set")) {
return getList(tableInfoScopeReq, structureList, 10);
}
return null;
}
/**
* kvt
*
* @return
*/
public List<HashMap<String, StructureValueResp>> getList(TableInfoScopeReq tableInfoScopeReq, List<Structure> structureList, int num) {
List<HashMap<String, StructureValueResp>> list = null;
HashMap<String, StructureValueResp> valueRespHashMap = new HashMap<>();
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfoScopeReq.getBasicId());
try {
Connection conn = this.getConn(basicConfigInfo);
PreparedStatement ps = conn.prepareStatement("select * from " + tableInfoScopeReq.getTableName() + " limit ?" );
ResultSet rs = ps.executeQuery();
while (rs.next()) {
for (int i = 0; i < structureList.size(); i++) {
StructureValueResp structureValueResp = StructureValueResp.saveBuilder(structureList.get(i),
String.valueOf(rs.getObject(i + 1)));
valueRespHashMap.put(structureList.get(i).getColumnName(), structureValueResp);
list.add(valueRespHashMap);
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return list;
}
}

View File

@ -1,5 +1,6 @@
package com.muyu.etl.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.req.TableInfoScopeReq;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.service.BasicConfigInfoService;
import com.muyu.etl.service.StructureService;
@ -106,5 +108,18 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo
return tableInfoMapper.selectTableInfoByName(table);
}
@Override
public List<TableInfo> getTableList(BasicConfigInfo basicConfigInfo) {
TableInfo tableInfo = tableInfoMapper.selectTableInfoByBasicAndParentId(new TableInfo() {{
setBasicId(basicConfigInfo.getId());
}});
return tableInfoMapper.selectTableInfoList(new TableInfo() {{
setParentId(tableInfo.getId());
setBasicId(basicConfigInfo.getId());
}});
}
}

View File

@ -46,6 +46,11 @@
where basic_id = #{basicId} and table_name = #{tableName}
</select>
<select id="selectTableInfoByBasicAndParentId" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
select * from table_info
where basic_id = #{basicId} and parent_id = 0
</select>
<insert id="insertTableInfo" parameterType="com.muyu.etl.domain.TableInfo" useGeneratedKeys="true" keyProperty="id">
insert into table_info

View File

@ -9,12 +9,13 @@
<version>3.6.3</version>
</parent>
<artifactId>muyv-etl</artifactId>
<artifactId>muyu-etl</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-etl-common</module>
<module>muyu-etl-remote</module>
<module>muyu-etl-service</module>
<module>muyu-etl-client</module>
</modules>
<properties>

View File

@ -0,0 +1,120 @@
<?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-ruleEngine</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-ruleEngine-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>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.8</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-etl-common</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>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,18 @@
package com.muyu;
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.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@EnableFeignClients
@SpringBootApplication
public class EngineClientApplication {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -16,5 +16,11 @@
<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>
</dependencies>
</project>

View File

@ -1,7 +0,0 @@
package com.muyu;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,35 @@
//package com.muyu.remote;
//
//import com.muyu.common.core.constant.SecurityConstants;
//import com.muyu.common.core.constant.ServiceNameConstants;
//import com.muyu.common.core.domain.Result;
//import com.muyu.common.system.domain.LoginUser;
//import com.muyu.remote.factory.RemoteRuleEngineFallbackFactory;
//import org.springframework.cloud.openfeign.FeignClient;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestHeader;
//
///**
// * 用户服务
// *
// * @author muyu
// */
//@FeignClient(contextId = "remoteRuleEngineService", value = ServiceNameConstants.ENGINE_SERVICE, fallbackFactory = RemoteRuleEngineFallbackFactory.class)
//public interface RemoteRuleEngineService {
// /**
// * 通过用户名查询用户信息
// *
// * @param username 用户名
// * @param source 请求来源
// *
// * @return 结果
// */
// @GetMapping("/user/info/{username}")
// public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
//
//
//
//
//
//}

View File

@ -0,0 +1,31 @@
//package com.muyu.remote.factory;
//
//import com.muyu.common.core.domain.Result;
//import com.muyu.common.system.domain.LoginUser;
//import com.muyu.remote.RemoteRuleEngineService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.cloud.openfeign.FallbackFactory;
//import org.springframework.stereotype.Component;
//
///**
// * 用户服务降级处理
// *
// * @author muyu
// */
//@Component
//public class RemoteRuleEngineFallbackFactory implements FallbackFactory<RemoteRuleEngineService> {
// private static final Logger log = LoggerFactory.getLogger(RemoteRuleEngineFallbackFactory.class);
//
// @Override
// public RemoteRuleEngineService create(Throwable throwable) {
// log.error("用户服务调用失败:{}", throwable.getMessage());
// return new RemoteRuleEngineService() {
//
// @Override
// public Result<LoginUser> getUserInfo(String username, String source) {
// return null;
// }
// };
// }
//}

View File

@ -1,6 +1,7 @@
package com.muyu.engine.controller;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -107,8 +108,7 @@ public class RuleEngineVersionController extends BaseController
@RequiresPermissions("engine:version:update")
@Log(title = "规则版本", businessType = BusinessType.DELETE)
@PostMapping("/saveCoding")
public Result saveCoding(@RequestBody RuleEngineVersion ruleEngineVersion)
{
public Result saveCoding(@RequestBody RuleEngineVersion ruleEngineVersion) throws ServletException {
return toAjax(ruleEngineVersionService.saveCoding(ruleEngineVersion));
}

View File

@ -5,6 +5,8 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.engine.domain.RuleEngineVersion;
import javax.servlet.ServletException;
/**
* Service
*
@ -66,7 +68,7 @@ public interface RuleEngineVersionService extends IService<RuleEngineVersion>
* @param ruleEngineVersion
* @return boolean
*/
boolean saveCoding(RuleEngineVersion ruleEngineVersion);
boolean saveCoding(RuleEngineVersion ruleEngineVersion) throws ServletException;
/**
*

View File

@ -111,7 +111,11 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
* @return
*/
@Override
public boolean saveCoding(RuleEngineVersion ruleEngineVersion) {
public boolean saveCoding(RuleEngineVersion ruleEngineVersion) throws ServletException {
RuleEngineVersion one = this.getOne(new LambdaQueryWrapper<>() {{
eq(RuleEngineVersion::getCode, ruleEngineVersion.getCode());
}});
if (!"null".equals(one)) throw new ServletException("该版本已存在");
String codeIng = ruleEngineVersion.getCodeIng();
try {
String path = codeIng.substring(codeIng.indexOf("com"), codeIng.indexOf(";")).replaceAll("\\.", "/").trim();

View File

@ -16,6 +16,7 @@
<module>muyu-ruleEngine-common</module>
<module>muyu-ruleEngine-remote</module>
<module>muyu-ruleEngine-service</module>
<module>muyu-ruleEngine-client</module>
</modules>
<properties>

View File

@ -13,7 +13,7 @@
<module>muyu-gen</module>
<module>muyu-job</module>
<module>muyu-file</module>
<module>muyv-etl</module>
<module>muyu-etl</module>
<module>muyu-ruleEngine</module>
</modules>