Compare commits
10 Commits
b0f0c3afe5
...
e7336a4f59
Author | SHA1 | Date |
---|---|---|
|
e7336a4f59 | |
|
1abb6e89b9 | |
|
e10817cb1b | |
|
d4ac304b07 | |
|
8a33e76f51 | |
|
9b76b6fae4 | |
|
8a1699ddfd | |
|
389f0be640 | |
|
07a2fc9618 | |
|
e69291cd38 |
|
@ -3,12 +3,16 @@ package com.muyu.common.system.remote;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.system.domain.SysDept;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务
|
* 用户服务
|
||||||
*
|
*
|
||||||
|
@ -37,4 +41,24 @@ public interface RemoteUserService {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/register")
|
@PostMapping("/user/register")
|
||||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户对象
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/list")
|
||||||
|
public Result<List<SysUser>> list (@RequestBody SysUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门
|
||||||
|
* @param deptId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/dept/{deptId}")
|
||||||
|
public Result<SysDept> getInfo (@PathVariable("deptId") Long deptId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
@PostMapping(value = "/dept/list")
|
||||||
|
Result<List<SysDept>> list(@RequestBody SysDept dept, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package com.muyu.common.system.remote.factory;
|
package com.muyu.common.system.remote.factory;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.common.system.domain.SysDept;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务降级处理
|
* 用户服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -19,18 +22,33 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
|
private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteUserService create (Throwable throwable) {
|
public RemoteUserService create(Throwable throwable) {
|
||||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
return new RemoteUserService() {
|
return new RemoteUserService() {
|
||||||
@Override
|
@Override
|
||||||
public Result<LoginUser> getUserInfo (String username, String source) {
|
public Result<LoginUser> getUserInfo(String username, String source) {
|
||||||
return Result.error("获取用户失败:" + throwable.getMessage());
|
return Result.error("获取用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
public Result<Boolean> registerUserInfo(SysUser sysUser, String source) {
|
||||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<SysUser>> list(SysUser user, String source) {
|
||||||
|
return Result.error("用户列表获取失败" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<SysDept> getInfo(Long deptId, String source) {
|
||||||
|
return Result.error("用户获取失败" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<SysDept>> list(SysDept dept, String source) {
|
||||||
|
return Result.error("部门列表获取失败" + throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-ruleEngine</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-ruleEngine-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>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.muyu.engine.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎对象 rule_engine
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class RuleEngine extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 规则名称 */
|
||||||
|
@Excel(name = "规则名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 规则类型 */
|
||||||
|
@Excel(name = "规则类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** 规则作用域 */
|
||||||
|
@Excel(name = "规则作用域")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
/** 规则编码 */
|
||||||
|
@Excel(name = "规则编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
@Excel(name = "引擎编码")
|
||||||
|
private String engineCode;
|
||||||
|
|
||||||
|
/** 描述 */
|
||||||
|
@Excel(name = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
@Excel(name = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 规则状态 */
|
||||||
|
@Excel(name = "规则状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.muyu.engine.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则版本对象 rule_engine_version
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class RuleEngineVersion extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 引擎id */
|
||||||
|
@Excel(name = "引擎id")
|
||||||
|
private Long ruleEngineId;
|
||||||
|
|
||||||
|
/** 版本类 */
|
||||||
|
@Excel(name = "版本类")
|
||||||
|
private String versionCode;
|
||||||
|
|
||||||
|
/** 版本名称 */
|
||||||
|
@Excel(name = "版本名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 版本code */
|
||||||
|
@Excel(name = "版本code")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
@Excel(name = "引擎编码")
|
||||||
|
private String codeIng;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
@Excel(name = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 测试状态 */
|
||||||
|
@Excel(name = "是否激活")
|
||||||
|
private String isTest;
|
||||||
|
|
||||||
|
/** 版本状态 */
|
||||||
|
@Excel(name = "版本状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 描述 */
|
||||||
|
@Excel(name = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?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-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>
|
||||||
|
|
||||||
|
</project>
|
|
@ -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-service</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-ruleEngine-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>
|
|
@ -0,0 +1,24 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RuleEngineApplication
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/5/3 11:43
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class RuleEngineApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(RuleEngineApplication.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
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.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.engine.domain.RuleEngine;
|
||||||
|
import com.muyu.engine.service.RuleEngineService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎Controller
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-03
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/engine")
|
||||||
|
public class RuleEngineController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineService ruleEngineService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则引擎列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
|
||||||
|
startPage();
|
||||||
|
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出规则引擎列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:export")
|
||||||
|
@Log(title = "规则引擎", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, RuleEngine ruleEngine) {
|
||||||
|
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
|
||||||
|
ExcelUtil<RuleEngine> util = new ExcelUtil<RuleEngine>(RuleEngine.class);
|
||||||
|
util.exportExcel(response, list, "规则引擎数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取规则引擎详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id) {
|
||||||
|
return success(ruleEngineService.selectRuleEngineById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则引擎
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:add")
|
||||||
|
@Log(title = "规则引擎", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody RuleEngine ruleEngine) {
|
||||||
|
return toAjax(ruleEngineService.insertRuleEngine(ruleEngine));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则引擎
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:edit")
|
||||||
|
@Log(title = "规则引擎", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody RuleEngine ruleEngine) {
|
||||||
|
return toAjax(ruleEngineService.updateRuleEngine(ruleEngine));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则引擎
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:engine:remove")
|
||||||
|
@Log(title = "规则引擎", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(ruleEngineService.deleteRuleEngineByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.muyu.engine.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.engine.domain.RuleEngineVersion;
|
||||||
|
import com.muyu.engine.service.RuleEngineVersionService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则版本Controller
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/version")
|
||||||
|
public class RuleEngineVersionController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineVersionService ruleEngineVersionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则版本列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:list")
|
||||||
|
@GetMapping("/list/{ruleEngineId}")
|
||||||
|
public Result<TableDataInfo<RuleEngineVersion>> list(@PathVariable Long ruleEngineId)
|
||||||
|
{
|
||||||
|
List<RuleEngineVersion> list = ruleEngineVersionService.selectRuleEngineVersionList(ruleEngineId);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出规则版本列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:export")
|
||||||
|
@Log(title = "规则版本", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, Long ruleEngineId)
|
||||||
|
{
|
||||||
|
List<RuleEngineVersion> list = ruleEngineVersionService.selectRuleEngineVersionList(ruleEngineId);
|
||||||
|
ExcelUtil<RuleEngineVersion> util = new ExcelUtil<RuleEngineVersion>(RuleEngineVersion.class);
|
||||||
|
util.exportExcel(response, list, "规则版本数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取规则版本详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(ruleEngineVersionService.selectRuleEngineVersionById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则版本
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:add")
|
||||||
|
@Log(title = "规则版本", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody RuleEngineVersion ruleEngineVersion)
|
||||||
|
{
|
||||||
|
return toAjax(ruleEngineVersionService.insertRuleEngineVersion(ruleEngineVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则版本
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:edit")
|
||||||
|
@Log(title = "规则版本", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody RuleEngineVersion ruleEngineVersion)
|
||||||
|
{
|
||||||
|
return toAjax(ruleEngineVersionService.updateRuleEngineVersion(ruleEngineVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则版本
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("engine:version:remove")
|
||||||
|
@Log(title = "规则版本", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(ruleEngineVersionService.deleteRuleEngineVersionByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.engine.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.engine.domain.RuleEngine;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎Mapper接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-03
|
||||||
|
*/
|
||||||
|
public interface RuleEngineMapper extends BaseMapper<RuleEngine>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询规则引擎
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 规则引擎
|
||||||
|
*/
|
||||||
|
public RuleEngine selectRuleEngineById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则引擎列表
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 规则引擎集合
|
||||||
|
*/
|
||||||
|
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertRuleEngine(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateRuleEngine(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则引擎
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则引擎
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineByIds(Long[] ids);
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.engine.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.engine.domain.RuleEngineVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则版本Mapper接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-06
|
||||||
|
*/
|
||||||
|
public interface RuleEngineVersionMapper extends BaseMapper<RuleEngineVersion>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询规则版本
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 规则版本
|
||||||
|
*/
|
||||||
|
public RuleEngineVersion selectRuleEngineVersionById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则版本列表
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 规则版本集合
|
||||||
|
*/
|
||||||
|
public List<RuleEngineVersion> selectRuleEngineVersionList(RuleEngineVersion ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则版本
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineVersionById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则版本
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineVersionByIds(Long[] ids);
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.muyu.engine.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.engine.domain.RuleEngine;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎Service接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-03
|
||||||
|
*/
|
||||||
|
public interface RuleEngineService extends IService<RuleEngine>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询规则引擎
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 规则引擎
|
||||||
|
*/
|
||||||
|
public RuleEngine selectRuleEngineById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则引擎列表
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 规则引擎集合
|
||||||
|
*/
|
||||||
|
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertRuleEngine(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateRuleEngine(RuleEngine ruleEngine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则引擎
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的规则引擎主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则引擎信息
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.engine.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.engine.domain.RuleEngineVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则版本Service接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-06
|
||||||
|
*/
|
||||||
|
public interface RuleEngineVersionService extends IService<RuleEngineVersion>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询规则版本
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 规则版本
|
||||||
|
*/
|
||||||
|
public RuleEngineVersion selectRuleEngineVersionById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则版本列表
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 规则版本集合
|
||||||
|
*/
|
||||||
|
public List<RuleEngineVersion> selectRuleEngineVersionList(Long ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则版本
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的规则版本主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineVersionByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则版本信息
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRuleEngineVersionById(Long id);
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.muyu.engine.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.engine.domain.RuleEngine;
|
||||||
|
import com.muyu.engine.mapper.RuleEngineMapper;
|
||||||
|
import com.muyu.engine.service.RuleEngineService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎Service业务层处理
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineMapper, RuleEngine> implements RuleEngineService {
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineMapper ruleEngineMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则引擎
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 规则引擎
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RuleEngine selectRuleEngineById(Long id) {
|
||||||
|
return ruleEngineMapper.selectRuleEngineById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则引擎列表
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 规则引擎
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine) {
|
||||||
|
return ruleEngineMapper.selectRuleEngineList(ruleEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertRuleEngine(RuleEngine ruleEngine) {
|
||||||
|
ruleEngine.setCreateTime(DateUtils.getNowDate());
|
||||||
|
ruleEngine.setEngineCode("engine_custom_" + ruleEngine.getCode());
|
||||||
|
boolean save = this.save(ruleEngine);
|
||||||
|
if (save) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则引擎
|
||||||
|
*
|
||||||
|
* @param ruleEngine 规则引擎
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateRuleEngine(RuleEngine ruleEngine) {
|
||||||
|
ruleEngine.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return ruleEngineMapper.updateRuleEngine(ruleEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则引擎
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的规则引擎主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleEngineByIds(Long[] ids) {
|
||||||
|
return ruleEngineMapper.deleteRuleEngineByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则引擎信息
|
||||||
|
*
|
||||||
|
* @param id 规则引擎主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleEngineById(Long id) {
|
||||||
|
return ruleEngineMapper.deleteRuleEngineById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,204 @@
|
||||||
|
package com.muyu.engine.service.impl;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.shaded.com.google.common.base.Supplier;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.engine.domain.RuleEngine;
|
||||||
|
import com.muyu.engine.service.RuleEngineService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.engine.mapper.RuleEngineVersionMapper;
|
||||||
|
import com.muyu.engine.domain.RuleEngineVersion;
|
||||||
|
import com.muyu.engine.service.RuleEngineVersionService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则版本Service业务层处理
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-05-06
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionMapper,RuleEngineVersion> implements RuleEngineVersionService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineVersionMapper ruleEngineVersionMapper;
|
||||||
|
@Autowired
|
||||||
|
private RuleEngineService ruleEngineService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则版本
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 规则版本
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RuleEngineVersion selectRuleEngineVersionById(Long id)
|
||||||
|
{
|
||||||
|
return ruleEngineVersionMapper.selectRuleEngineVersionById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规则版本列表
|
||||||
|
*
|
||||||
|
* @param ruleEngineId 规则版本
|
||||||
|
* @return 规则版本
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<RuleEngineVersion> selectRuleEngineVersionList(Long ruleEngineId)
|
||||||
|
{
|
||||||
|
return list(new LambdaQueryWrapper<RuleEngineVersion>(){{
|
||||||
|
eq(RuleEngineVersion::getRuleEngineId,ruleEngineId);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion)
|
||||||
|
{
|
||||||
|
ruleEngineVersion.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return ruleEngineVersionMapper.insertRuleEngineVersion(ruleEngineVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改规则版本
|
||||||
|
*
|
||||||
|
* @param ruleEngineVersion 规则版本
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion)
|
||||||
|
{
|
||||||
|
ruleEngineVersion.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return ruleEngineVersionMapper.updateRuleEngineVersion(ruleEngineVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除规则版本
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的规则版本主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleEngineVersionByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return ruleEngineVersionMapper.deleteRuleEngineVersionByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规则版本信息
|
||||||
|
*
|
||||||
|
* @param id 规则版本主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleEngineVersionById(Long id)
|
||||||
|
{
|
||||||
|
return ruleEngineVersionMapper.deleteRuleEngineVersionById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
public boolean testEngine(Long id) throws Exception {
|
||||||
|
// RuleEngine ruleEngine = ruleEngineService.getById(id);
|
||||||
|
// if (ruleEngine.getIsActivate().contains("no")) throw new ServletException("未激活");
|
||||||
|
// if (ruleEngine.getStatus().contains("1")) throw new ServletException("已停用");
|
||||||
|
// Scope scope = this.getOne(new LambdaQueryWrapper<Scope>() {{
|
||||||
|
// eq(Scope::getRuleEngineId, ruleEngine.getId());
|
||||||
|
// eq(Scope::getValue, "taskContext");
|
||||||
|
// }});
|
||||||
|
// String code = scope.getCode();
|
||||||
|
// String path = code.substring(code.indexOf("com"), code.indexOf(";")).replaceAll("/.", "/").trim();
|
||||||
|
// String fileName = code.substring(code.indexOf("class") + 6, code.indexOf("{")).trim();
|
||||||
|
// String name = path+"."+fileName;
|
||||||
|
// String javaPackageName = name.replace(".", File.separator)+".java";
|
||||||
|
// String javaAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" +javaPackageName;
|
||||||
|
// String jarAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/target/classes/com/muyu/engine/controller";
|
||||||
|
// Process process = Runtime.getRuntime().exec("javac -classpath "+ jarAbsolutePath+ " " + javaAbsolutePath);
|
||||||
|
// try {
|
||||||
|
// int exitVal = process.waitFor();
|
||||||
|
// System.out.println("Process exitValue: " + exitVal);
|
||||||
|
// ClassLoader classLoader = ReflectionUtils.class.getClassLoader();
|
||||||
|
// Class aClass = classLoader.loadClass(name);
|
||||||
|
// Object o = aClass.newInstance();
|
||||||
|
// Method[] methods = aClass.getMethods();
|
||||||
|
// for (Method method : methods) {
|
||||||
|
// method.invoke(o,null);
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error(e.getMessage());
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎流程并执行测试
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// @Override
|
||||||
|
public boolean init(Long id) throws ServletException {
|
||||||
|
RuleEngine ruleEngine = ruleEngineService.getById(id);
|
||||||
|
if (ruleEngine.getIsActivate().contains("no")) throw new ServletException("未激活");
|
||||||
|
if (ruleEngine.getStatus().contains("1")) throw new ServletException("已停用");
|
||||||
|
Supplier<Boolean> booleanSupplier = () -> {
|
||||||
|
try {
|
||||||
|
return testEngine(ruleEngine);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
System.out.println();
|
||||||
|
return booleanSupplier.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean testEngine(RuleEngine ruleEngine) throws ServletException, IOException {
|
||||||
|
// System.out.println("初始化");
|
||||||
|
// System.out.println(ruleEngine);
|
||||||
|
// Scope scope = this.getOne(new LambdaQueryWrapper<Scope>() {{
|
||||||
|
// eq(Scope::getRuleEngineId, ruleEngine.getId());
|
||||||
|
// eq(Scope::getValue, "taskContext");
|
||||||
|
// }});
|
||||||
|
// String code = scope.getCode();
|
||||||
|
// String path = code.substring(code.indexOf("com"), code.indexOf(";")).replaceAll("\\.", "/").trim();
|
||||||
|
// String fileName = code.substring(code.indexOf("class") + 6, code.indexOf("{")).trim();
|
||||||
|
// //代码编译
|
||||||
|
// File file = new File("D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" + path + "/" + fileName + ".java");
|
||||||
|
// if (!file.exists()) {
|
||||||
|
// //不存在创建
|
||||||
|
// file.createNewFile();
|
||||||
|
// }else {
|
||||||
|
// //存在测重新创建
|
||||||
|
// file.delete();
|
||||||
|
// file.createNewFile();
|
||||||
|
// }
|
||||||
|
// String[] split = code.split("/n");
|
||||||
|
// //OutputStreamWriter对象将字符转换为字节流,指定了文件输出流和编码方式。
|
||||||
|
// OutputStreamWriter outputStreamWriter =
|
||||||
|
// new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8");
|
||||||
|
// //BufferedWriter对象,用于缓冲写入数据,提高写入效率。
|
||||||
|
// BufferedWriter bw = new BufferedWriter(outputStreamWriter);
|
||||||
|
// for (String str : split) {
|
||||||
|
// bw.write(str);
|
||||||
|
// bw.newLine();
|
||||||
|
// }
|
||||||
|
// bw.close();
|
||||||
|
// outputStreamWriter.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9206
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: muyu-engine
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 43.142.100.73:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 43.142.100.73:8848
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.engine.mapper: DEBUG
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.engine.mapper.RuleEngineMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.engine.domain.RuleEngine" id="RuleEngineResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="level" column="level" />
|
||||||
|
<result property="code" column="code" />
|
||||||
|
<result property="engineCode" column="engine_code" />
|
||||||
|
<result property="description" column="description" />
|
||||||
|
<result property="isActivate" column="is_activate" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectRuleEngineVo">
|
||||||
|
select id, name, type, level, code,engine_code,description, is_activate, status, remark, create_by, create_time, update_by, update_time from rule_engine
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectRuleEngineList" parameterType="com.muyu.engine.domain.RuleEngine" resultMap="RuleEngineResult">
|
||||||
|
<include refid="selectRuleEngineVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||||
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||||
|
<if test="level != null and level != ''"> and level = #{level}</if>
|
||||||
|
<if test="code != null and code != ''"> and code = #{code}</if>
|
||||||
|
<if test="engineCode != null and engineCode != ''"> and engine_code = #{engineCode}</if>
|
||||||
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||||
|
<if test="isActivate != null and isActivate != ''"> and is_activate = #{isActivate}</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRuleEngineById" parameterType="Long" resultMap="RuleEngineResult">
|
||||||
|
<include refid="selectRuleEngineVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRuleEngine" parameterType="com.muyu.engine.domain.RuleEngine">
|
||||||
|
insert into rule_engine
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="name != null">name,</if>
|
||||||
|
<if test="type != null">type,</if>
|
||||||
|
<if test="level != null">level,</if>
|
||||||
|
<if test="code != null">code,</if>
|
||||||
|
<if test="engineCode != null">engine_code,</if>
|
||||||
|
<if test="description != null">description,</if>
|
||||||
|
<if test="isActivate != null">is_activate,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="name != null">#{name},</if>
|
||||||
|
<if test="type != null">#{type},</if>
|
||||||
|
<if test="level != null">#{level},</if>
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="engine_code != null">#{engineCode},</if>
|
||||||
|
<if test="description != null">#{description},</if>
|
||||||
|
<if test="isActivate != null">#{isActivate},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateRuleEngine" parameterType="com.muyu.engine.domain.RuleEngine">
|
||||||
|
update rule_engine
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="name != null">name = #{name},</if>
|
||||||
|
<if test="type != null">type = #{type},</if>
|
||||||
|
<if test="level != null">level = #{level},</if>
|
||||||
|
<if test="code != null">code = #{code},</if>
|
||||||
|
<if test="engineCode != null">engine_code = #{engineCode},</if>
|
||||||
|
<if test="description != null">description = #{description},</if>
|
||||||
|
<if test="isActivate != null">is_activate = #{isActivate},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteRuleEngineById" parameterType="Long">
|
||||||
|
delete from rule_engine where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRuleEngineByIds" parameterType="String">
|
||||||
|
delete from rule_engine where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,116 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.engine.mapper.RuleEngineVersionMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.engine.domain.RuleEngineVersion" id="RuleEngineVersionResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="ruleEngineId" column="rule_engine_id" />
|
||||||
|
<result property="versionCode" column="version_code" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="code" column="code" />
|
||||||
|
<result property="codeIng" column="codeIng" />
|
||||||
|
<result property="isActivate" column="is_activate" />
|
||||||
|
<result property="isTest" column="is_test" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="description" column="description" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectRuleEngineVersionVo">
|
||||||
|
select id, rule_engine_id, version_code, name, code, code_ing, is_activate,is_test, status, description, remark, create_by, create_time, update_by, update_time from rule_engine_version
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectRuleEngineVersionList" parameterType="com.muyu.engine.domain.RuleEngineVersion" resultMap="RuleEngineVersionResult">
|
||||||
|
<include refid="selectRuleEngineVersionVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="ruleEngineId != null "> and rule_engine_id = #{ruleEngineId}</if>
|
||||||
|
<if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode}</if>
|
||||||
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||||
|
<if test="code != null and code != ''"> and code = #{code}</if>
|
||||||
|
<if test="codeIng != null and codeIng != ''"> and code_ing = #{codeIng}</if>
|
||||||
|
<if test="isActivate != null and isActivate != ''"> and is_activate = #{isActivate}</if>
|
||||||
|
<if test="isTest != null and isTest != ''"> and is_test = #{isTest}</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRuleEngineVersionById" parameterType="Long" resultMap="RuleEngineVersionResult">
|
||||||
|
<include refid="selectRuleEngineVersionVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRuleEngineVersion" parameterType="com.muyu.engine.domain.RuleEngineVersion" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into rule_engine_version
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="ruleEngineId != null">rule_engine_id,</if>
|
||||||
|
<if test="versionCode != null">version_code,</if>
|
||||||
|
<if test="name != null">name,</if>
|
||||||
|
<if test="code != null">code,</if>
|
||||||
|
<if test="codeIng != null">code_ing,</if>
|
||||||
|
<if test="isActivate != null">is_activate,</if>
|
||||||
|
<if test="isTest != null">is_test,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="description != null">description,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="ruleEngineId != null">#{ruleEngineId},</if>
|
||||||
|
<if test="versionCode != null">#{versionCode},</if>
|
||||||
|
<if test="name != null">#{name},</if>
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="codeIng != null">#{codeIng},</if>
|
||||||
|
<if test="isActivate != null">#{isActivate},</if>
|
||||||
|
<if test="isTest != null">#{isTest},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="description != null">#{description},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateRuleEngineVersion" parameterType="com.muyu.engine.domain.RuleEngineVersion">
|
||||||
|
update rule_engine_version
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="ruleEngineId != null">rule_engine_id = #{ruleEngineId},</if>
|
||||||
|
<if test="versionCode != null">version_code = #{versionCode},</if>
|
||||||
|
<if test="name != null">name = #{name},</if>
|
||||||
|
<if test="code != null">code = #{code},</if>
|
||||||
|
<if test="codeIng != null">code_ing = #{codeIng},</if>
|
||||||
|
<if test="isActivate != null">is_activate = #{isActivate},</if>
|
||||||
|
<if test="isTest != null">is_test = #{isTest},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="description != null">description = #{description},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteRuleEngineVersionById" parameterType="Long">
|
||||||
|
delete from rule_engine_version where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRuleEngineVersionByIds" parameterType="String">
|
||||||
|
delete from rule_engine_version where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -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-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-ruleEngine</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>muyu-ruleEngine-common</module>
|
||||||
|
<module>muyu-ruleEngine-remote</module>
|
||||||
|
<module>muyu-ruleEngine-service</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -34,7 +34,7 @@ public class SysDeptController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:list")
|
@RequiresPermissions("system:dept:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result list (SysDept dept) {
|
public Result<List<SysDept>> list (SysDept dept) {
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return success(depts);
|
return success(depts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.muyu.etl.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.common.system.domain.SysDept;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产赋权对象 asset_impower
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-04-28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class AssetImpower extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表id
|
||||||
|
*/
|
||||||
|
@Excel(name = "表id")
|
||||||
|
private Long tableId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
@Excel(name = "部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入id
|
||||||
|
*/
|
||||||
|
@Excel(name = "接入id")
|
||||||
|
private Long basicId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@Excel(name = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
public static AssetImpower saveAssetImpower(Long deptId,Long userId,AssetImpower assetImpower){
|
||||||
|
return AssetImpower.builder()
|
||||||
|
.basicId(assetImpower.getBasicId())
|
||||||
|
.tableId(assetImpower.getTableId())
|
||||||
|
.deptId(deptId)
|
||||||
|
.userId(userId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,8 +24,6 @@ public class TableInfo extends TreeEntity
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/** 主键 */
|
||||||
|
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ -39,6 +37,11 @@ public class TableInfo extends TreeEntity
|
||||||
@Excel(name = "表备注")
|
@Excel(name = "表备注")
|
||||||
private String tableRemark;
|
private String tableRemark;
|
||||||
|
|
||||||
|
/** 表备注 */
|
||||||
|
@Excel(name = "数据来源类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
|
||||||
/** 数据量 */
|
/** 数据量 */
|
||||||
@Excel(name = "数据量")
|
@Excel(name = "数据量")
|
||||||
private Long dataNum;
|
private Long dataNum;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
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 AssetImpowerReq
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/4/29 14:04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class AssetImpowerReq {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表id
|
||||||
|
*/
|
||||||
|
@Excel(name = "表id")
|
||||||
|
private Long tableId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入id
|
||||||
|
*/
|
||||||
|
@Excel(name = "接入id")
|
||||||
|
private Long basicId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
@Excel(name = "部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@Excel(name = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.etl.domain.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入--表基础信息(授权)
|
||||||
|
*
|
||||||
|
* @ClassName BasicTableInfoResp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/4/30 11:58
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BasicTableInfoResp {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入id
|
||||||
|
*/
|
||||||
|
private Long basicId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据接入名
|
||||||
|
*/
|
||||||
|
private String dataResourceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据接入系统名
|
||||||
|
*/
|
||||||
|
private String dataSourcesSystemName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库名
|
||||||
|
*/
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名(中文)
|
||||||
|
*/
|
||||||
|
private String tableRemark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表明
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据条数
|
||||||
|
*/
|
||||||
|
private Long totalNum;
|
||||||
|
|
||||||
|
}
|
|
@ -45,10 +45,14 @@ public class TableInfoStructureResp
|
||||||
/** 数据量 */
|
/** 数据量 */
|
||||||
@Excel(name = "数据量")
|
@Excel(name = "数据量")
|
||||||
private Long dataNum;
|
private Long dataNum;
|
||||||
|
/** 表备注 */
|
||||||
|
@Excel(name = "数据来源类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
/** 是否核心 'Y'是 'N'不是 */
|
/** 是否核心 'Y'是 'N'不是 */
|
||||||
@Excel(name = "是否核心 'Y'是 'N'不是")
|
@Excel(name = "是否核心 'Y'是 'N'不是")
|
||||||
private String center;
|
private String center;
|
||||||
|
|
||||||
private String databaseType;
|
private String databaseType;
|
||||||
|
|
||||||
private List<Structure> structureList;
|
private List<Structure> structureList;
|
||||||
|
|
|
@ -11,10 +11,18 @@
|
||||||
|
|
||||||
<artifactId>muyu-etl-remote</artifactId>
|
<artifactId>muyu-etl-remote</artifactId>
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.3.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
@ -85,6 +90,7 @@
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -5,10 +5,12 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
|
@EnableFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class MuYuEtlApplication {
|
public class MuYuEtlApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.muyu.etl.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.etl.domain.AssetImpower;
|
||||||
|
import com.muyu.etl.service.AssetImpowerService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产赋权Controller
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-04-28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/impower")
|
||||||
|
public class AssetImpowerController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private AssetImpowerService assetImpowerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资产赋权列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<AssetImpower>> list(AssetImpower assetImpower)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<AssetImpower> list = assetImpowerService.selectAssetImpowerList(assetImpower);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出资产赋权列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:export")
|
||||||
|
@Log(title = "资产赋权", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, AssetImpower assetImpower)
|
||||||
|
{
|
||||||
|
List<AssetImpower> list = assetImpowerService.selectAssetImpowerList(assetImpower);
|
||||||
|
ExcelUtil<AssetImpower> util = new ExcelUtil<AssetImpower>(AssetImpower.class);
|
||||||
|
util.exportExcel(response, list, "资产赋权数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资产赋权详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(assetImpowerService.selectAssetImpowerById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资产赋权
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:add")
|
||||||
|
@Log(title = "资产赋权", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody AssetImpower assetImpower)
|
||||||
|
{
|
||||||
|
return toAjax(assetImpowerService.insertAssetImpower(assetImpower));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资产赋权
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:edit")
|
||||||
|
@Log(title = "资产赋权", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody AssetImpower assetImpower)
|
||||||
|
{
|
||||||
|
return toAjax(assetImpowerService.updateAssetImpower(assetImpower));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资产赋权
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:remove")
|
||||||
|
@Log(title = "资产赋权", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(assetImpowerService.deleteAssetImpowerByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资产赋权
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:impower:list")
|
||||||
|
@Log(title = "资产赋权", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("getPowerByTableId/{tableId}")
|
||||||
|
public Result getPowerByTableId(@PathVariable Long tableId)
|
||||||
|
{
|
||||||
|
return Result.success(assetImpowerService.getPowerByTableId(tableId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -10,11 +10,11 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.etl.domain.AssetDataDict;
|
import com.muyu.etl.domain.AssetDataDict;
|
||||||
import com.muyu.etl.domain.BasicConfigInfo;
|
import com.muyu.etl.domain.BasicConfigInfo;
|
||||||
import com.muyu.etl.domain.DictInfo;
|
import com.muyu.etl.domain.DictInfo;
|
||||||
|
import com.muyu.etl.domain.Structure;
|
||||||
import com.muyu.etl.domain.resp.BasicDictResp;
|
import com.muyu.etl.domain.resp.BasicDictResp;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||||
import com.muyu.etl.service.AssetDataDictService;
|
import com.muyu.etl.service.*;
|
||||||
import com.muyu.etl.service.BasicConfigInfoService;
|
|
||||||
import com.muyu.etl.service.DictInfoService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -36,7 +36,12 @@ public class BasicConfigInfoController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AssetDataDictService assetDataDictService;
|
private AssetDataDictService assetDataDictService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private TableInfoService tableInfoService;
|
||||||
|
@Autowired
|
||||||
private DictInfoService dictInfoService;
|
private DictInfoService dictInfoService;
|
||||||
|
@Autowired
|
||||||
|
private StructureService structureService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询基础信息列表
|
* 查询基础信息列表
|
||||||
*/
|
*/
|
||||||
|
@ -109,12 +114,16 @@ public class BasicConfigInfoController extends BaseController {
|
||||||
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
|
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("etl:info:test")
|
// /**
|
||||||
@Log(title = "获取成功链接中的")
|
// * 获取成功链接中的
|
||||||
@GetMapping("/dataConstruct")
|
// * @return
|
||||||
public Result<TableDataInfo<List>> getData() {
|
// */
|
||||||
return getDataTable(basicConfigInfoService.getDataByEtl());
|
// @RequiresPermissions("etl:info:test")
|
||||||
}
|
// @Log(title = "获取成功链接中的")
|
||||||
|
// @GetMapping("/dataConstruct")
|
||||||
|
// public Result<TableDataInfo<List>> getData() {
|
||||||
|
// return getDataTable(basicConfigInfoService.getDataByEtl());
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 树级结构数据
|
* 树级结构数据
|
||||||
|
@ -129,7 +138,7 @@ public class BasicConfigInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板
|
* 通过接入id查询数据库所属字典
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -140,8 +149,22 @@ public class BasicConfigInfoController extends BaseController {
|
||||||
return Result.success(assetDataDictService.getDict(basicId));
|
return Result.success(assetDataDictService.getDict(basicId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过tableId查询表信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Log(title = "描述")
|
||||||
|
@GetMapping("/getTableInfo/{tableId}")
|
||||||
|
public Result<TableInfoStructureResp> getTableInfo(@PathVariable Long tableId) {
|
||||||
|
return Result.success(basicConfigInfoService.getTableInfo(tableId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加字典表
|
* 添加字典表
|
||||||
|
*
|
||||||
* @param assetDataDict
|
* @param assetDataDict
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -151,17 +174,42 @@ public class BasicConfigInfoController extends BaseController {
|
||||||
public Result insertDictInfo(@RequestBody AssetDataDict assetDataDict) throws ServletException {
|
public Result insertDictInfo(@RequestBody AssetDataDict assetDataDict) throws ServletException {
|
||||||
return Result.success(assetDataDictService.insertAssetDataDict(assetDataDict));
|
return Result.success(assetDataDictService.insertAssetDataDict(assetDataDict));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* 添加字典详细信息
|
* 添加字典详细信息
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("etl:table:list")
|
@RequiresPermissions("etl:table:add")
|
||||||
@Log(title = "添加字典表")
|
@Log(title = "添加字典表")
|
||||||
@PostMapping("/insertDictInfo")
|
@PostMapping("/insertDictInfo")
|
||||||
public Result insertDict(@RequestBody DictInfo dictInfo) throws ServletException {
|
public Result insertDict(@RequestBody DictInfo dictInfo) throws ServletException {
|
||||||
return Result.success(dictInfoService.insertDictInfo(dictInfo));
|
return Result.success(dictInfoService.insertDictInfo(dictInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取具体表的所有基础信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:table:list")
|
||||||
|
@Log(title = "获取具体表的所有基础信息")
|
||||||
|
@GetMapping("/getBasicTableInfo/{tableId}")
|
||||||
|
public Result getBasicTableInfo(@PathVariable Long tableId) throws ServletException {
|
||||||
|
return Result.success(basicConfigInfoService.getBasicTableInfo(tableId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资产结构中字典信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("etl:table:update")
|
||||||
|
@Log(title = "修改资产结构中字典信息")
|
||||||
|
@PutMapping("/updateStructureInfo")
|
||||||
|
public Result updateStructureInfo(@RequestBody Structure structure) {
|
||||||
|
return Result.success(structureService.updateStructureInfoDict(structure), "修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 模板
|
// * 模板
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.etl.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.etl.domain.AssetImpower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产赋权Mapper接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-04-28
|
||||||
|
*/
|
||||||
|
public interface AssetImpowerMapper extends BaseMapper<AssetImpower>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询资产赋权
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 资产赋权
|
||||||
|
*/
|
||||||
|
public AssetImpower selectAssetImpowerById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资产赋权列表
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 资产赋权集合
|
||||||
|
*/
|
||||||
|
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAssetImpower(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAssetImpower(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资产赋权
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAssetImpowerById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资产赋权
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAssetImpowerByIds(Long[] ids);
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.etl.domain.AssetDataDict;
|
import com.muyu.etl.domain.AssetDataDict;
|
||||||
import com.muyu.etl.domain.resp.BasicDictResp;
|
import com.muyu.etl.domain.resp.BasicDictResp;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
@ -65,4 +66,5 @@ public interface AssetDataDictService extends IService<AssetDataDict>
|
||||||
public int deleteAssetDataDictById(Long id);
|
public int deleteAssetDataDictById(Long id);
|
||||||
|
|
||||||
List<BasicDictResp> getDict(Long basicId);
|
List<BasicDictResp> getDict(Long basicId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.muyu.etl.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.etl.domain.AssetImpower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产赋权Service接口
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-04-28
|
||||||
|
*/
|
||||||
|
public interface AssetImpowerService extends IService<AssetImpower>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询资产赋权
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 资产赋权
|
||||||
|
*/
|
||||||
|
public AssetImpower selectAssetImpowerById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资产赋权列表
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 资产赋权集合
|
||||||
|
*/
|
||||||
|
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAssetImpower(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAssetImpower(AssetImpower assetImpower);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资产赋权
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资产赋权主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAssetImpowerByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资产赋权信息
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAssetImpowerById(Long id);
|
||||||
|
|
||||||
|
List<AssetImpower> getPowerByTableId(Long tableId);
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.etl.domain.BasicConfigInfo;
|
import com.muyu.etl.domain.BasicConfigInfo;
|
||||||
|
import com.muyu.etl.domain.resp.BasicTableInfoResp;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -67,7 +69,11 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo>
|
||||||
|
|
||||||
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
|
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
|
||||||
|
|
||||||
List getDataByEtl();
|
// List getDataByEtl();
|
||||||
|
|
||||||
List<TableTreeResp> getTableTree();
|
List<TableTreeResp> getTableTree();
|
||||||
|
|
||||||
|
TableInfoStructureResp getTableInfo(Long tableId);
|
||||||
|
|
||||||
|
BasicTableInfoResp getBasicTableInfo(Long tableId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,4 +60,6 @@ public interface StructureService extends IService<Structure>
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteStructureById(Long id);
|
public int deleteStructureById(Long id);
|
||||||
|
|
||||||
|
boolean updateStructureInfoDict(Structure structure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.etl.domain.TableInfo;
|
import com.muyu.etl.domain.TableInfo;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 库表基础信息Service接口
|
* 库表基础信息Service接口
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
import com.muyu.etl.domain.DictInfo;
|
import com.muyu.etl.domain.DictInfo;
|
||||||
import com.muyu.etl.domain.resp.BasicDictResp;
|
import com.muyu.etl.domain.resp.BasicDictResp;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
import com.muyu.etl.service.DictInfoService;
|
import com.muyu.etl.service.DictInfoService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -71,11 +72,10 @@ public class AssetDataDictServiceImpl extends ServiceImpl<AssetDataDictMapper, A
|
||||||
if (one!=null){
|
if (one!=null){
|
||||||
throw new ServletException("该字典已存在");
|
throw new ServletException("该字典已存在");
|
||||||
}
|
}
|
||||||
boolean b = this.saveOrUpdate(assetDataDict, new LambdaUpdateWrapper<AssetDataDict>(AssetDataDict.class) {{
|
return this.saveOrUpdate(assetDataDict, new LambdaUpdateWrapper<AssetDataDict>(AssetDataDict.class) {{
|
||||||
eq(AssetDataDict::getDictType,assetDataDict.getDictType());
|
eq(AssetDataDict::getDictType,assetDataDict.getDictType());
|
||||||
eq(AssetDataDict::getBasicId,assetDataDict.getBasicId());
|
eq(AssetDataDict::getBasicId,assetDataDict.getBasicId());
|
||||||
}});
|
}});
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,4 +134,6 @@ public class AssetDataDictServiceImpl extends ServiceImpl<AssetDataDictMapper, A
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
return collect;
|
return collect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.muyu.etl.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.common.system.domain.SysDept;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import com.muyu.etl.domain.AssetImpower;
|
||||||
|
import com.muyu.etl.domain.TableInfo;
|
||||||
|
import com.muyu.etl.mapper.AssetImpowerMapper;
|
||||||
|
import com.muyu.etl.service.AssetImpowerService;
|
||||||
|
import com.muyu.etl.service.TableInfoService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产赋权Service业务层处理
|
||||||
|
*
|
||||||
|
* @author Saisai
|
||||||
|
* @date 2024-04-28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class AssetImpowerServiceImpl extends ServiceImpl<AssetImpowerMapper, AssetImpower> implements AssetImpowerService {
|
||||||
|
@Autowired
|
||||||
|
private AssetImpowerMapper assetImpowerMapper;
|
||||||
|
@Autowired
|
||||||
|
private TableInfoService tableInfoService;
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资产赋权
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 资产赋权
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AssetImpower selectAssetImpowerById(Long id) {
|
||||||
|
return assetImpowerMapper.selectAssetImpowerById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资产赋权列表
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 资产赋权
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower) {
|
||||||
|
return assetImpowerMapper.selectAssetImpowerList(assetImpower);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertAssetImpower(AssetImpower assetImpower) {
|
||||||
|
List<AssetImpower> rows = new ArrayList<>();
|
||||||
|
assetImpower.setCreateTime(DateUtils.getNowDate());
|
||||||
|
//创建一个部门容器和用户容器
|
||||||
|
List<SysDept> deptList = remoteUserService.list(new SysDept(), SecurityConstants.INNER).getData();
|
||||||
|
System.out.println(remoteUserService.list(new SysDept(), SecurityConstants.INNER));
|
||||||
|
//单表单个用户赋权
|
||||||
|
if (assetImpower.getTableId() != null && assetImpower.getUserId() != null) {
|
||||||
|
rows.add(assetImpower);
|
||||||
|
}
|
||||||
|
//单表多用户赋权
|
||||||
|
if (assetImpower.getTableId() != null) {
|
||||||
|
//根据id过滤部门
|
||||||
|
SysDept dept = remoteUserService.getInfo(assetImpower.getDeptId(), SecurityConstants.INNER).getData();
|
||||||
|
deptList.addAll(getChildSysDept(deptList, dept));
|
||||||
|
List<AssetImpower> finalRows = rows;
|
||||||
|
deptList.stream().distinct().forEach(sysDept -> {
|
||||||
|
//该部门下的用户列表
|
||||||
|
remoteUserService.list(new SysUser() {{
|
||||||
|
setDeptId(sysDept.getDeptId());
|
||||||
|
}}, SecurityConstants.INNER).getData()
|
||||||
|
.forEach(sysUser -> finalRows.add(AssetImpower.saveAssetImpower(sysDept.getDeptId(), sysUser.getUserId(), assetImpower)));
|
||||||
|
});
|
||||||
|
rows = rows.stream().distinct().toList();
|
||||||
|
}
|
||||||
|
//多表单用户赋权
|
||||||
|
if (assetImpower.getUserId() != null) {
|
||||||
|
List<TableInfo> tableInfoList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
||||||
|
setBasicId(assetImpower.getBasicId());
|
||||||
|
}});
|
||||||
|
List<AssetImpower> finalRows = rows;
|
||||||
|
tableInfoList.forEach(tableInfo -> finalRows.add(AssetImpower.saveAssetImpower(
|
||||||
|
assetImpower.getDeptId(), assetImpower.getUserId(), new AssetImpower() {{
|
||||||
|
setBasicId(assetImpower.getBasicId());
|
||||||
|
setTableId(tableInfo.getId());
|
||||||
|
}})));
|
||||||
|
}
|
||||||
|
boolean b = this.saveBatch(rows);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//递归获取子级部门
|
||||||
|
public List<SysDept> getChildSysDept(List<SysDept> deptList, SysDept sysDept) {
|
||||||
|
List<SysDept> list = new ArrayList<>();
|
||||||
|
List<SysDept> deptChildList = new ArrayList<>(deptList);
|
||||||
|
list.addAll(deptChildList.stream()
|
||||||
|
.distinct()
|
||||||
|
.filter(dept -> dept.getParentId().equals(sysDept.getDeptId())).toList());
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
list.forEach(sysDeptChild -> deptChildList.addAll(this.getChildSysDept(deptChildList, sysDeptChild)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资产赋权
|
||||||
|
*
|
||||||
|
* @param assetImpower 资产赋权
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateAssetImpower(AssetImpower assetImpower) {
|
||||||
|
assetImpower.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return assetImpowerMapper.updateAssetImpower(assetImpower);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资产赋权
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资产赋权主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAssetImpowerByIds(Long[] ids) {
|
||||||
|
return assetImpowerMapper.deleteAssetImpowerByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资产赋权信息
|
||||||
|
*
|
||||||
|
* @param id 资产赋权主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAssetImpowerById(Long id) {
|
||||||
|
return assetImpowerMapper.deleteAssetImpowerById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AssetImpower> getPowerByTableId(Long tableId) {
|
||||||
|
return this.selectAssetImpowerList(new AssetImpower() {{
|
||||||
|
setTableId(tableId);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.etl.domain.BasicConfigInfo;
|
import com.muyu.etl.domain.BasicConfigInfo;
|
||||||
import com.muyu.etl.domain.Structure;
|
import com.muyu.etl.domain.Structure;
|
||||||
import com.muyu.etl.domain.TableInfo;
|
import com.muyu.etl.domain.TableInfo;
|
||||||
|
import com.muyu.etl.domain.resp.BasicTableInfoResp;
|
||||||
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
import com.muyu.etl.domain.resp.TableTreeResp;
|
import com.muyu.etl.domain.resp.TableTreeResp;
|
||||||
import com.muyu.etl.mapper.BasicConfigInfoMapper;
|
import com.muyu.etl.mapper.BasicConfigInfoMapper;
|
||||||
|
@ -17,11 +18,16 @@ import lombok.SneakyThrows;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +38,7 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapper, BasicConfigInfo> implements BasicConfigInfoService
|
public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapper, BasicConfigInfo> implements BasicConfigInfoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BasicConfigInfoMapper basicConfigInfoMapper;
|
private BasicConfigInfoMapper basicConfigInfoMapper;
|
||||||
|
|
||||||
|
@ -51,8 +56,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public BasicConfigInfo selectBasicConfigInfoById(Long id)
|
public BasicConfigInfo selectBasicConfigInfoById(Long id) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
|
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +67,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo)
|
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.selectBasicConfigInfoList(basicConfigInfo);
|
return basicConfigInfoMapper.selectBasicConfigInfoList(basicConfigInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +78,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq)
|
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.insertBasicConfigInfo(configQueryReq);
|
return basicConfigInfoMapper.insertBasicConfigInfo(configQueryReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +89,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq)
|
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.updateBasicConfigInfo(configQueryReq);
|
return basicConfigInfoMapper.updateBasicConfigInfo(configQueryReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +100,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteBasicConfigInfoByIds(Long[] ids)
|
public int deleteBasicConfigInfoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.deleteBasicConfigInfoByIds(ids);
|
return basicConfigInfoMapper.deleteBasicConfigInfoByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,93 +111,135 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteBasicConfigInfoById(Long id)
|
public int deleteBasicConfigInfoById(Long id) {
|
||||||
{
|
|
||||||
return basicConfigInfoMapper.deleteBasicConfigInfoById(id);
|
return basicConfigInfoMapper.deleteBasicConfigInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试连接并同步
|
||||||
|
*
|
||||||
|
* @param basicConfigInfo
|
||||||
|
* @return
|
||||||
|
* @throws ServletException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
|
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
|
||||||
//定义下面需要的对象
|
//定义下面需要的对象
|
||||||
String host = basicConfigInfo.getHost();
|
String host = basicConfigInfo.getHost();
|
||||||
String port = basicConfigInfo.getPort();
|
String port = basicConfigInfo.getPort();
|
||||||
String databaseName = basicConfigInfo.getDatabaseName();
|
String databaseName = basicConfigInfo.getDatabaseName();
|
||||||
String databaseType = basicConfigInfo.getDatabaseType();
|
String databaseType = basicConfigInfo.getDatabaseType();
|
||||||
|
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
|
||||||
String url = "jdbc:"+databaseType+"://"+host+":"+port+"/"+databaseName+"?"+basicConfigInfo.getConnectionParams();
|
|
||||||
String user = basicConfigInfo.getUsername();
|
String user = basicConfigInfo.getUsername();
|
||||||
String password = basicConfigInfo.getPassword();
|
String password = basicConfigInfo.getPassword();
|
||||||
Connection conn= null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
conn = DriverManager.getConnection(url, user, password);
|
conn = DriverManager.getConnection(url, user, password);
|
||||||
System.out.println("Connected to the MySQL server successfully.");
|
System.out.println("Connected to the MySQL server successfully.");
|
||||||
//同步数据库信息
|
//同步数据库信息
|
||||||
//树级结构,库,表
|
//树级结构,库,表
|
||||||
TableInfo tableInfo = TableInfo.builder()
|
TableInfo tableInfoInsert = TableInfo.builder()
|
||||||
.basicId(basicConfigInfo.getId())
|
.basicId(basicConfigInfo.getId())
|
||||||
.parentId(0L)
|
.parentId(0L)
|
||||||
.tableRemark("")
|
.tableRemark("")
|
||||||
.center("Y")
|
.center("Y")
|
||||||
.tableName(basicConfigInfo.getDataSourcesSystemName() + "(" + databaseName + ")")
|
.type("dataSource")
|
||||||
.createBy(SecurityUtils.getUsername())
|
.tableName(basicConfigInfo.getDataSourcesSystemName() + "(" + databaseName + ")")
|
||||||
.createTime(new Date())
|
.createBy(SecurityUtils.getUsername())
|
||||||
.build();
|
.createTime(new Date())
|
||||||
tableInfoService.saveOrUpdate(tableInfo,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
|
.build();
|
||||||
eq(TableInfo::getTableName,tableInfo.getTableName());
|
tableInfoService.saveOrUpdate(tableInfoInsert, new LambdaUpdateWrapper<TableInfo>(TableInfo.class) {{
|
||||||
eq(TableInfo::getBasicId,basicConfigInfo.getId());
|
eq(TableInfo::getTableName, tableInfoInsert.getTableName());
|
||||||
|
eq(TableInfo::getBasicId, basicConfigInfo.getId());
|
||||||
}});
|
}});
|
||||||
|
//查询列表中的所有tableInfo basic_id 不存在删除
|
||||||
|
//通过查询或去当前tableinfo对象的id
|
||||||
|
TableInfo tableInfo = tableInfoService.selectTableInfoByName(tableInfoInsert);
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
ResultSet rs = metaData.getTables(databaseName,
|
ResultSet rs = metaData.getTables(databaseName,
|
||||||
null, "%", new String[]{"TABLE", "VIEW"});
|
null, "%", new String[]{"TABLE", "VIEW"});
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
//表名
|
//表名
|
||||||
String tableName1 = rs.getString("TABLE_NAME");
|
String tableName = rs.getString("TABLE_NAME");
|
||||||
String tableRemark = rs.getString("REMARKS");
|
String tableRemark = rs.getString("REMARKS");
|
||||||
Connection finalConn = conn;
|
Connection finalConn = conn;
|
||||||
PreparedStatement ps = conn.prepareStatement("select* from " + tableName1);
|
PreparedStatement ps = conn.prepareStatement("select * from " + tableName);
|
||||||
ResultSet rset = ps.executeQuery();
|
ResultSet rset = ps.executeQuery();
|
||||||
Long rowCount = 0L;
|
Long rowCount = 0L;
|
||||||
while(rset.next()) {rowCount++;}
|
while (rset.next()) {
|
||||||
TableInfo build = TableInfo.builder()
|
rowCount++;
|
||||||
.basicId(basicConfigInfo.getId())
|
|
||||||
.tableName(tableName1)
|
|
||||||
.tableRemark(tableRemark.isEmpty()? "null":tableRemark)
|
|
||||||
.parentId(tableInfo.getId())
|
|
||||||
.center("Y")
|
|
||||||
.updateBy(SecurityUtils.getUsername())
|
|
||||||
.dataNum(rowCount)
|
|
||||||
.updateTime(new Date())
|
|
||||||
.build();
|
|
||||||
tableInfoService.saveOrUpdate(build,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
|
|
||||||
eq(TableInfo::getTableName,build.getTableName());
|
|
||||||
eq(TableInfo::getBasicId,basicConfigInfo.getId());
|
|
||||||
}});
|
|
||||||
TableInfo table = tableInfoService.selectTableInfoByName(build);
|
|
||||||
Runnable thread = new Runnable() {
|
|
||||||
@SneakyThrows
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
syncData(finalConn, databaseName, table);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new ServletException("连接失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
thread.run();
|
|
||||||
}
|
}
|
||||||
|
TableInfo build = TableInfo.builder()
|
||||||
|
.basicId(basicConfigInfo.getId())
|
||||||
|
.tableName(tableName)
|
||||||
|
//bug点,tableRemark为空,造成空指针异常
|
||||||
|
.tableRemark(tableRemark == null ? "" : tableRemark)
|
||||||
|
.parentId(tableInfo.getId())
|
||||||
|
.type("dataTable")
|
||||||
|
.center("Y")
|
||||||
|
.updateBy(SecurityUtils.getUsername())
|
||||||
|
.dataNum(rowCount)
|
||||||
|
.updateTime(new Date())
|
||||||
|
.build();
|
||||||
|
tableInfoService.saveOrUpdate(build, new LambdaUpdateWrapper<>(TableInfo.class) {{
|
||||||
|
eq(TableInfo::getTableName, build.getTableName());
|
||||||
|
eq(TableInfo::getBasicId, basicConfigInfo.getId());
|
||||||
|
}});
|
||||||
|
TableInfo table = tableInfoService.selectTableInfoByName(build);
|
||||||
|
//线程池
|
||||||
|
ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
|
threadPool.submit(() -> {
|
||||||
|
try {
|
||||||
|
syncData(finalConn, databaseName, table);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
try {
|
||||||
|
throw new ServletException("同步数据失败");
|
||||||
|
} catch (ServletException ex) {
|
||||||
|
throw new RuntimeException(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Runnable thread = new Runnable() {
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
//同步
|
||||||
|
syncData(finalConn, databaseName, table);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw new ServletException("连接失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.run();
|
||||||
|
ps.close();
|
||||||
|
}
|
||||||
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
throw new ServletException("连接失败");
|
throw new ServletException("连接失败");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncData (Connection conn, String databaseName, TableInfo table) throws SQLException {
|
/**
|
||||||
|
* 同步数据
|
||||||
|
*
|
||||||
|
* @param conn
|
||||||
|
* @param databaseName
|
||||||
|
* @param table
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void syncData(Connection conn, String databaseName, TableInfo table) throws SQLException {
|
||||||
|
ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
PreparedStatement ps = conn.prepareStatement(
|
PreparedStatement ps = conn.prepareStatement(
|
||||||
" SELECT " +
|
" SELECT " +
|
||||||
" COLUMN_NAME AS '字段', " +
|
" COLUMN_NAME , " +
|
||||||
" COLUMN_COMMENT AS '字段注释', " +
|
" COLUMN_COMMENT ," +
|
||||||
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END AS '是否主键'," +
|
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END ," +
|
||||||
" CASE \n" +
|
" CASE \n" +
|
||||||
" WHEN DATA_TYPE = 'int' THEN 'Integer' " +
|
" WHEN DATA_TYPE = 'int' THEN 'Integer' " +
|
||||||
" WHEN DATA_TYPE = 'bigint' THEN 'Long' " +
|
" WHEN DATA_TYPE = 'bigint' THEN 'Long' " +
|
||||||
|
@ -205,13 +247,13 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
" WHEN DATA_TYPE = 'decimal' THEN 'BigDecimal' " +
|
" WHEN DATA_TYPE = 'decimal' THEN 'BigDecimal' " +
|
||||||
" WHEN DATA_TYPE = 'tinyint' AND COLUMN_TYPE = 'tinyint(1)' THEN 'Boolean'" +
|
" WHEN DATA_TYPE = 'tinyint' AND COLUMN_TYPE = 'tinyint(1)' THEN 'Boolean'" +
|
||||||
" ELSE DATA_TYPE -- 如果无法映射,则返回原始数据库类型 \n" +
|
" ELSE DATA_TYPE -- 如果无法映射,则返回原始数据库类型 \n" +
|
||||||
" END AS 'Java类型', " +
|
" END , " +
|
||||||
" DATA_TYPE AS '数据库类型', -- 原始的数据库类型 \n" +
|
" DATA_TYPE , -- 原始的数据库类型 \n" +
|
||||||
" COLUMN_TYPE AS '详细的数据库类型', -- 更详细的数据库类型,可能包含长度、精度等 \n" +
|
" COLUMN_TYPE , -- 更详细的数据库类型,可能包含长度、精度等 \n" +
|
||||||
" CHARACTER_MAXIMUM_LENGTH AS '长度', \n" +
|
" CHARACTER_MAXIMUM_LENGTH , \n" +
|
||||||
" NUMERIC_SCALE AS '小数位', \n" +
|
" NUMERIC_SCALE , \n" +
|
||||||
" IS_NULLABLE AS '是否为空', \n" +
|
" IS_NULLABLE , \n" +
|
||||||
" COLUMN_DEFAULT AS '默认值' \n" +
|
" COLUMN_DEFAULT \n" +
|
||||||
"FROM INFORMATION_SCHEMA.COLUMNS WHERE \n" +
|
"FROM INFORMATION_SCHEMA.COLUMNS WHERE \n" +
|
||||||
"TABLE_SCHEMA = '" + databaseName + "' -- 替换为你的数据库名称 \n" +
|
"TABLE_SCHEMA = '" + databaseName + "' -- 替换为你的数据库名称 \n" +
|
||||||
"AND TABLE_NAME = '" + table.getTableName() + "'");
|
"AND TABLE_NAME = '" + table.getTableName() + "'");
|
||||||
|
@ -220,117 +262,149 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
|
||||||
// NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS
|
// NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
// WHERE TABLE_SCHEMA = '数据库名' AND TABLE_NAME = '表名'"
|
// WHERE TABLE_SCHEMA = '数据库名' AND TABLE_NAME = '表名'"
|
||||||
ResultSet resultSet = ps.executeQuery();
|
ResultSet resultSet = ps.executeQuery();
|
||||||
while (resultSet.next()){
|
while (resultSet.next()) {
|
||||||
String columnName = String.valueOf( resultSet.getString(1));
|
String columnName = String.valueOf(resultSet.getString(1));
|
||||||
String columnComment = String.valueOf( resultSet.getObject(2));
|
String columnComment = String.valueOf(resultSet.getObject(2));
|
||||||
String columnKey = String.valueOf( resultSet.getObject(3));
|
String columnKey = String.valueOf(resultSet.getObject(3));
|
||||||
String end = String.valueOf( resultSet.getObject(4));
|
String end = String.valueOf(resultSet.getObject(4));
|
||||||
String dataType = String.valueOf( resultSet.getObject(5));
|
String dataType = String.valueOf(resultSet.getObject(5));
|
||||||
String columnType = String.valueOf( resultSet.getObject(6));
|
String columnType = String.valueOf(resultSet.getObject(6));
|
||||||
String characterMaximumLength = String.valueOf(resultSet.getInt(7));
|
String characterMaximumLength = String.valueOf(resultSet.getInt(7));
|
||||||
String NumericScale = String.valueOf(resultSet.getInt(8));
|
String NumericScale = String.valueOf(resultSet.getInt(8));
|
||||||
String isNullable = String.valueOf( resultSet.getObject(9));
|
String isNullable = String.valueOf(resultSet.getObject(9));
|
||||||
String columnDefault = String.valueOf( resultSet.getObject(10));
|
String columnDefault = String.valueOf(resultSet.getObject(10));
|
||||||
Structure build = Structure.builder()
|
Structure build = Structure.builder()
|
||||||
.tableId(table.getId())
|
.tableId(table.getId())
|
||||||
.columnName(String.valueOf(columnName))
|
.columnName(String.valueOf(columnName))
|
||||||
.columnRemark(columnComment)
|
.columnRemark(columnComment)
|
||||||
.isPrimary("是".equals(columnKey) ? "Y" : "N")
|
.isPrimary("是".equals(columnKey) ? "Y" : "N")
|
||||||
.javaType( end)
|
.javaType(end)
|
||||||
.columnType( dataType)
|
.columnType(dataType)
|
||||||
.columnType(columnType)
|
.columnType(columnType)
|
||||||
.columnLength(characterMaximumLength)
|
.columnLength(characterMaximumLength)
|
||||||
.columnDecimals( NumericScale)
|
.columnDecimals(NumericScale)
|
||||||
.isNull("YES".equals(isNullable) ? "Y" : "N")
|
.isNull("YES".equals(isNullable) ? "Y" : "N")
|
||||||
.defaultValue( columnDefault)
|
.defaultValue(columnDefault)
|
||||||
.build();
|
.build();
|
||||||
structureService.saveOrUpdate(build,new LambdaUpdateWrapper<Structure>(){{
|
threadPool.submit(() -> {
|
||||||
eq(Structure::getTableId,build.getTableId());
|
structureService.saveOrUpdate(build, new LambdaUpdateWrapper<Structure>() {{
|
||||||
eq(Structure::getColumnName,build.getColumnName());
|
eq(Structure::getTableId, build.getTableId());
|
||||||
eq(Structure::getColumnRemark,build.getColumnRemark());
|
eq(Structure::getColumnName, build.getColumnName());
|
||||||
}});
|
eq(Structure::getColumnRemark, build.getColumnRemark());
|
||||||
|
}});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
threadPool.shutdown();
|
||||||
|
ps.close();
|
||||||
/**
|
|
||||||
* 获取数据接入接口数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List getDataByEtl() {
|
|
||||||
List<BasicConfigInfo> list = this.list();
|
|
||||||
List<Map<String,List<String>>> mapList = new ArrayList<>();
|
|
||||||
for (BasicConfigInfo info : list) {
|
|
||||||
//定义下面需要的对象
|
|
||||||
String url = "jdbc:" + info.getDatabaseType() + "://" + info.getHost() + ":" + info.getPort() + "/" + info.getDatabaseName() + "";
|
|
||||||
String user = info.getUsername();
|
|
||||||
String password = info.getPassword();
|
|
||||||
Connection conn = null;
|
|
||||||
try {
|
|
||||||
conn = DriverManager.getConnection(url, user, password);
|
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
|
||||||
ResultSet resultSet = metaData.getCatalogs();
|
|
||||||
while (resultSet.next()){
|
|
||||||
//库名
|
|
||||||
String catalogs = resultSet.getString("TABLE_CAT");
|
|
||||||
log.info(catalogs);
|
|
||||||
// 获取表名
|
|
||||||
ResultSet rs = metaData.getTables(info.getDatabaseName(),null, "%", new String[]{"TABLE", "VIEW"});
|
|
||||||
try {
|
|
||||||
ArrayList<String> tableName = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
|
||||||
//表名
|
|
||||||
String tableName1 = rs.getString("TABLE_NAME");
|
|
||||||
tableName.add( rs.getString("TABLE_NAME"));
|
|
||||||
}
|
|
||||||
mapList.add(new HashMap<>(){{
|
|
||||||
//库名,表名
|
|
||||||
put(catalogs,tableName);
|
|
||||||
}});
|
|
||||||
}catch (Exception exception){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
log.error(e.getMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mapList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取响应体对象
|
* 获取响应体对象
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TableTreeResp> getTableTree() {
|
public List<TableTreeResp> getTableTree() {
|
||||||
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo(){{setParentId(0L);}}).stream().map(tableInfo ->{
|
ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||||
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
|
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
||||||
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
setParentId(0L);
|
||||||
setParentId(tableInfo.getId());
|
}}).stream().map(tableInfo -> {
|
||||||
}}).stream().map(info -> {
|
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
|
||||||
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId,info.getId()));
|
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
|
||||||
return TableInfoStructureResp.builder()
|
setParentId(tableInfo.getId());
|
||||||
.id(info.getId())
|
}}).stream().map(info -> {
|
||||||
.tableName(info.getTableName())
|
TableInfoStructureResp tableInfoStructureResp = null;
|
||||||
.center(info.getCenter())
|
Future<TableInfoStructureResp> submit = threadPool.submit(() -> {
|
||||||
.tableRemark(info.getTableRemark())
|
return TableInfoStructureResp.builder()
|
||||||
.dataNum(info.getDataNum())
|
.id(info.getId())
|
||||||
.parentId(info.getParentId())
|
.tableName(info.getTableName())
|
||||||
.databaseType(basicConfigInfo.getDatabaseType())
|
.center(info.getCenter())
|
||||||
.structureList(structureList)
|
.tableRemark(info.getTableRemark())
|
||||||
.basicId(info.getBasicId())
|
.type(info.getType())
|
||||||
.build();
|
.dataNum(info.getDataNum())
|
||||||
}).collect(Collectors.toList());
|
.parentId(info.getParentId())
|
||||||
return TableTreeResp.builder()
|
.databaseType(basicConfigInfo.getDatabaseType())
|
||||||
.tableInfo(tableInfo)
|
.structureList(null)
|
||||||
.basicConfigInfo(basicConfigInfo)
|
.basicId(info.getBasicId())
|
||||||
.Children(tableInfoStructureRespList)
|
|
||||||
.build();
|
.build();
|
||||||
}).collect(Collectors.toList());
|
});
|
||||||
|
try {
|
||||||
|
tableInfoStructureResp = submit.get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return tableInfoStructureResp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return TableTreeResp.builder()
|
||||||
|
.tableInfo(tableInfo)
|
||||||
|
.basicConfigInfo(basicConfigInfo)
|
||||||
|
.Children(tableInfoStructureRespList)
|
||||||
|
.build();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
threadPool.shutdown();
|
||||||
|
while (true) if (threadPool.isTerminated()) break;
|
||||||
|
|
||||||
return tableTreeRespList;
|
return tableTreeRespList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public TableInfoStructureResp getTableInfo(Long tableId) {
|
||||||
|
TableInfo tableInfo = tableInfoService.selectTableInfoById(tableId);
|
||||||
|
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
|
||||||
|
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>()
|
||||||
|
.eq(Structure::getTableId, tableInfo.getId()));
|
||||||
|
return TableInfoStructureResp.builder()
|
||||||
|
.id(tableInfo.getId())
|
||||||
|
.tableName(tableInfo.getTableName())
|
||||||
|
.center(tableInfo.getCenter())
|
||||||
|
.tableRemark(tableInfo.getTableRemark())
|
||||||
|
.dataNum(tableInfo.getDataNum())
|
||||||
|
.parentId(tableInfo.getParentId())
|
||||||
|
.databaseType(basicConfigInfo.getDatabaseType())
|
||||||
|
.structureList(structureList)
|
||||||
|
.basicId(tableInfo.getBasicId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
PreparedStatement ps = conn.prepareStatement("select Count(0) from " + tableInfo.getTableName());
|
||||||
|
ResultSet resultSet = ps.executeQuery();
|
||||||
|
while (resultSet.next()){
|
||||||
|
String a = String.valueOf(resultSet.getObject(1));
|
||||||
|
totalNum = resultSet.getLong(1);
|
||||||
|
}
|
||||||
|
basicTableInfoResp = BasicTableInfoResp.builder()
|
||||||
|
.dataResourceName(basicConfigInfo.getDataResourceName())
|
||||||
|
.dataSourcesSystemName(basicConfigInfo.getDataSourcesSystemName())
|
||||||
|
.databaseName(basicConfigInfo.getDatabaseName())
|
||||||
|
.tableName(tableInfo.getTableName())
|
||||||
|
.tableRemark(tableInfo.getTableRemark())
|
||||||
|
.id(tableId)
|
||||||
|
.basicId(basicConfigInfo.getId())
|
||||||
|
.totalNum(totalNum)
|
||||||
|
.build();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return basicTableInfoResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -97,4 +97,12 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
|
||||||
{
|
{
|
||||||
return structureMapper.deleteStructureById(id);
|
return structureMapper.deleteStructureById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateStructureInfoDict(Structure structure) {
|
||||||
|
if ("N".equals(structure.getIsDictionary())){
|
||||||
|
structure.setDictionaryTable("");
|
||||||
|
}
|
||||||
|
return this.saveOrUpdate(structure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
package com.muyu.etl.service.impl;
|
package com.muyu.etl.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.etl.domain.BasicConfigInfo;
|
||||||
|
import com.muyu.etl.domain.Structure;
|
||||||
|
import com.muyu.etl.domain.resp.TableInfoStructureResp;
|
||||||
|
import com.muyu.etl.service.BasicConfigInfoService;
|
||||||
|
import com.muyu.etl.service.StructureService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -19,10 +26,12 @@ import com.muyu.etl.service.TableInfoService;
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Service
|
@Service
|
||||||
public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService
|
public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TableInfoMapper tableInfoMapper;
|
private TableInfoMapper tableInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private StructureService structureService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询库表基础信息
|
* 查询库表基础信息
|
||||||
|
@ -31,8 +40,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 库表基础信息
|
* @return 库表基础信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableInfo selectTableInfoById(Long id)
|
public TableInfo selectTableInfoById(Long id) {
|
||||||
{
|
|
||||||
return tableInfoMapper.selectTableInfoById(id);
|
return tableInfoMapper.selectTableInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +51,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 库表基础信息
|
* @return 库表基础信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TableInfo> selectTableInfoList(TableInfo tableInfo)
|
public List<TableInfo> selectTableInfoList(TableInfo tableInfo) {
|
||||||
{
|
|
||||||
return tableInfoMapper.selectTableInfoList(tableInfo);
|
return tableInfoMapper.selectTableInfoList(tableInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +62,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertTableInfo(TableInfo tableInfo)
|
public int insertTableInfo(TableInfo tableInfo) {
|
||||||
{
|
|
||||||
tableInfo.setCreateTime(DateUtils.getNowDate());
|
tableInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
return tableInfoMapper.insertTableInfo(tableInfo);
|
return tableInfoMapper.insertTableInfo(tableInfo);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +74,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateTableInfo(TableInfo tableInfo)
|
public int updateTableInfo(TableInfo tableInfo) {
|
||||||
{
|
|
||||||
tableInfo.setUpdateTime(DateUtils.getNowDate());
|
tableInfo.setUpdateTime(DateUtils.getNowDate());
|
||||||
return tableInfoMapper.updateTableInfo(tableInfo);
|
return tableInfoMapper.updateTableInfo(tableInfo);
|
||||||
}
|
}
|
||||||
|
@ -81,8 +86,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteTableInfoByIds(Long[] ids)
|
public int deleteTableInfoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return tableInfoMapper.deleteTableInfoByIds(ids);
|
return tableInfoMapper.deleteTableInfoByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +97,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteTableInfoById(Long id)
|
public int deleteTableInfoById(Long id) {
|
||||||
{
|
|
||||||
return tableInfoMapper.deleteTableInfoById(id);
|
return tableInfoMapper.deleteTableInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,4 +105,6 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
|
||||||
public TableInfo selectTableInfoByName(TableInfo table) {
|
public TableInfo selectTableInfoByName(TableInfo table) {
|
||||||
return tableInfoMapper.selectTableInfoByName(table);
|
return tableInfoMapper.selectTableInfoByName(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.etl.mapper.AssetImpowerMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.etl.domain.AssetImpower" id="AssetImpowerResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="basicId" column="basic_id" />
|
||||||
|
<result property="tableId" column="table_id" />
|
||||||
|
<result property="deptId" column="dept_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAssetImpowerVo">
|
||||||
|
select id,basic_id , table_id, dept_id, user_id, remark, create_by, create_time, update_by, update_time from asset_impower
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectAssetImpowerList" parameterType="com.muyu.etl.domain.AssetImpower" resultMap="AssetImpowerResult">
|
||||||
|
<include refid="selectAssetImpowerVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="tableId != null "> and table_id = #{tableId}</if>
|
||||||
|
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||||
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAssetImpowerById" parameterType="Long" resultMap="AssetImpowerResult">
|
||||||
|
<include refid="selectAssetImpowerVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAssetImpower" parameterType="com.muyu.etl.domain.AssetImpower" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into asset_impower
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="basicId != null">basic_id,</if>
|
||||||
|
<if test="tableId != null">table_id,</if>
|
||||||
|
<if test="deptId != null">dept_id,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="basicId != null">#{basicId},</if>
|
||||||
|
<if test="tableId != null">#{tableId},</if>
|
||||||
|
<if test="deptId != null">#{deptId},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAssetImpower" parameterType="com.muyu.etl.domain.AssetImpower">
|
||||||
|
update asset_impower
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="basicId != null">basic_id = #{basicId},</if>
|
||||||
|
<if test="tableId != null">table_id = #{tableId},</if>
|
||||||
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||||
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteAssetImpowerById" parameterType="Long">
|
||||||
|
delete from asset_impower where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteAssetImpowerByIds" parameterType="String">
|
||||||
|
delete from asset_impower where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -72,10 +72,10 @@
|
||||||
<if test="dataSourcesSystemName != null">#{dataSourcesSystemName},</if>
|
<if test="dataSourcesSystemName != null">#{dataSourcesSystemName},</if>
|
||||||
<if test="host != null">#{host},</if>
|
<if test="host != null">#{host},</if>
|
||||||
<if test="port != null">#{port},</if>
|
<if test="port != null">#{port},</if>
|
||||||
<if test="username != null">#{username},</if>
|
|
||||||
<if test="password != null">#{password},</if>
|
|
||||||
<if test="databaseType != null">#{databaseType},</if>
|
<if test="databaseType != null">#{databaseType},</if>
|
||||||
<if test="databaseName != null">#{databaseName},</if>
|
<if test="databaseName != null">#{databaseName},</if>
|
||||||
|
<if test="username != null">#{username},</if>
|
||||||
|
<if test="password != null">#{password},</if>
|
||||||
<if test="initLinkNum != null">#{initLinkNum},</if>
|
<if test="initLinkNum != null">#{initLinkNum},</if>
|
||||||
<if test="maxLinkNum != null">#{maxLinkNum},</if>
|
<if test="maxLinkNum != null">#{maxLinkNum},</if>
|
||||||
<if test="maxWaitTime != null">#{maxWaitTime},</if>
|
<if test="maxWaitTime != null">#{maxWaitTime},</if>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<result property="tableRemark" column="table_remark" />
|
<result property="tableRemark" column="table_remark" />
|
||||||
<result property="dataNum" column="data_num" />
|
<result property="dataNum" column="data_num" />
|
||||||
<result property="center" column="center" />
|
<result property="center" column="center" />
|
||||||
|
<result property="type" column="type" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
@ -20,18 +21,18 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTableInfoVo">
|
<sql id="selectTableInfoVo">
|
||||||
select id, parent_id, basic_id,table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
|
select id, parent_id,type, basic_id,table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTableInfoList" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
|
<select id="selectTableInfoList" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
|
||||||
<include refid="selectTableInfoVo"/>
|
<include refid="selectTableInfoVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
<if test="parentId != null ">and parent_id = #{parentId}</if>
|
||||||
<if test="basicId != null "> and basic_id = #{basicId}</if>
|
<if test="basicId != null ">and basic_id = #{basicId}</if>
|
||||||
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
|
<if test="tableName != null and tableName != ''">and table_name like concat('%', #{tableName}, '%')</if>
|
||||||
<if test="tableRemark != null and tableRemark != ''"> and table_remark = #{tableRemark}</if>
|
<if test="tableRemark != null and tableRemark != ''">and table_remark = #{tableRemark}</if>
|
||||||
<if test="dataNum != null "> and data_num = #{dataNum}</if>
|
<if test="dataNum != null ">and data_num = #{dataNum}</if>
|
||||||
<if test="center != null and center != ''"> and center = #{center}</if>
|
<if test="center != null and center != ''">and center = #{center}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -42,8 +43,8 @@
|
||||||
|
|
||||||
<select id="selectTableInfoByName" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
|
<select id="selectTableInfoByName" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
|
||||||
select * from table_info
|
select * from table_info
|
||||||
where basic_id = #{basicId} and table_name = #{tableName}
|
where basic_id = #{basicId} and (table_name = #{tableName} or parent_id = #{parentId})
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertTableInfo" parameterType="com.muyu.etl.domain.TableInfo" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertTableInfo" parameterType="com.muyu.etl.domain.TableInfo" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="parentId != null">parent_id,</if>
|
<if test="parentId != null">parent_id,</if>
|
||||||
<if test="basicId != null">basic_id,</if>
|
<if test="basicId != null">basic_id,</if>
|
||||||
|
<if test="type != null and type != ''">type,</if>
|
||||||
<if test="tableName != null and tableName != ''">table_name,</if>
|
<if test="tableName != null and tableName != ''">table_name,</if>
|
||||||
<if test="tableRemark != null and tableRemark != ''">table_remark,</if>
|
<if test="tableRemark != null and tableRemark != ''">table_remark,</if>
|
||||||
<if test="dataNum != null">data_num,</if>
|
<if test="dataNum != null">data_num,</if>
|
||||||
|
@ -64,6 +66,7 @@
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="parentId != null">#{parentId},</if>
|
<if test="parentId != null">#{parentId},</if>
|
||||||
<if test="basicId != null">#{basicId},</if>
|
<if test="basicId != null">#{basicId},</if>
|
||||||
|
<if test="type != null and type != ''">#{type},</if>
|
||||||
<if test="tableName != null and tableName != ''">#{tableName},</if>
|
<if test="tableName != null and tableName != ''">#{tableName},</if>
|
||||||
<if test="tableRemark != null and tableRemark != ''">#{tableRemark},</if>
|
<if test="tableRemark != null and tableRemark != ''">#{tableRemark},</if>
|
||||||
<if test="dataNum != null">#{dataNum},</if>
|
<if test="dataNum != null">#{dataNum},</if>
|
||||||
|
@ -81,6 +84,7 @@
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||||
<if test="basicId != null">basic_id = #{basicId},</if>
|
<if test="basicId != null">basic_id = #{basicId},</if>
|
||||||
|
<if test="type != null">type = #{type},</if>
|
||||||
<if test="tableName != null and tableName != ''">table_name = #{tableName},</if>
|
<if test="tableName != null and tableName != ''">table_name = #{tableName},</if>
|
||||||
<if test="tableRemark != null and tableRemark != ''">table_remark = #{tableRemark},</if>
|
<if test="tableRemark != null and tableRemark != ''">table_remark = #{tableRemark},</if>
|
||||||
<if test="dataNum != null">data_num = #{dataNum},</if>
|
<if test="dataNum != null">data_num = #{dataNum},</if>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<module>muyu-job</module>
|
<module>muyu-job</module>
|
||||||
<module>muyu-file</module>
|
<module>muyu-file</module>
|
||||||
<module>muyv-etl</module>
|
<module>muyv-etl</module>
|
||||||
|
<module>muyu-ruleEngine</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>muyu-modules</artifactId>
|
<artifactId>muyu-modules</artifactId>
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -213,6 +213,13 @@
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 规则引擎 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-ruleEngine-common</artifactId>
|
||||||
|
<version>${muyu.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue