feat : 模块抽离 + 自定义查分表模块基本完成
This commit is contained in:
102
custom-query/custom-query-biz/pom.xml
Normal file
102
custom-query/custom-query-biz/pom.xml
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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">
|
||||
<parent>
|
||||
<artifactId>custom-query</artifactId>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>custom-query-biz</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>custom-query-submter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-mybatis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-decrypt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-seata</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>2.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-code</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-excel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.7.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.fateverse.query;
|
||||
|
||||
import cn.fateverse.common.security.annotation.EnableSecurity;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2022/11/10
|
||||
*/
|
||||
@EnableSecurity
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
public class CustomQueryApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CustomQueryApplication.class, args);
|
||||
System.out.println("自定义查询启动");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.fateverse.query.aspect;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.factory.DynamicDataSourceService;
|
||||
import cn.fateverse.query.mapper.DataSourceManageMapper;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class DynamicDataSourceAspect {
|
||||
|
||||
private final DataSourceManageMapper dataSourceManageMapper;
|
||||
|
||||
private final DynamicDataSourceService dynamicDataSourceService;
|
||||
|
||||
public DynamicDataSourceAspect(DataSourceManageMapper dataSourceManageMapper,
|
||||
DynamicDataSourceService dynamicDataSourceService) {
|
||||
this.dataSourceManageMapper = dataSourceManageMapper;
|
||||
this.dynamicDataSourceService = dynamicDataSourceService;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Around("execution(* cn.fateverse.query.service.DynamicDataSourceTableService.*(..))")
|
||||
public Object around(ProceedingJoinPoint point) {
|
||||
try {
|
||||
Object[] args = point.getArgs();
|
||||
Long dataSourceId = (Long) args[args.length - 1];
|
||||
//获取到当前数据源id的数据源
|
||||
DataSourceManage dataSourceManage = dataSourceManageMapper.selectById(dataSourceId);
|
||||
if (null == dataSourceManage) {
|
||||
throw new CustomException("数据源错误!");
|
||||
}
|
||||
DynamicDataSourceMapper dataSourceServiceMapper = dynamicDataSourceService.getMapper(dataSourceManage);
|
||||
//获取到当前代理的对象
|
||||
Object target = point.getTarget();
|
||||
Class<?> targetClass = target.getClass();
|
||||
Field dataSourceManageField = targetClass.getDeclaredField("dataSourceManage");
|
||||
dataSourceManageField.setAccessible(true);
|
||||
dataSourceManageField.set(target, dataSourceManage);
|
||||
//根据数据源信息来获取到对应的具体mapper实现
|
||||
Field dynamicDataSourceMapperField = targetClass.getDeclaredField("dynamicDataSourceMapper");
|
||||
dynamicDataSourceMapperField.setAccessible(true);
|
||||
dynamicDataSourceMapperField.set(target, dataSourceServiceMapper);
|
||||
//运行代理的函数
|
||||
Object proceed;
|
||||
try {
|
||||
proceed = point.proceed();
|
||||
} catch (Exception e) {
|
||||
log.error("数据源{}连接失败", dataSourceManage.getDsName(), e);
|
||||
dynamicDataSourceService.remove(dataSourceId);
|
||||
throw e;
|
||||
}
|
||||
//将表格mapper对象置null
|
||||
dynamicDataSourceMapperField.set(target, null);
|
||||
//对数据源对象置null
|
||||
dataSourceManageField.set(target, null);
|
||||
//返回对象
|
||||
return proceed;
|
||||
} finally {
|
||||
//关闭session
|
||||
dynamicDataSourceService.closeSqlSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.fateverse.query.constant;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-05
|
||||
*/
|
||||
public class QueryConstant {
|
||||
|
||||
|
||||
public static final String PERMISSIONS_KEY = "custom:query:online:";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import cn.fateverse.query.entity.dto.DataAdapterDto;
|
||||
import cn.fateverse.query.entity.query.DataAdapterQuery;
|
||||
import cn.fateverse.query.entity.vo.DataAdapterVo;
|
||||
import cn.fateverse.query.service.DataAdapterService;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源适配器 Controller
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
@Api(value = "数据源适配器管理", tags = "数据源适配器管理")
|
||||
@RestController
|
||||
@RequestMapping("/query/adapter")
|
||||
public class DataAdapterController {
|
||||
|
||||
private final DataAdapterService dataAdapterService;
|
||||
|
||||
public DataAdapterController(DataAdapterService dataAdapterService) {
|
||||
this.dataAdapterService = dataAdapterService;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取数据源适配器列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:list')")
|
||||
public Result<TableDataInfo<DataAdapterVo>> list(DataAdapterQuery query) {
|
||||
TableDataInfo<DataAdapterVo> dataInfo = dataAdapterService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取校验规则option")
|
||||
@GetMapping("/option")
|
||||
public Result<List<Option>> option() {
|
||||
List<Option> options = dataAdapterService.searchOptionList();
|
||||
return Result.ok(options);
|
||||
}
|
||||
|
||||
@ApiOperation("导出excel数据")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:export')")
|
||||
public void export(DataAdapterQuery query) {
|
||||
List<DataAdapterVo> list = dataAdapterService.exportList(query);
|
||||
ExcelUtil.exportExcel(list, DataAdapterVo.class);
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源适配器详细信息")
|
||||
@GetMapping("/{adapterId}")
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:info')")
|
||||
public Result<DataAdapterVo> info(@PathVariable Long adapterId) {
|
||||
ObjectUtils.checkPk(adapterId);
|
||||
DataAdapterVo dataAdapter = dataAdapterService.searchById(adapterId);
|
||||
return Result.ok(dataAdapter);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("模拟执行适配器函数")
|
||||
@PostMapping("/mock/execute")
|
||||
@Log(title = "模拟执行适配器函数", businessType = BusinessType.EXECUTE_CODE)
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:execute')")
|
||||
public Result<Object> mockExecute(@RequestBody @Validated DataAdapterDto dataAdapter) {
|
||||
if (ObjectUtils.isEmpty(dataAdapter.getMockData())) {
|
||||
throw new CustomException("请先获取模拟数据");
|
||||
}
|
||||
Object result = dataAdapterService.mockExecute(dataAdapter);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("新增数据源适配器")
|
||||
@PostMapping
|
||||
@Log(title = "新增数据源适配器", businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:add')")
|
||||
public Result<Void> add(@RequestBody @Validated DataAdapterDto dataAdapter) {
|
||||
dataAdapterService.save(dataAdapter);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("修改数据源适配器")
|
||||
@PutMapping
|
||||
@Log(title = "修改数据源适配器", businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated DataAdapterDto dataAdapter) {
|
||||
ObjectUtils.checkPk(dataAdapter.getAdapterId());
|
||||
dataAdapterService.edit(dataAdapter);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除数据源适配器")
|
||||
@DeleteMapping("/{adapterIdList}")
|
||||
@Log(title = "删除数据源适配器", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('query:adapter:del')")
|
||||
public Result<Void> batchDel(@PathVariable List<Long> adapterIdList) {
|
||||
ObjectUtils.checkPkList(adapterIdList);
|
||||
dataAdapterService.removeBatch(adapterIdList);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.entity.dto.DataSourceManageDto;
|
||||
import cn.fateverse.query.entity.query.DataSourceManageQuery;
|
||||
import cn.fateverse.query.entity.vo.DataSourceManageVo;
|
||||
import cn.fateverse.query.service.DataSourceManageService;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据源管理 Controller
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Api(value = "数据源管理管理",tags = "数据源管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/datasource")
|
||||
public class DataSourceManageController {
|
||||
|
||||
private final DataSourceManageService dataSourceManageService;
|
||||
|
||||
public DataSourceManageController(DataSourceManageService dataSourceManageService) {
|
||||
this.dataSourceManageService = dataSourceManageService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源管理列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('query:source:list')")
|
||||
public Result<TableDataInfo<DataSourceManageVo>> list(DataSourceManageQuery query) {
|
||||
TableDataInfo<DataSourceManageVo> dataInfo = dataSourceManageService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源option")
|
||||
@GetMapping("/option")
|
||||
public Result<List<Option>> option(){
|
||||
List<Option> options = dataSourceManageService.searchOptionList();
|
||||
return Result.ok(options);
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源类型")
|
||||
@GetMapping("/option/type")
|
||||
public Result<List<Option>> datasourceType(){
|
||||
List<Option> optionList = Arrays.stream(DynamicSourceEnum.values()).map(dynamicSourceEnum -> Option.builder()
|
||||
.label(dynamicSourceEnum.getType())
|
||||
.value(dynamicSourceEnum)
|
||||
.build()).collect(Collectors.toList());
|
||||
return Result.ok(optionList);
|
||||
}
|
||||
|
||||
@ApiOperation("导出excel数据")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('query:source:export')")
|
||||
public void export(DataSourceManageQuery query){
|
||||
List<DataSourceManageVo> list = dataSourceManageService.exportList(query);
|
||||
ExcelUtil.exportExcel(list, DataSourceManageVo.class);
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源管理详细信息")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('query:source:info')")
|
||||
public Result<DataSourceManageVo> info(@PathVariable Long id) {
|
||||
ObjectUtils.checkPk(id);
|
||||
DataSourceManageVo dataSourceManageVo = dataSourceManageService.searchById(id);
|
||||
return Result.ok(dataSourceManageVo);
|
||||
}
|
||||
|
||||
@ApiOperation("新增数据源管理")
|
||||
@PostMapping
|
||||
@Log(title = "新增数据源管理",businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('query:source:add')")
|
||||
public Result<Void> add(@RequestBody @Validated DataSourceManageDto manageDto){
|
||||
checkDataSource(manageDto);
|
||||
if (StrUtil.isBlank(manageDto.getPassword())){
|
||||
return Result.error("数据源密码不能为空!");
|
||||
}
|
||||
dataSourceManageService.save(manageDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("修改数据源管理")
|
||||
@PutMapping
|
||||
@Log(title = "修改数据源管理",businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('query:source:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated DataSourceManageDto manageDto){
|
||||
ObjectUtils.checkPk(manageDto.getId());
|
||||
checkDataSource(manageDto);
|
||||
dataSourceManageService.edit(manageDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除数据源管理")
|
||||
@DeleteMapping("/{idList}")
|
||||
@Log(title = "删除数据源管理",businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('query:source:del')")
|
||||
public Result<Void> batchDel(@PathVariable List<Long> idList){
|
||||
ObjectUtils.checkPkList(idList);
|
||||
dataSourceManageService.removeBatch(idList);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据源字段的合规性
|
||||
* @param dataSource 数据源
|
||||
*/
|
||||
public void checkDataSource(DataSourceManageDto dataSource){
|
||||
if (1 == dataSource.getConfigType()){
|
||||
if (StrUtil.isEmpty(dataSource.getHost())) {
|
||||
throw new CustomException("主机地址不能为空!");
|
||||
}
|
||||
if (null == dataSource.getPort()) {
|
||||
throw new CustomException("主机端口不能为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(dataSource.getDbName())) {
|
||||
throw new CustomException("数据库名称不能为空!");
|
||||
}
|
||||
}else {
|
||||
if (StrUtil.isEmpty(dataSource.getUrl())) {
|
||||
throw new CustomException("数据源接地址不能为空!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.query.entity.DynamicTable;
|
||||
import cn.fateverse.query.entity.query.DynamicTableQuery;
|
||||
import cn.fateverse.query.service.DynamicDataSourceTableService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Api(value = "动态数据源表格管理",tags = "动态数据源表格管理")
|
||||
@RestController
|
||||
@RequestMapping("/dynamic/table")
|
||||
public class DynamicDataSourceTableController {
|
||||
|
||||
private final DynamicDataSourceTableService dynamicDataSourceTableService;
|
||||
|
||||
public DynamicDataSourceTableController(DynamicDataSourceTableService dynamicDataSourceTableService) {
|
||||
this.dynamicDataSourceTableService = dynamicDataSourceTableService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取数据源信息")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('query:dynamic-table:list')")
|
||||
public Result<TableDataInfo<DynamicTable>> test(DynamicTableQuery query, Long dataSourceId) {
|
||||
if (LongUtils.isNull(dataSourceId)){
|
||||
return Result.error("数据源id不能为空!");
|
||||
}
|
||||
TableDataInfo<DynamicTable> dataInfo = dynamicDataSourceTableService.searchTableList(query, dataSourceId);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.query.entity.dto.DynamicEchartsDto;
|
||||
import cn.fateverse.query.entity.query.DynamicEchartsQuery;
|
||||
import cn.fateverse.query.entity.vo.DynamicEchartsVo;
|
||||
import cn.fateverse.query.service.DynamicEchartsService;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态echarts图表 Controller
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
@Api(value = "动态echarts图表管理",tags = "动态echarts图表管理")
|
||||
@RestController
|
||||
@RequestMapping("/echarts")
|
||||
public class DynamicEchartsController {
|
||||
|
||||
private final DynamicEchartsService dynamicEchartsService;
|
||||
|
||||
public DynamicEchartsController(DynamicEchartsService dynamicEchartsService) {
|
||||
this.dynamicEchartsService = dynamicEchartsService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取动态echarts图表列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:list')")
|
||||
public Result<TableDataInfo<DynamicEchartsVo>> list(DynamicEchartsQuery query) {
|
||||
TableDataInfo<DynamicEchartsVo> dataInfo = dynamicEchartsService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("获取校验规则option")
|
||||
@GetMapping("/option")
|
||||
public Result<List<Option>> option(){
|
||||
List<Option> options = dynamicEchartsService.searchOptionList();
|
||||
return Result.ok(options);
|
||||
}
|
||||
|
||||
@ApiOperation("导出excel数据")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:export')")
|
||||
public void export(DynamicEchartsQuery query){
|
||||
List<DynamicEchartsVo> list = dynamicEchartsService.exportList(query);
|
||||
ExcelUtil.exportExcel(list,DynamicEchartsVo.class);
|
||||
}
|
||||
|
||||
@ApiOperation("获取动态echarts图表详细信息")
|
||||
@GetMapping("/{echartsId}")
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:info')")
|
||||
public Result<DynamicEchartsVo> info(@PathVariable Long echartsId) {
|
||||
ObjectUtils.checkPk(echartsId);
|
||||
DynamicEchartsVo dynamicEcharts = dynamicEchartsService.searchById(echartsId);
|
||||
return Result.ok(dynamicEcharts);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("新增动态echarts图表")
|
||||
@PostMapping
|
||||
@Log(title = "新增动态echarts图表",businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:add')")
|
||||
public Result<Void> add(@RequestBody @Validated DynamicEchartsDto dynamicEcharts){
|
||||
dynamicEchartsService.save(dynamicEcharts);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("修改动态echarts图表")
|
||||
@PutMapping
|
||||
@Log(title = "修改动态echarts图表",businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated DynamicEchartsDto dynamicEcharts){
|
||||
ObjectUtils.checkPk(dynamicEcharts.getEchartsId());
|
||||
dynamicEchartsService.edit(dynamicEcharts);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除动态echarts图表")
|
||||
@DeleteMapping("/{echartsIdList}")
|
||||
@Log(title = "删除动态echarts图表",businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('query:echarts:del')")
|
||||
public Result<Void> batchDel(@PathVariable List<Long> echartsIdList){
|
||||
ObjectUtils.checkPkList(echartsIdList);
|
||||
dynamicEchartsService.removeBatch(echartsIdList);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.decrypt.annotation.Encrypt;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.vo.CustomQueryResult;
|
||||
import cn.fateverse.query.entity.dto.SearchInfo;
|
||||
import cn.fateverse.query.service.PageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-05
|
||||
*/
|
||||
@Api(value = "上线自定义查询页面",tags = "上线自定义查询页面")
|
||||
@RestController
|
||||
@RequestMapping("/page")
|
||||
public class PageController {
|
||||
|
||||
|
||||
private final PageService pageService;
|
||||
|
||||
|
||||
public PageController(PageService pageService) {
|
||||
this.pageService = pageService;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取到自定义查询的信息")
|
||||
@GetMapping("/{queryId}")
|
||||
@Encrypt
|
||||
public Result<CustomQueryResult> info(@PathVariable @EncryptField String queryId){
|
||||
if (ObjectUtils.isEmpty(queryId)) {
|
||||
return Result.error("请求参数为空");
|
||||
}
|
||||
return pageService.searchQueryInfoAndData(Long.valueOf(queryId));
|
||||
}
|
||||
|
||||
@ApiOperation("查询数据")
|
||||
@PostMapping("/data")
|
||||
@Encrypt
|
||||
public Result<TableDataInfo<Map<String, Object>>> searchData(@RequestBody @Validated SearchInfo searchInfo){
|
||||
TableDataInfo<Map<String, Object>> tableDataInfo = pageService.searchQueryData(searchInfo);
|
||||
return Result.ok(tableDataInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.decrypt.annotation.Encrypt;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.vo.CustomQueryResult;
|
||||
import cn.fateverse.query.entity.dto.SearchInfo;
|
||||
import cn.fateverse.query.entity.dto.SqlDto;
|
||||
import cn.fateverse.query.entity.vo.SqlInfoVo;
|
||||
import cn.fateverse.query.service.SqlSearchService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-09
|
||||
*/
|
||||
@Api(value = "sql万能查询", tags = "sql万能查询")
|
||||
@RestController
|
||||
@RequestMapping("/sql/search")
|
||||
public class SqlSearchController {
|
||||
|
||||
private final SqlSearchService sqlSearchService;
|
||||
|
||||
|
||||
public SqlSearchController(SqlSearchService sqlSearchService) {
|
||||
this.sqlSearchService = sqlSearchService;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取到sql自定义查询的基础信息")
|
||||
@GetMapping("/{queryId}")
|
||||
@Encrypt
|
||||
public Result<SqlInfoVo> topology(@PathVariable @EncryptField String queryId) {
|
||||
SqlInfoVo sqlInfoVo = sqlSearchService.search(Long.parseLong(queryId));
|
||||
return Result.ok(sqlInfoVo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("保存sql自定义查询参数")
|
||||
@PostMapping
|
||||
@Encrypt
|
||||
public Result<Void> save(@RequestBody @Validated SqlDto sqlDto) {
|
||||
sqlSearchService.saveData(sqlDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("预览")
|
||||
@Encrypt
|
||||
@PutMapping("/preview")
|
||||
public Result<CustomQueryResult> preview(@RequestBody @Validated SqlDto sqlDto) {
|
||||
return sqlSearchService.preview(sqlDto);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("发布")
|
||||
@Encrypt
|
||||
@PostMapping("/publish")
|
||||
public Result<Void> publish(@RequestBody @Validated SqlDto sqlDto) {
|
||||
if (ObjectUtils.isEmpty(sqlDto.getMenuId())) {
|
||||
return Result.error("上级菜单不能为空!");
|
||||
}
|
||||
sqlSearchService.publish(sqlDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("撤销")
|
||||
@Encrypt
|
||||
@PutMapping("/cancel/{queryId}")
|
||||
public Result<Void> cancel(@PathVariable @EncryptField String queryId){
|
||||
sqlSearchService.cancel(Long.valueOf(queryId));
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("预览弹窗数据获取")
|
||||
@Encrypt
|
||||
@PostMapping("/preview/data")
|
||||
public Result<TableDataInfo<Map<String, Object>>> previewData(@RequestBody @Validated SearchInfo searchInfo) {
|
||||
TableDataInfo<Map<String, Object>> tableDataInfo = sqlSearchService.previewData(searchInfo.getList(), searchInfo.getQueryId());
|
||||
return Result.ok(tableDataInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.decrypt.annotation.Encrypt;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import cn.fateverse.query.entity.vo.UniQueryVo;
|
||||
import cn.fateverse.query.entity.dto.UniQueryDto;
|
||||
import cn.fateverse.query.entity.query.UniQueryQuery;
|
||||
import cn.fateverse.query.service.UniQueryService;
|
||||
import cn.fateverse.query.service.impl.SqlUniQueryServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-09
|
||||
*/
|
||||
@Api(value = "SQL万能查询管理", tags = "SQL万能查询管理")
|
||||
@RestController
|
||||
@RequestMapping("/sql/uni")
|
||||
public class SqlUniQueryController {
|
||||
|
||||
|
||||
private final UniQueryService uniQueryService;
|
||||
|
||||
|
||||
public SqlUniQueryController(SqlUniQueryServiceImpl uniQueryService) {
|
||||
this.uniQueryService = uniQueryService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取万能查询列表")
|
||||
@GetMapping
|
||||
@Encrypt
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:list')")
|
||||
public Result<TableDataInfo<UniQueryVo>> list(UniQueryQuery query) {
|
||||
TableDataInfo<UniQueryVo> dataInfo = uniQueryService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("导出excel数据")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:export')")
|
||||
public void export(UniQueryQuery query) {
|
||||
List<UniQueryVo> list = uniQueryService.exportList(query);
|
||||
ExcelUtil.exportExcel(list, UniQueryVo.class);
|
||||
}
|
||||
|
||||
@ApiOperation("获取万能查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
@Encrypt
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:info')")
|
||||
public Result<UniQueryVo> info(@PathVariable @EncryptField String id) {
|
||||
ObjectUtils.checkPk(id);
|
||||
UniQueryVo uniQuery = uniQueryService.searchById(Long.parseLong(id));
|
||||
return Result.ok(uniQuery);
|
||||
}
|
||||
|
||||
@ApiOperation("新增万能查询")
|
||||
@PostMapping
|
||||
@Log(title = "新增万能查询", businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:add')")
|
||||
public Result<UniQueryVo> add(@RequestBody @Validated UniQueryDto dto) {
|
||||
return uniQueryService.save(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("修改万能查询")
|
||||
@PutMapping
|
||||
@Encrypt
|
||||
@Log(title = "修改万能查询", businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated UniQueryDto dto) {
|
||||
ObjectUtils.checkPk(dto.getId());
|
||||
uniQueryService.edit(dto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除万能查询")
|
||||
@DeleteMapping("/{idList}")
|
||||
@Encrypt
|
||||
@Log(title = "删除万能查询", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('sql:uni-query:del')")
|
||||
public Result<Void> batchDel(@PathVariable @EncryptField List<String> idList) {
|
||||
List<Long> collect = idList.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
ObjectUtils.checkPkList(idList);
|
||||
uniQueryService.removeBatch(collect);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.utils.LongUtils;
|
||||
import cn.fateverse.query.entity.TableInfo;
|
||||
import cn.fateverse.query.entity.dto.ImportDto;
|
||||
import cn.fateverse.query.entity.query.TableQuery;
|
||||
import cn.fateverse.query.entity.vo.TableVo;
|
||||
import cn.fateverse.query.service.TableService;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义查询表格维护 Controller
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Api(value = "自定义查询表格维护管理", tags = "自定义查询表格维护管理")
|
||||
@RestController
|
||||
@RequestMapping("/table")
|
||||
public class TableController {
|
||||
|
||||
private final TableService tableService;
|
||||
|
||||
public TableController(TableService tableService) {
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取自定义查询表格维护列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('query:table:list')")
|
||||
public Result<TableDataInfo<TableVo>> list(TableQuery query) {
|
||||
TableDataInfo<TableVo> dataInfo = tableService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("根据数据源获取到表格option信息")
|
||||
@GetMapping("/option/{datasourceId}")
|
||||
public Result<List<Option>> option(@PathVariable Long datasourceId){
|
||||
List<Option> optionList = tableService.searchOption(datasourceId);
|
||||
return Result.ok(optionList);
|
||||
}
|
||||
|
||||
@ApiOperation("根据表格id获取列的option信息")
|
||||
@GetMapping("/column/option/{tableId}")
|
||||
public Result<List<Option>> columnOption(@PathVariable Long tableId){
|
||||
List<Option> optionList = tableService.searchColumnOption(tableId);
|
||||
return Result.ok(optionList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取详细信息")
|
||||
@GetMapping("/{tableId}")
|
||||
@PreAuthorize("@ss.hasPermission('query:table:info')")
|
||||
public Result<TableInfo> info(@PathVariable Long tableId) {
|
||||
TableInfo tableInfo = tableService.searchById(tableId);
|
||||
return Result.ok(tableInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("导入表信息")
|
||||
@PostMapping("/import")
|
||||
@Log(title = "自定义查询导入表信息", businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('query:table:import')")
|
||||
public Result<Long> importTable(@RequestBody @Validated ImportDto dto) {
|
||||
if (dto.getTables().isEmpty() || LongUtils.isNull(dto.getDataSourceId())) {
|
||||
return Result.error("缺少必要参数!");
|
||||
}
|
||||
return tableService.importTable(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("同步数据库")
|
||||
@PutMapping("/sync/{tableId}")
|
||||
@Log(title = "同步数据库", businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('query:table:sync')")
|
||||
public Result<Void> syncTable(@PathVariable Long tableId) {
|
||||
if (ObjectUtils.isEmpty(tableId)){
|
||||
return Result.error("缺少必要参数!");
|
||||
}
|
||||
tableService.syncTable(tableId);
|
||||
return Result.ok("同步成功");
|
||||
}
|
||||
|
||||
@ApiOperation("修改自定义查询表格维护")
|
||||
@PutMapping
|
||||
@Log(title = "修改自定义查询表格维护", businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('query:table:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated TableInfo table) {
|
||||
ObjectUtils.checkPk(table.getTable().getTableId());
|
||||
if (null == table.getColumnList() || table.getColumnList().isEmpty()) {
|
||||
return Result.error("列信息不能为空!");
|
||||
}
|
||||
if (null == table.getRoleIds() || table.getRoleIds().isEmpty()) {
|
||||
return Result.error("角色信息不能为空!");
|
||||
}
|
||||
tableService.edit(table);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除自定义查询表格维护")
|
||||
@DeleteMapping("/{tableId}")
|
||||
@Log(title = "删除自定义查询表格维护", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('query:table:del')")
|
||||
public Result<Void> batchDel(@PathVariable Long tableId) {
|
||||
if (null == tableId || 0L == tableId) {
|
||||
return Result.error("缺少必要参数!");
|
||||
}
|
||||
tableService.removeById(tableId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.Encrypt;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.common.excel.utils.ExcelUtil;
|
||||
import cn.fateverse.common.log.annotation.Log;
|
||||
import cn.fateverse.common.log.enums.BusinessType;
|
||||
import cn.fateverse.query.entity.vo.UniQueryVo;
|
||||
import cn.fateverse.query.entity.dto.UniQueryDto;
|
||||
import cn.fateverse.query.entity.query.UniQueryQuery;
|
||||
import cn.fateverse.query.service.UniQueryService;
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.query.service.impl.TopoUniQueryServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 万能查询 Controller
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
@Api(value = "TOPO万能查询管理", tags = "TOPO万能查询管理")
|
||||
@RestController
|
||||
@RequestMapping({"/topo/uni"})
|
||||
public class TopoUniQueryController {
|
||||
|
||||
private final UniQueryService uniQueryService;
|
||||
|
||||
public TopoUniQueryController(TopoUniQueryServiceImpl uniQueryService) {
|
||||
this.uniQueryService = uniQueryService;
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图获取万能查询列表")
|
||||
@GetMapping
|
||||
@Encrypt
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:list')")
|
||||
public Result<TableDataInfo<UniQueryVo>> list(UniQueryQuery query) {
|
||||
TableDataInfo<UniQueryVo> dataInfo = uniQueryService.searchList(query);
|
||||
return Result.ok(dataInfo);
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图导出excel数据")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:export')")
|
||||
public void export(UniQueryQuery query) {
|
||||
List<UniQueryVo> list = uniQueryService.exportList(query);
|
||||
ExcelUtil.exportExcel(list, UniQueryVo.class);
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图数据查看接口")
|
||||
@GetMapping("/view/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:view')")
|
||||
@Encrypt
|
||||
public Result<String> preview(@PathVariable @EncryptField String id) {
|
||||
String url = uniQueryService.view(Long.valueOf(id));
|
||||
return Result.ok(url);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("拓扑图获取万能查询详细信息")
|
||||
@GetMapping("/{id}")
|
||||
@Encrypt
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:info')")
|
||||
public Result<UniQueryVo> info(@PathVariable @EncryptField String id) {
|
||||
ObjectUtils.checkPk(id);
|
||||
UniQueryVo uniQuery = uniQueryService.searchById(Long.parseLong(id));
|
||||
return Result.ok(uniQuery);
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图新增万能查询")
|
||||
@PostMapping
|
||||
@Log(title = "拓扑图新增万能查询", businessType = BusinessType.INSERT)
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:add')")
|
||||
public Result<UniQueryVo> add(@RequestBody @Validated UniQueryDto dto) {
|
||||
return uniQueryService.save(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图修改万能查询")
|
||||
@PutMapping
|
||||
@Encrypt
|
||||
@Log(title = "拓扑图修改万能查询", businessType = BusinessType.UPDATE)
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:edit')")
|
||||
public Result<Void> edit(@RequestBody @Validated UniQueryDto dto) {
|
||||
ObjectUtils.checkPk(dto.getId());
|
||||
uniQueryService.edit(dto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("拓扑图删除万能查询")
|
||||
@DeleteMapping("/{idList}")
|
||||
@Encrypt
|
||||
@Log(title = "拓扑图删除万能查询", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermission('topo:uni-query:del')")
|
||||
public Result<Void> batchDel(@PathVariable @EncryptField List<String> idList) {
|
||||
List<Long> collect = idList.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
ObjectUtils.checkPkList(idList);
|
||||
uniQueryService.removeBatch(collect);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package cn.fateverse.query.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.decrypt.annotation.Encrypt;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.vo.CustomQueryResult;
|
||||
import cn.fateverse.query.entity.vo.TopoVo;
|
||||
import cn.fateverse.query.entity.dto.SearchInfo;
|
||||
import cn.fateverse.query.entity.dto.TopoDto;
|
||||
import cn.fateverse.query.service.TopologySearchService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-21
|
||||
*/
|
||||
@Api(value = "拓扑图万能查询", tags = "拓扑图万能查询")
|
||||
@RestController
|
||||
@RequestMapping("/topo/search")
|
||||
public class TopologySearchController {
|
||||
|
||||
private final TopologySearchService topologySearchService;
|
||||
|
||||
public TopologySearchController(TopologySearchService topologySearchService) {
|
||||
this.topologySearchService = topologySearchService;
|
||||
}
|
||||
|
||||
@ApiOperation("获取到表格的拖拽数据信息")
|
||||
@GetMapping("/{queryId}")
|
||||
@Encrypt
|
||||
public Result<TopoVo> topology(@PathVariable @EncryptField String queryId) {
|
||||
TopoVo topoVo = topologySearchService.search(Long.parseLong(queryId));
|
||||
return Result.ok(topoVo);
|
||||
}
|
||||
|
||||
@ApiOperation("保存topo参数")
|
||||
@PostMapping
|
||||
@Encrypt
|
||||
public Result<Void> save(@RequestBody @Validated TopoDto topo) {
|
||||
topologySearchService.saveData(topo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("预览")
|
||||
@Encrypt
|
||||
@PostMapping("/preview")
|
||||
public Result<CustomQueryResult> preview(@RequestBody @Validated TopoDto topo) {
|
||||
return topologySearchService.preview(topo);
|
||||
}
|
||||
|
||||
@ApiOperation("撤销")
|
||||
@Encrypt
|
||||
@PutMapping("/cancel/{queryId}")
|
||||
public Result<Void> cancel(@PathVariable @EncryptField String queryId){
|
||||
topologySearchService.cancel(Long.valueOf(queryId));
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("发布")
|
||||
@Encrypt
|
||||
@PostMapping("/publish")
|
||||
public Result<Void> publish(@RequestBody @Validated TopoDto topo) {
|
||||
if (ObjectUtils.isEmpty(topo.getMenuId())) {
|
||||
return Result.error("上级菜单不能为空!");
|
||||
}
|
||||
topologySearchService.publish(topo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("预览弹窗数据获取")
|
||||
@Encrypt
|
||||
@PostMapping("/preview/data")
|
||||
public Result<TableDataInfo<Map<String, Object>>> previewData(@RequestBody @Validated SearchInfo searchInfo) {
|
||||
TableDataInfo<Map<String, Object>> tableDataInfo = topologySearchService.previewData(searchInfo.getList(), searchInfo.getQueryId());
|
||||
return Result.ok(tableDataInfo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源适配器对象 data_adapter
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataAdapter extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 数据适配器id
|
||||
*/
|
||||
private Long adapterId;
|
||||
|
||||
/**
|
||||
* 数据源id,数据源可以是 topo自定义查询,sql自定义查询,api请求
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 适配器名称
|
||||
*/
|
||||
private String adapterName;
|
||||
|
||||
/**
|
||||
* 数据适配器代码类型 Java or Js
|
||||
*/
|
||||
private DataAdapterType type;
|
||||
|
||||
/**
|
||||
* 适配器代码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 可以执行的代码块
|
||||
*/
|
||||
private String executeCode;
|
||||
|
||||
/**
|
||||
* 适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echart编辑器
|
||||
*/
|
||||
private DataAdapterSource source;
|
||||
|
||||
/**
|
||||
* 模拟数据 strng类型的json字符串
|
||||
*/
|
||||
private String mockData;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源管理对象 query_data_source
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataSourceManage extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 数据源服务地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 数据源端口
|
||||
*/
|
||||
private Long port;
|
||||
|
||||
/**
|
||||
* 配置参数
|
||||
*/
|
||||
private String args;
|
||||
|
||||
/**
|
||||
* 服务名
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 数据源类型,匹配java枚举
|
||||
*/
|
||||
private DynamicSourceEnum type;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String dbName;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
private Integer configType;
|
||||
|
||||
/**
|
||||
* 数据源连接类型
|
||||
*/
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2024/2/21 11:38
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceManageCount {
|
||||
|
||||
private Long dataSourceId;
|
||||
|
||||
private Long count;
|
||||
|
||||
private String dataSourceName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 动态echarts图表对象 dynamic_echarts
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DynamicEcharts extends BaseEntity{
|
||||
|
||||
/**
|
||||
* echarts主键
|
||||
*/
|
||||
private Long echartsId;
|
||||
|
||||
/**
|
||||
* 数据适配器id,可以选择或者直接创建
|
||||
*/
|
||||
private Long adapterId;
|
||||
|
||||
/**
|
||||
* echarts名称
|
||||
*/
|
||||
private String echartsName;
|
||||
|
||||
/**
|
||||
* echarts配置数据
|
||||
*/
|
||||
private String echartsConfig;
|
||||
|
||||
/**
|
||||
* 是否发布
|
||||
*/
|
||||
private Boolean publish;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class DynamicPage {
|
||||
/**
|
||||
* 开始行数
|
||||
*/
|
||||
private Integer startNum;
|
||||
/**
|
||||
* 结束行数
|
||||
*/
|
||||
private Integer endNum;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
public class DynamicTable {
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@ApiModelProperty("表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表注释
|
||||
*/
|
||||
@ApiModelProperty("表注释")
|
||||
private String tableComment;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Table extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 表id
|
||||
*/
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
private DynamicSourceEnum dataSourceType;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表注释
|
||||
*/
|
||||
private String tableComment;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableColumn extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 表格id
|
||||
*/
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列注释
|
||||
*/
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 是否组件
|
||||
*/
|
||||
private Boolean pk;
|
||||
|
||||
/**
|
||||
* 使用装填
|
||||
*/
|
||||
private Boolean use;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.query.entity.dto.TableColumnDto;
|
||||
import cn.fateverse.query.entity.dto.TableDto;
|
||||
import cn.fateverse.query.entity.dto.TableRelationalMappingDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableInfo {
|
||||
|
||||
private TableDto table;
|
||||
|
||||
private List<Long> roleIds;
|
||||
|
||||
private List<TableColumnDto> columnList;
|
||||
|
||||
private List<TableRelationalMappingDto> relationMappings;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableRelationalMapping {
|
||||
|
||||
/** 主表id */
|
||||
private Long mainId;
|
||||
|
||||
/** 字表id */
|
||||
private Long childId;
|
||||
|
||||
/** 主表字段 */
|
||||
private String mainKey;
|
||||
|
||||
/** 字表字段 */
|
||||
private String childKey;
|
||||
|
||||
/** 关系 1:hasOne 2:hasMany 3: belongsTo */
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableRole {
|
||||
|
||||
private Long tableId;
|
||||
|
||||
private Long roleId;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UniColumn {
|
||||
private Long id;
|
||||
//列id
|
||||
private Long queryId;
|
||||
//列信息
|
||||
private String prop;
|
||||
//标签
|
||||
private String label;
|
||||
//显示类型
|
||||
private String displayType;
|
||||
//显示参数
|
||||
private String displayParam;
|
||||
//排序
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.query.entity.vo.UniConVo;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UniCon {
|
||||
|
||||
private Long ucId;
|
||||
/**
|
||||
* 查询id
|
||||
*/
|
||||
@JsonIgnore
|
||||
private Long uqId;
|
||||
/**
|
||||
* 条件名称
|
||||
*/
|
||||
private String ucName;
|
||||
/**
|
||||
* 查询关键词
|
||||
*/
|
||||
private String ucKey;
|
||||
/**
|
||||
* 查询条件
|
||||
*/
|
||||
private String ucCon;
|
||||
/**
|
||||
* 模拟数据
|
||||
*/
|
||||
private Object ucMock;
|
||||
/**
|
||||
* 查询描述
|
||||
*/
|
||||
private String ucDescribe;
|
||||
/**
|
||||
* 输入类型
|
||||
*/
|
||||
private String ucType;
|
||||
/**
|
||||
* 显示类型.字典 or 正常数据
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
|
||||
public UniConVo toUcConVo() {
|
||||
return UniConVo.builder()
|
||||
.ucId(ucId)
|
||||
.ucName(ucName)
|
||||
.ucDescribe(ucDescribe)
|
||||
.ucType(ucType)
|
||||
.type(type)
|
||||
.sort(sort)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.fateverse.query.entity;
|
||||
|
||||
import cn.fateverse.common.core.annotaion.EnableAutoField;
|
||||
import cn.fateverse.common.core.entity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 万能查询对象 query_uni_query
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@EnableAutoField
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UniQuery extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 自定义查询id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String uqName;
|
||||
|
||||
/**
|
||||
* sql语句
|
||||
*/
|
||||
private String uqSql;
|
||||
|
||||
/**
|
||||
* 查询关键词
|
||||
*/
|
||||
private String selectKey;
|
||||
|
||||
/**
|
||||
* 表格信息
|
||||
*/
|
||||
private String tableInfo;
|
||||
|
||||
/**
|
||||
* 表格关系
|
||||
*/
|
||||
private String relevance;
|
||||
|
||||
/**
|
||||
* 是否为单表
|
||||
*/
|
||||
private Boolean single;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String uqDescribe;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*/
|
||||
private Boolean publish;
|
||||
|
||||
/**
|
||||
* 预览:1,已预览 ,2 未预览
|
||||
*/
|
||||
private Boolean preview;
|
||||
|
||||
/**
|
||||
* top图json数据
|
||||
*/
|
||||
private String topJson;
|
||||
|
||||
/**
|
||||
* 类型 1:普通 2:top图
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
//@AutoUser(method = MethodEnum.INSERT,value = AutoUserEnum.USER_ID)
|
||||
//private Long userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.fateverse.query.entity.bo;
|
||||
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-10
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SqlSelect {
|
||||
//查询sql
|
||||
private String selectSql;
|
||||
//查询条件
|
||||
private List<UniCon> uniCons;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.fateverse.query.entity.bo;
|
||||
|
||||
import cn.fateverse.query.entity.Table;
|
||||
import cn.fateverse.query.entity.TableColumn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableBo {
|
||||
|
||||
private Table table;
|
||||
|
||||
private List<TableColumn> columns;
|
||||
|
||||
private TableColumn pk;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.fateverse.query.entity.bo;
|
||||
|
||||
import cn.fateverse.query.entity.UniColumn;
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TopologySelect {
|
||||
//查询关键词
|
||||
private String selectKey;
|
||||
//表格信息
|
||||
private String tableInfo;
|
||||
//表格之间的关系
|
||||
private List<String> relevance;
|
||||
//表格列信息
|
||||
private List<UniColumn> uniColumns;
|
||||
//查询信息
|
||||
private List<UniCon> uniCons;
|
||||
//是否为单表
|
||||
private Boolean single;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据源适配器对象 data_adapter
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("数据源适配器Dto")
|
||||
public class DataAdapterDto {
|
||||
|
||||
/**
|
||||
* 数据适配器id
|
||||
*/
|
||||
@ApiModelProperty("数据适配器id")
|
||||
private Long adapterId;
|
||||
|
||||
/**
|
||||
* 适配器名称
|
||||
*/
|
||||
@ApiModelProperty("适配器名称")
|
||||
private String adapterName;
|
||||
|
||||
/**
|
||||
* 数据适配器代码类型 Java or Js
|
||||
*/
|
||||
@ApiModelProperty("数据适配器代码类型 Java or Js")
|
||||
private DataAdapterType type;
|
||||
|
||||
/**
|
||||
* 适配器代码
|
||||
*/
|
||||
@ApiModelProperty("适配器代码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echart编辑器
|
||||
*/
|
||||
@ApiModelProperty("适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echart编辑器")
|
||||
private DataAdapterSource source;
|
||||
|
||||
/**
|
||||
* 模拟数据 strng类型的json字符串
|
||||
*/
|
||||
@ApiModelProperty("模拟数据 strng类型的json字符串")
|
||||
private String mockData;
|
||||
|
||||
public DataAdapter toDataAdapter() {
|
||||
return DataAdapter.builder()
|
||||
.adapterId(adapterId)
|
||||
.adapterName(adapterName)
|
||||
.type(type)
|
||||
.code(code)
|
||||
.source(source)
|
||||
.mockData(mockData)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 数据源管理对象 query_data_source
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("数据源管理Dto")
|
||||
public class DataSourceManageDto {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@ApiModelProperty("数据源名称")
|
||||
@NotBlank(message = "数据源名称不能为空!")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
@ApiModelProperty("数据源用户名")
|
||||
@NotBlank(message = "数据源用户名不能为空!")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
@ApiModelProperty("数据源密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 数据源服务地址
|
||||
*/
|
||||
@ApiModelProperty("数据源服务地址")
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 数据源端口
|
||||
*/
|
||||
@ApiModelProperty("数据源端口")
|
||||
private Long port;
|
||||
|
||||
private String args;
|
||||
|
||||
@ApiModelProperty("服务名称")
|
||||
private JSONObject params;
|
||||
|
||||
/**
|
||||
* 数据源类型,匹配java枚举
|
||||
*/
|
||||
@ApiModelProperty("数据源类型,匹配java枚举")
|
||||
@NotNull(message = "数据源类型不能为空!")
|
||||
private DynamicSourceEnum type;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@ApiModelProperty("数据库名称")
|
||||
private String dbName;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
@ApiModelProperty("数据源类型")
|
||||
@NotNull(message = "配置类型不能为空!")
|
||||
private Integer configType;
|
||||
|
||||
/**
|
||||
* 数据源连接类型
|
||||
*/
|
||||
@ApiModelProperty("数据源连接类型")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
public DataSourceManage toQueryDataSource() {
|
||||
DataSourceManage build = DataSourceManage.builder()
|
||||
.id(id)
|
||||
.dsName(dsName)
|
||||
.username(username)
|
||||
.password(password)
|
||||
.args(args)
|
||||
.params(JSON.toJSONString(params))
|
||||
.host(host)
|
||||
.port(port)
|
||||
.type(type)
|
||||
.dbName(dbName)
|
||||
.configType(configType)
|
||||
.url(url)
|
||||
.build();
|
||||
build.setRemark(remark);
|
||||
return build;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.query.entity.DynamicEcharts;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 动态echarts图表对象 dynamic_echarts
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("动态echarts图表Dto")
|
||||
public class DynamicEchartsDto {
|
||||
|
||||
/**
|
||||
* echarts主键
|
||||
*/
|
||||
@ApiModelProperty("echarts主键")
|
||||
private Long echartsId;
|
||||
|
||||
/**
|
||||
* 数据适配器id,可以选择或者直接创建
|
||||
*/
|
||||
@ApiModelProperty("数据适配器id,可以选择或者直接创建")
|
||||
private Long adapterId;
|
||||
|
||||
/**
|
||||
* echarts名称
|
||||
*/
|
||||
@ApiModelProperty("echarts名称")
|
||||
private String echartsName;
|
||||
|
||||
/**
|
||||
* echarts配置数据
|
||||
*/
|
||||
@ApiModelProperty("echarts配置数据")
|
||||
private String echartsConfig;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
public DynamicEcharts toDynamicEcharts() {
|
||||
DynamicEcharts echarts = DynamicEcharts.builder()
|
||||
.echartsId(echartsId)
|
||||
.adapterId(adapterId)
|
||||
.echartsName(echartsName)
|
||||
.echartsConfig(echartsConfig)
|
||||
.build();
|
||||
echarts.setRemark(remark);
|
||||
return echarts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
public class ImportDto {
|
||||
|
||||
@NotNull(message = "表格不能为空")
|
||||
private List<String> tables;
|
||||
|
||||
@NotNull(message = "数据源id不能为空")
|
||||
private Long dataSourceId;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class SearchInfo {
|
||||
|
||||
@NotNull(message = "查询条件不为空")
|
||||
private List<UniConDto> list;
|
||||
|
||||
@NotNull(message = "查询id不能为空")
|
||||
@EncryptField
|
||||
private String queryId;
|
||||
|
||||
public Long getQueryId() {
|
||||
return Long.parseLong(queryId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.UniColumn;
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-08-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SqlDto {
|
||||
|
||||
//查询id
|
||||
@EncryptField
|
||||
@NotBlank(message = "查询id不为空")
|
||||
private String queryId;
|
||||
|
||||
//查询语句
|
||||
@NotBlank(message = "sql语句不为空")
|
||||
private String uniSql;
|
||||
|
||||
private Long menuId;
|
||||
|
||||
//查询条件
|
||||
private List<UniCon> uniCons;
|
||||
|
||||
//查询列信息
|
||||
private List<UniColumn> uniColumns;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
public Long getLongQueryId() {
|
||||
return ObjectUtils.isEmpty(queryId) ? null : Long.valueOf(queryId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-21
|
||||
*/
|
||||
@Data
|
||||
public class TableColumnDto {
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 表格id
|
||||
*/
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列注释
|
||||
*/
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 是否组件
|
||||
*/
|
||||
private Boolean pk;
|
||||
|
||||
/**
|
||||
* 使用装填
|
||||
*/
|
||||
private Boolean use;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.query.entity.Table;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 自定义查询表格维护对象 table
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("自定义查询表格维护Dto")
|
||||
public class TableDto {
|
||||
|
||||
/**
|
||||
* 表id
|
||||
*/
|
||||
@ApiModelProperty("表id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@ApiModelProperty("数据源id")
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@ApiModelProperty("数据源类型")
|
||||
private DynamicSourceEnum dataSourceType;
|
||||
|
||||
/**
|
||||
* 表格名称
|
||||
*/
|
||||
@ApiModelProperty("表格名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表格注释
|
||||
*/
|
||||
@ApiModelProperty("表格注释")
|
||||
private String tableComment;
|
||||
|
||||
public Table toTable() {
|
||||
return Table.builder()
|
||||
.tableId(tableId)
|
||||
.dataSourceId(dataSourceId)
|
||||
.dataSourceType(dataSourceType)
|
||||
.tableName(tableName)
|
||||
.tableComment(tableComment)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.query.entity.TableRelationalMapping;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableRelationalMappingDto {
|
||||
/** 主表id */
|
||||
private Long mainId;
|
||||
|
||||
/** 字表id */
|
||||
private Long childId;
|
||||
|
||||
/** 主表字段 */
|
||||
private String mainKey;
|
||||
|
||||
/** 字表字段 */
|
||||
private String childKey;
|
||||
|
||||
/** 关系 1:hasOne 2:hasMany 3: belongsTo */
|
||||
private List<String> type;
|
||||
|
||||
|
||||
public static TableRelationalMappingDto toTableRelationalMappingDto(TableRelationalMapping source){
|
||||
return TableRelationalMappingDto.builder()
|
||||
.mainId(source.getMainId())
|
||||
.childId(source.getChildId())
|
||||
.mainKey(source.getMainKey())
|
||||
.childKey(source.getChildKey())
|
||||
.type(JSON.parseArray(source.getType(),String.class))
|
||||
.build();
|
||||
}
|
||||
|
||||
public TableRelationalMapping toTableRelationalMapping(){
|
||||
return TableRelationalMapping.builder()
|
||||
.mainId(mainId)
|
||||
.childId(childId)
|
||||
.mainKey(mainKey)
|
||||
.childKey(childKey)
|
||||
.type(JSON.toJSONString(type))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class TopoDto {
|
||||
|
||||
@NotNull(message = "查询id不能为空")
|
||||
@EncryptField
|
||||
private String queryId;
|
||||
|
||||
private Long menuId;
|
||||
|
||||
@NotBlank(message = "json数据不能为空")
|
||||
private String topJson;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
public Long getLongQueryId() {
|
||||
return Long.parseLong(queryId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class UniConDto {
|
||||
private Long ucId;
|
||||
private Object query;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package cn.fateverse.query.entity.dto;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.UniQuery;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 万能查询对象 query_uni_query
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("万能查询Dto")
|
||||
public class UniQueryDto {
|
||||
|
||||
/**
|
||||
* 自定义查询id
|
||||
*/
|
||||
@ApiModelProperty("自定义查询id")
|
||||
@EncryptField
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("数据源id")
|
||||
@NotNull(message = "重要参数不能为空")
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String uqName;
|
||||
|
||||
/**
|
||||
* sql语句
|
||||
*/
|
||||
@ApiModelProperty("sql语句")
|
||||
private String uqSql;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty("描述")
|
||||
@NotBlank(message = "描述不能为空")
|
||||
private String uqDescribe;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*/
|
||||
@ApiModelProperty("发布")
|
||||
private Boolean publish;
|
||||
|
||||
/**
|
||||
* 预览:1,已预览 ,2 未预览
|
||||
*/
|
||||
@ApiModelProperty("预览:1,已预览 ,2 未预览")
|
||||
private Boolean preview;
|
||||
|
||||
/**
|
||||
* top图json数据
|
||||
*/
|
||||
@ApiModelProperty("top图json数据")
|
||||
private String topJson;
|
||||
|
||||
/**
|
||||
* 类型 1:普通 2:top图
|
||||
*/
|
||||
@ApiModelProperty("类型 1:普通 2:top图")
|
||||
private Integer type;
|
||||
|
||||
public Long getId() {
|
||||
if (null == id) {
|
||||
return -1L;
|
||||
} else {
|
||||
return Long.parseLong(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static UniQuery toUniQuery(UniQueryDto uniQuery) {
|
||||
return UniQuery.builder()
|
||||
.id(uniQuery.getId())
|
||||
.uqName(uniQuery.getUqName())
|
||||
.uqSql(uniQuery.getUqSql())
|
||||
.uqDescribe(uniQuery.getUqDescribe())
|
||||
.publish(uniQuery.getPublish())
|
||||
.preview(uniQuery.getPreview())
|
||||
.topJson(uniQuery.getTopJson())
|
||||
.type(uniQuery.getType())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据源适配器对象 data_adapter
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("数据源适配器Query")
|
||||
public class DataAdapterQuery {
|
||||
|
||||
/**
|
||||
* 适配器名称
|
||||
*/
|
||||
@ApiModelProperty("适配器名称")
|
||||
private String adapterName;
|
||||
|
||||
/**
|
||||
* 数据适配器代码类型 Java or Js
|
||||
*/
|
||||
@ApiModelProperty("数据适配器代码类型 Java or Js")
|
||||
private DataAdapterType type;
|
||||
|
||||
/**
|
||||
* 适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echarts编辑器
|
||||
*/
|
||||
@ApiModelProperty("适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echarts编辑器")
|
||||
private DataAdapterSource source;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据源管理对象 query_data_source
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("数据源管理Query")
|
||||
public class DataSourceManageQuery {
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@ApiModelProperty("数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@ApiModelProperty("数据库名称")
|
||||
private String dbName;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@ApiModelProperty("数据源类型")
|
||||
private Integer configType;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 动态echarts图表对象 dynamic_echarts
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("动态echarts图表Query")
|
||||
public class DynamicEchartsQuery {
|
||||
|
||||
/**
|
||||
* echart名称
|
||||
*/
|
||||
@ApiModelProperty("echarts名称")
|
||||
private String echartsName;
|
||||
|
||||
/**
|
||||
* 是否发布
|
||||
*/
|
||||
@ApiModelProperty("是否发布")
|
||||
private Boolean publish;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import cn.fateverse.common.core.entity.QueryTime;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
public class DynamicTableQuery extends QueryTime {
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@ApiModelProperty("表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表注释
|
||||
*/
|
||||
@ApiModelProperty("表注释")
|
||||
private String tableComment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import cn.fateverse.common.core.entity.QueryTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("自定义查询,表格查询")
|
||||
public class TableQuery extends QueryTime {
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@ApiModelProperty("数据源id")
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
@ApiModelProperty("表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表描述
|
||||
*/
|
||||
@ApiModelProperty("表描述")
|
||||
private String tableComment;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
private String dataSourceType;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.fateverse.query.entity.query;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 万能查询对象 query_uni_query
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("万能查询Query")
|
||||
public class UniQueryQuery {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty("名称")
|
||||
private String uqName;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*/
|
||||
@ApiModelProperty("发布")
|
||||
private Integer publish;
|
||||
|
||||
/**
|
||||
* 预览:1,已预览 ,2 未预览
|
||||
*/
|
||||
@ApiModelProperty("预览:1,已预览 ,2 未预览")
|
||||
private Boolean preview;
|
||||
|
||||
/**
|
||||
* 类型 1:普通 2:top图
|
||||
*/
|
||||
@ApiModelProperty("类型 1:普通 2:top图")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("数据源id")
|
||||
private Long dataSourceId;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.fateverse.query.entity.topology;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class Edge {
|
||||
/**
|
||||
* 源
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 目标
|
||||
*/
|
||||
private String target;
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
private EdgeConfig appConfig;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.fateverse.query.entity.topology;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class EdgeConfig {
|
||||
/**
|
||||
* 关系
|
||||
*/
|
||||
private String associated;
|
||||
/**
|
||||
* 源列
|
||||
*/
|
||||
private String sourceColumn;
|
||||
/**
|
||||
* 目标列
|
||||
*/
|
||||
private String targetColumn;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.fateverse.query.entity.topology;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class Node {
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 表格
|
||||
*/
|
||||
private String table;
|
||||
/**
|
||||
* 别名
|
||||
*/
|
||||
private String alias;
|
||||
/**
|
||||
* 列信息
|
||||
*/
|
||||
private List<NodeColumn> columns;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.fateverse.query.entity.topology;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
public class NodeColumn {
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
private String columnName;
|
||||
/**
|
||||
* 列备注
|
||||
*/
|
||||
private String columnComment;
|
||||
/**
|
||||
* 是否使用
|
||||
*/
|
||||
private Boolean use;
|
||||
/**
|
||||
* 是否查询
|
||||
*/
|
||||
private Boolean query;
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String ucDescribe;
|
||||
/**
|
||||
* 查询条件
|
||||
*/
|
||||
private String ucCon;
|
||||
/**
|
||||
* 显示类型
|
||||
*/
|
||||
private String displayType;
|
||||
/**
|
||||
* 显示参数
|
||||
*/
|
||||
private String displayParam;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 输入类型
|
||||
*/
|
||||
private String ucType;
|
||||
/**
|
||||
* 显示类型.input,dict,date
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 模拟数据
|
||||
*/
|
||||
private Object ucMock;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.fateverse.query.entity.topology;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TopologyBo {
|
||||
/**
|
||||
* 节点
|
||||
*/
|
||||
private List<Node> nodes;
|
||||
/**
|
||||
* 连线
|
||||
*/
|
||||
private List<Edge> edges;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.query.entity.UniColumn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomQueryResult {
|
||||
/**
|
||||
* 表格数据
|
||||
*/
|
||||
private TableDataInfo<Map<String, Object>> table;
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
private List<UniColumn> uniColumns;
|
||||
/**
|
||||
* 条件信息
|
||||
*/
|
||||
private List<UniConVo> uniCons;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.common.core.annotaion.Excel;
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数据源适配器对象 data_adapter
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("数据源适配器Vo")
|
||||
public class DataAdapterVo {
|
||||
|
||||
/**
|
||||
* 数据适配器id
|
||||
*/
|
||||
@ApiModelProperty("数据适配器id")
|
||||
private Long adapterId;
|
||||
|
||||
/**
|
||||
* 适配器名称
|
||||
*/
|
||||
@ApiModelProperty("适配器名称")
|
||||
@Excel("适配器名称")
|
||||
private String adapterName;
|
||||
|
||||
/**
|
||||
* 数据适配器代码类型 Java or Js
|
||||
*/
|
||||
@ApiModelProperty("数据适配器代码类型 Java or Js")
|
||||
@Excel("数据适配器代码类型 Java or Js")
|
||||
private DataAdapterType type;
|
||||
|
||||
/**
|
||||
* 适配器代码
|
||||
*/
|
||||
@ApiModelProperty("适配器代码")
|
||||
@Excel("适配器代码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echarts编辑器
|
||||
*/
|
||||
@ApiModelProperty("适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echarts编辑器")
|
||||
@Excel("适配器来源,数据源 自定义创建 自定义查询 sql 自定义查询 echarts编辑器")
|
||||
private DataAdapterSource source;
|
||||
|
||||
/**
|
||||
* 模拟数据 strng类型的json字符串
|
||||
*/
|
||||
@ApiModelProperty("模拟数据 strng类型的json字符串")
|
||||
@Excel("模拟数据 strng类型的json字符串")
|
||||
private String mockData;
|
||||
|
||||
public static DataAdapterVo toDataAdapterVo(DataAdapter dataAdapter) {
|
||||
return DataAdapterVo.builder()
|
||||
.adapterId(dataAdapter.getAdapterId())
|
||||
.adapterName(dataAdapter.getAdapterName())
|
||||
.type(dataAdapter.getType())
|
||||
.code(dataAdapter.getCode())
|
||||
.source(dataAdapter.getSource())
|
||||
.mockData(dataAdapter.getMockData())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import cn.fateverse.common.core.annotaion.Excel;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据源管理对象 query_data_source
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("数据源管理Vo")
|
||||
public class DataSourceManageVo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@ApiModelProperty("数据源名称")
|
||||
@Excel("数据源名称")
|
||||
private String dsName;
|
||||
|
||||
/**
|
||||
* 数据源密码
|
||||
*/
|
||||
@ApiModelProperty("数据源用户名称")
|
||||
@Excel("数据源用户名称")
|
||||
private String username;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String args;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private JSONObject params;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String host;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Long port;
|
||||
|
||||
/**
|
||||
* 数据源类型,匹配java枚举
|
||||
*/
|
||||
@ApiModelProperty("数据源类型,匹配java枚举")
|
||||
@Excel("数据源类型,匹配java枚举")
|
||||
private DynamicSourceEnum type;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@ApiModelProperty("数据库名称")
|
||||
@Excel("数据库名称")
|
||||
private String dbName;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@ApiModelProperty("数据源类型")
|
||||
@Excel("数据源类型")
|
||||
private Integer configType;
|
||||
|
||||
/**
|
||||
* 数据源连接类型
|
||||
*/
|
||||
@ApiModelProperty("数据源连接类型")
|
||||
@Excel("数据源连接类型")
|
||||
private String url;
|
||||
|
||||
public static DataSourceManageVo toQueryDataSourceVo(DataSourceManage dataSourceManage) {
|
||||
return DataSourceManageVo.builder()
|
||||
.id(dataSourceManage.getId())
|
||||
.dsName(dataSourceManage.getDsName())
|
||||
.username(dataSourceManage.getUsername())
|
||||
.type(dataSourceManage.getType())
|
||||
.dbName(dataSourceManage.getDbName())
|
||||
.configType(dataSourceManage.getConfigType())
|
||||
.url(dataSourceManage.getUrl())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.query.entity.DynamicEcharts;
|
||||
import cn.fateverse.common.core.annotaion.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 动态echarts图表对象 dynamic_echarts
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("动态echarts图表Vo")
|
||||
public class DynamicEchartsVo {
|
||||
|
||||
/**
|
||||
* echarts主键
|
||||
*/
|
||||
@ApiModelProperty("echarts主键")
|
||||
private Long echartsId;
|
||||
|
||||
/**
|
||||
* 数据适配器id,可以选择或者直接创建
|
||||
*/
|
||||
@ApiModelProperty("数据适配器id,可以选择或者直接创建")
|
||||
private String adapterName;
|
||||
|
||||
/**
|
||||
* echart名称
|
||||
*/
|
||||
@ApiModelProperty("echarts名称")
|
||||
@Excel("echarts名称")
|
||||
private String echartsName;
|
||||
|
||||
/**
|
||||
* echart配置数据
|
||||
*/
|
||||
@ApiModelProperty("echarts配置数据")
|
||||
@Excel("echartss配置数据")
|
||||
private String echartsConfig;
|
||||
|
||||
/**
|
||||
* 是否发布
|
||||
*/
|
||||
@ApiModelProperty("是否发布")
|
||||
@Excel("是否发布")
|
||||
private Boolean publish;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty("备注")
|
||||
@Excel("备注")
|
||||
private String remark;
|
||||
|
||||
public static DynamicEchartsVo toDynamicEchartsVo(DynamicEcharts dynamicEcharts) {
|
||||
return DynamicEchartsVo.builder()
|
||||
.echartsId(dynamicEcharts.getEchartsId())
|
||||
.echartsName(dynamicEcharts.getEchartsName())
|
||||
.echartsConfig(dynamicEcharts.getEchartsConfig())
|
||||
.publish(dynamicEcharts.getPublish())
|
||||
.remark(dynamicEcharts.getRemark())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.UniColumn;
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-11-30 21:59
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SqlInfoVo {
|
||||
//查询id
|
||||
@EncryptField
|
||||
@NotBlank(message = "查询id不为空")
|
||||
private String queryId;
|
||||
|
||||
//查询语句
|
||||
@NotBlank(message = "sql语句不为空")
|
||||
private String uniSql;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty("名称")
|
||||
private String uqName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty("描述")
|
||||
private String uqDescribe;
|
||||
|
||||
private Long menuId;
|
||||
|
||||
//查询条件
|
||||
private List<UniCon> uniCons;
|
||||
|
||||
//查询列信息
|
||||
private List<UniColumn> uniColumns;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.query.entity.TableColumn;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class TableColumnVo {
|
||||
|
||||
private Long tableId;
|
||||
|
||||
private Long columnId;
|
||||
|
||||
private String columnName;
|
||||
|
||||
private String columnComment;
|
||||
|
||||
private String columnType;
|
||||
|
||||
private Boolean pk;
|
||||
|
||||
private Boolean use;
|
||||
|
||||
|
||||
public static TableColumnVo toTableColumnVo(TableColumn column){
|
||||
return TableColumnVo.builder()
|
||||
.tableId(column.getTableId())
|
||||
.columnId(column.getColumnId())
|
||||
.columnName(column.getColumnName())
|
||||
.columnComment(column.getColumnComment())
|
||||
.columnType(column.getColumnType())
|
||||
.pk(column.getPk())
|
||||
.use(column.getUse())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class TableTopoVo {
|
||||
|
||||
private Long tableId;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String tableComment;
|
||||
|
||||
private List<TableColumnVo> columns;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.query.entity.Table;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 自定义查询表格维护对象 table
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("自定义查询表格维护Vo")
|
||||
public class TableVo {
|
||||
|
||||
/**
|
||||
* 表id
|
||||
*/
|
||||
@ApiModelProperty("表id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@ApiModelProperty("数据源id")
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@ApiModelProperty("数据源类型")
|
||||
private DynamicSourceEnum dataSourceType;
|
||||
|
||||
/**
|
||||
* 表格名称
|
||||
*/
|
||||
@ApiModelProperty("表格名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表格注释
|
||||
*/
|
||||
@ApiModelProperty("表格注释")
|
||||
private String tableComment;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
public static TableVo toTableVo(Table table) {
|
||||
return TableVo.builder()
|
||||
.tableId(table.getTableId())
|
||||
.dataSourceId(table.getDataSourceId())
|
||||
.dataSourceType(table.getDataSourceType())
|
||||
.tableName(table.getTableName())
|
||||
.tableComment(table.getTableComment())
|
||||
.createTime(table.getCreateTime())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.query.entity.dto.TableRelationalMappingDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TopoVo {
|
||||
|
||||
private List<TableTopoVo> tableList;
|
||||
|
||||
private List<TableRelationalMappingDto> relational;
|
||||
|
||||
private String topJson;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UniConVo {
|
||||
//查询id
|
||||
private Long ucId;
|
||||
//查询名称
|
||||
private String ucName;
|
||||
//查询描述
|
||||
private String ucDescribe;
|
||||
//输入类型
|
||||
private String ucType;
|
||||
//显示类型
|
||||
private String type;
|
||||
//排序
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package cn.fateverse.query.entity.vo;
|
||||
|
||||
import cn.fateverse.common.decrypt.annotation.EncryptField;
|
||||
import cn.fateverse.query.entity.UniQuery;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 万能查询对象 query_uni_query
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("万能查询Vo")
|
||||
public class UniQueryVo {
|
||||
|
||||
/**
|
||||
* 自定义查询id
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
@EncryptField
|
||||
private String id;
|
||||
|
||||
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty("名称")
|
||||
private String uqName;
|
||||
|
||||
/**
|
||||
* sql语句
|
||||
*/
|
||||
@ApiModelProperty("sql语句")
|
||||
private String uqSql;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ApiModelProperty("描述")
|
||||
private String uqDescribe;
|
||||
|
||||
/**
|
||||
* 发布
|
||||
*/
|
||||
@ApiModelProperty("发布")
|
||||
private Boolean publish;
|
||||
|
||||
/**
|
||||
* 预览:1,已预览 ,2 未预览
|
||||
*/
|
||||
@ApiModelProperty("预览:1,已预览 ,2 未预览")
|
||||
private Boolean preview;
|
||||
|
||||
/**
|
||||
* top图json数据
|
||||
*/
|
||||
@ApiModelProperty("top图json数据")
|
||||
private String topJson;
|
||||
|
||||
/**
|
||||
* 类型 1:普通 2:top图
|
||||
*/
|
||||
@ApiModelProperty("类型 1:普通 2:top图")
|
||||
private Integer type;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
|
||||
public static UniQueryVo toUniQueryVo(UniQuery uniQuery) {
|
||||
return UniQueryVo.builder()
|
||||
.id(uniQuery.getId().toString())
|
||||
.dataSourceId(uniQuery.getDataSourceId())
|
||||
.uqName(uniQuery.getUqName())
|
||||
.uqSql(uniQuery.getUqSql())
|
||||
.uqDescribe(uniQuery.getUqDescribe())
|
||||
.publish(uniQuery.getPublish())
|
||||
.preview(uniQuery.getPreview())
|
||||
.topJson(uniQuery.getTopJson())
|
||||
.type(uniQuery.getType())
|
||||
.createTime(uniQuery.getCreateTime())
|
||||
.updateTime(uniQuery.getUpdateTime())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.fateverse.query.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 适配器来源
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2023-10-29 18:33
|
||||
*/
|
||||
public enum DataAdapterSource {
|
||||
TOPO_QUERY("拓扑自定义查询"),
|
||||
SQL_QUERY("SQL自定义查询"),
|
||||
ECHARTS_EDITOR("echarts编辑器"),
|
||||
SYSTEM("系统默认"),
|
||||
CUSTOM("自定义"),
|
||||
;
|
||||
|
||||
private final String source;
|
||||
|
||||
|
||||
|
||||
DataAdapterSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.fateverse.query.enums;
|
||||
|
||||
|
||||
public enum DataAdapterType {
|
||||
JAVA("java"),
|
||||
JAVA_SCRIPT("JavaScript");
|
||||
|
||||
|
||||
private final String type;
|
||||
|
||||
|
||||
DataAdapterType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cn.fateverse.query.enums;
|
||||
|
||||
import cn.fateverse.query.factory.DynamicDataSourceFactory;
|
||||
import cn.fateverse.query.factory.impl.MariaDynamicDataSourceFactory;
|
||||
import cn.fateverse.query.factory.impl.MySqlDynamicDataSourceFactory;
|
||||
import cn.fateverse.query.factory.impl.OracleDynamicDataSourceFactory;
|
||||
import cn.fateverse.query.factory.impl.PostgresDynamicDataSourceFactory;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public enum DynamicSourceEnum {
|
||||
|
||||
|
||||
/**
|
||||
* 数据库状态
|
||||
*/
|
||||
MYSQL("mysql", "com.mysql.cj.jdbc.Driver", MySqlDynamicDataSourceFactory.class),
|
||||
MARIADB("mariadb", "org.mariadb.jdbc.Driver", MariaDynamicDataSourceFactory.class),
|
||||
ORACLE("oracle", "oracle.jdbc.driver.OracleDriver", OracleDynamicDataSourceFactory.class),
|
||||
POSTGRES("postgres", "org.postgresql.Driver", PostgresDynamicDataSourceFactory.class),
|
||||
;
|
||||
|
||||
|
||||
private final String type;
|
||||
|
||||
private final String drive;
|
||||
|
||||
private final Class<? extends DynamicDataSourceFactory> clazz;
|
||||
|
||||
private volatile DynamicDataSourceFactory dynamicDataSourceFactory;
|
||||
|
||||
|
||||
DynamicSourceEnum(String type, String drive, Class<? extends DynamicDataSourceFactory> clazz) {
|
||||
this.type = type;
|
||||
this.drive = drive;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getDrive() {
|
||||
return drive;
|
||||
}
|
||||
|
||||
public DynamicDataSourceFactory getDynamicDataSourceFactory() {
|
||||
if (null == dynamicDataSourceFactory) {
|
||||
synchronized (this) {
|
||||
if (null == dynamicDataSourceFactory) {
|
||||
try {
|
||||
dynamicDataSourceFactory = clazz.getDeclaredConstructor().newInstance();
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("初始化实例失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dynamicDataSourceFactory;
|
||||
}
|
||||
|
||||
|
||||
public static DynamicSourceEnum getType(String typeName){
|
||||
return Arrays.stream(DynamicSourceEnum.values()).filter(e->e.getType().equals(typeName)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.fateverse.query.factory;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.entity.DynamicPage;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface DynamicDataSourceFactory {
|
||||
|
||||
/**
|
||||
* 获取到数据库session 工厂
|
||||
*
|
||||
* @param dataSource 数据源管理信息
|
||||
* @return 数据工厂
|
||||
*/
|
||||
SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSource);
|
||||
|
||||
/**
|
||||
* 获取到查询的mapper映射文件
|
||||
*
|
||||
* @param sqlSession sqlSession
|
||||
* @return 映射的mapper
|
||||
*/
|
||||
DynamicDataSourceMapper getTableMapper(SqlSession sqlSession);
|
||||
|
||||
/**
|
||||
* 获取到动态的分页信息
|
||||
*
|
||||
* @return 分页信息
|
||||
*/
|
||||
DynamicPage getDynamicPage();
|
||||
|
||||
/**
|
||||
* 使用数据源拼接jdbcUrl
|
||||
*
|
||||
* @param dataSourceManage 数据源管理信息
|
||||
* @return url返回参数
|
||||
*/
|
||||
String getDataBaseUrl(DataSourceManage dataSourceManage);
|
||||
|
||||
/**
|
||||
* 获取到数据库对应的特殊参数
|
||||
*
|
||||
* @param dataSourceManage 数据库特殊参数
|
||||
* @return 返回参数
|
||||
*/
|
||||
Map<String, Object> getParams(DataSourceManage dataSourceManage);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.fateverse.query.factory;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Component
|
||||
public class DynamicDataSourceService {
|
||||
|
||||
private final Map<Long, SqlSessionFactory> factoryMap = new ConcurrentHashMap<>(8);
|
||||
|
||||
private static final ThreadLocal<SqlSession> session = new ThreadLocal<>();
|
||||
|
||||
|
||||
/**
|
||||
* 获取到数据源的SqlSession
|
||||
*
|
||||
* @param dataSourceManage 数据源
|
||||
* @return 返回DynamicDataSourceMapper对象
|
||||
*/
|
||||
public DynamicDataSourceMapper getMapper(DataSourceManage dataSourceManage) {
|
||||
SqlSessionFactory sqlSessionFactory = factoryMap.get(dataSourceManage.getId());
|
||||
DynamicSourceEnum type = dataSourceManage.getType();
|
||||
if (sqlSessionFactory == null) {
|
||||
synchronized (this) {
|
||||
sqlSessionFactory = factoryMap.get(dataSourceManage.getId());
|
||||
if (null == sqlSessionFactory) {
|
||||
sqlSessionFactory = type.getDynamicDataSourceFactory().getSqlSessionFactory(dataSourceManage);
|
||||
factoryMap.put(dataSourceManage.getId(), sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession();
|
||||
session.set(sqlSession);
|
||||
return type.getDynamicDataSourceFactory().getTableMapper(sqlSession);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查当前数据源是否可连接
|
||||
*
|
||||
* @param dataSourceManage 数据源管理对象
|
||||
* @return 如果数据源可连接则返回true,否则返回false
|
||||
*/
|
||||
public Boolean checkDataSource(DataSourceManage dataSourceManage) {
|
||||
try {
|
||||
SqlSessionFactory sqlSessionFactory = dataSourceManage.getType().getDynamicDataSourceFactory().getSqlSessionFactory(dataSourceManage);
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession();
|
||||
DynamicDataSourceMapper tableMapper = dataSourceManage.getType().getDynamicDataSourceFactory().getTableMapper(sqlSession);
|
||||
tableMapper.checkSource();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof CustomException) {
|
||||
throw e;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Session工厂缓存
|
||||
*
|
||||
* @param dataSourceId 数据源id
|
||||
*/
|
||||
public synchronized void remove(Long dataSourceId) {
|
||||
factoryMap.remove(dataSourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭sqlSession
|
||||
*/
|
||||
public void closeSqlSession() {
|
||||
SqlSession sqlSession = session.get();
|
||||
if (sqlSession != null) {
|
||||
sqlSession.close();
|
||||
session.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cn.fateverse.query.factory.impl;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.entity.DynamicPage;
|
||||
import cn.fateverse.query.enums.DynamicSourceEnum;
|
||||
import cn.fateverse.query.submeter.datasource.SubmeterDataSource;
|
||||
import cn.fateverse.query.utils.MyBatisResourceUtils;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.fateverse.common.core.entity.PageInfo;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.utils.TableSupport;
|
||||
import cn.fateverse.common.mybatis.utils.PageUtils;
|
||||
import cn.fateverse.query.factory.DynamicDataSourceFactory;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONException;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-24
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class AbstractDynamicDataSourceFactory implements DynamicDataSourceFactory {
|
||||
|
||||
public SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSourceManage, String mapperPath) {
|
||||
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||
//获取需要的xml文件
|
||||
Resource[] resources = MyBatisResourceUtils.getResources(mapperPath);
|
||||
sessionFactoryBean.setMapperLocations(resources);
|
||||
DynamicSourceEnum mysqlEnum = dataSourceManage.getType();
|
||||
String baseUrl;
|
||||
if (1 == dataSourceManage.getConfigType()) {
|
||||
baseUrl = getDataBaseUrl(dataSourceManage);
|
||||
} else {
|
||||
baseUrl = dataSourceManage.getUrl();
|
||||
}
|
||||
//todo 后续分表查询可将数据源替换为新的数据源即可
|
||||
DataSource dataSource = new UnpooledDataSource(mysqlEnum.getDrive(), baseUrl,
|
||||
dataSourceManage.getUsername(), dataSourceManage.getPassword());
|
||||
// sessionFactoryBean.setDataSource(new SubmeterDataSource(dataSource));
|
||||
sessionFactoryBean.setDataSource(dataSource);
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
try {
|
||||
sqlSessionFactory = sessionFactoryBean.getObject();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return sqlSessionFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DynamicPage getDynamicPage() {
|
||||
PageInfo pageInfo = TableSupport.buildPageRequest();
|
||||
Integer startNum = PageUtils.getStartSize(pageInfo);
|
||||
Integer endNum = startNum + pageInfo.getPageSize();
|
||||
return DynamicPage.builder()
|
||||
.startNum(startNum)
|
||||
.endNum(endNum)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParams(DataSourceManage dataSourceManage) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public JSONObject checkParam(String paramStr, String msg, String... keys) {
|
||||
if (StrUtil.isBlank(paramStr)) {
|
||||
throw new CustomException(msg);
|
||||
}
|
||||
JSONObject params;
|
||||
try {
|
||||
params = JSON.parseObject(paramStr);
|
||||
for (String key : keys) {
|
||||
if (StrUtil.isBlank(params.getString(key))) {
|
||||
log.error(key + "is blank");
|
||||
throw new CustomException(msg);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new CustomException(msg);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.fateverse.query.factory.impl;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import cn.fateverse.query.mapper.dynamic.MariaDynamicDataSourceMapper;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-23
|
||||
*/
|
||||
public class MariaDynamicDataSourceFactory extends AbstractDynamicDataSourceFactory {
|
||||
|
||||
@Override
|
||||
public SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSourceManage) {
|
||||
return super.getSqlSessionFactory(dataSourceManage, "classpath:mapper/dynamic/MariaDynamicDataSourceMapper.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceMapper getTableMapper(SqlSession sqlSession) {
|
||||
return sqlSession.getMapper(MariaDynamicDataSourceMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataBaseUrl(DataSourceManage dataSource) {
|
||||
return "jdbc:mariadb://" + dataSource.getHost() + ":" + dataSource.getPort() + "/" + dataSource.getDbName() + dataSource.getArgs();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.fateverse.query.factory.impl;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import cn.fateverse.query.mapper.dynamic.MySqlDynamicDataSourceMapper;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public class MySqlDynamicDataSourceFactory extends AbstractDynamicDataSourceFactory {
|
||||
|
||||
|
||||
@Override
|
||||
public SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSourceManage) {
|
||||
return super.getSqlSessionFactory(dataSourceManage, "classpath:mapper/dynamic/MySqlDynamicDataSourceMapper.xml");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceMapper getTableMapper(SqlSession sqlSession) {
|
||||
return sqlSession.getMapper(MySqlDynamicDataSourceMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataBaseUrl(DataSourceManage dataSource) {
|
||||
return "jdbc:mysql://" + dataSource.getHost() + ":" + dataSource.getPort() + "/" + dataSource.getDbName() + (null == dataSource.getArgs() ? "" : dataSource.getArgs());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.fateverse.query.factory.impl;
|
||||
|
||||
import cn.fateverse.common.core.utils.ObjectUtils;
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import cn.fateverse.query.mapper.dynamic.OracleDynamicDataSourceMapper;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-24
|
||||
*/
|
||||
public class OracleDynamicDataSourceFactory extends AbstractDynamicDataSourceFactory {
|
||||
|
||||
@Override
|
||||
public SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSourceManage) {
|
||||
return super.getSqlSessionFactory(dataSourceManage, "classpath:mapper/dynamic/OracleDynamicDataSourceMapper.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataBaseUrl(DataSourceManage dataSourceManage) {
|
||||
JSONObject params = super.checkParam(dataSourceManage.getParams(), "服务名称不能为空", "serviceName");
|
||||
return "jdbc:oracle:thin:@" + dataSourceManage.getHost() + ":" + dataSourceManage.getPort() + ":" + params.getString("serviceName") + (ObjectUtils.isEmpty(dataSourceManage.getArgs()) ? "" : dataSourceManage.getArgs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceMapper getTableMapper(SqlSession sqlSession) {
|
||||
return sqlSession.getMapper(OracleDynamicDataSourceMapper.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.fateverse.query.factory.impl;
|
||||
|
||||
import cn.fateverse.common.core.entity.PageInfo;
|
||||
import cn.fateverse.common.core.utils.TableSupport;
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.entity.DynamicPage;
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
import cn.fateverse.query.mapper.dynamic.PostgresDynamicDataSourceMapper;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-25
|
||||
*/
|
||||
public class PostgresDynamicDataSourceFactory extends AbstractDynamicDataSourceFactory {
|
||||
@Override
|
||||
public SqlSessionFactory getSqlSessionFactory(DataSourceManage dataSource) {
|
||||
return super.getSqlSessionFactory(dataSource, "classpath:mapper/dynamic/PostgresDynamicDataSourceMapper.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceMapper getTableMapper(SqlSession sqlSession) {
|
||||
return sqlSession.getMapper(PostgresDynamicDataSourceMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataBaseUrl(DataSourceManage dataSourceManage) {
|
||||
return "jdbc:postgresql://" + dataSourceManage.getHost() + ":" + dataSourceManage.getPort() + "/" + dataSourceManage.getDbName() + dataSourceManage.getArgs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParams(DataSourceManage dataSourceManage) {
|
||||
JSONObject param = super.checkParam(dataSourceManage.getParams(), "命名空间不能为空", "namespace");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("namespace", param.getString("namespace"));
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicPage getDynamicPage() {
|
||||
PageInfo pageInfo = TableSupport.buildPageRequest();
|
||||
Integer startNum = pageInfo.getPageSize();
|
||||
Integer endNum = (pageInfo.getPageNum() - 1) * pageInfo.getPageSize();
|
||||
return DynamicPage.builder()
|
||||
.startNum(startNum)
|
||||
.endNum(endNum)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.fateverse.query.handler.adapter;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-10-31 20:52
|
||||
*/
|
||||
public interface DataAdapterHandler {
|
||||
|
||||
/**
|
||||
* 模拟执行
|
||||
*
|
||||
* @param dataAdapter 数据适配器信息
|
||||
* @return 执行结果
|
||||
*/
|
||||
Object mockExecute(DataAdapter dataAdapter, Object param);
|
||||
|
||||
/**
|
||||
* 真实执行
|
||||
*
|
||||
* @param dataAdapter 数据适配器信息
|
||||
* @return 执行结果
|
||||
*/
|
||||
Object execute(DataAdapter dataAdapter, Object param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.fateverse.query.handler.adapter.impl;
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.entity.UniQuery;
|
||||
import cn.fateverse.query.entity.dto.SearchInfo;
|
||||
import cn.fateverse.query.enums.DataAdapterSource;
|
||||
import cn.fateverse.query.handler.adapter.DataAdapterHandler;
|
||||
import cn.fateverse.query.handler.reader.EngineExecuteHandlerReader;
|
||||
import cn.fateverse.query.mapper.UniQueryMapper;
|
||||
import cn.fateverse.query.service.DynamicDataSearchService;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-10-31 21:04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CustomQueryDataAdapterHandler implements DataAdapterHandler {
|
||||
|
||||
|
||||
private final UniQueryMapper uniQueryMapper;
|
||||
|
||||
private final EngineExecuteHandlerReader handlerReader;
|
||||
|
||||
private final DynamicDataSearchService dynamicDataSearchService;
|
||||
|
||||
public CustomQueryDataAdapterHandler(UniQueryMapper uniQueryMapper,
|
||||
EngineExecuteHandlerReader handlerReader,
|
||||
DynamicDataSearchService dynamicDataSearchService) {
|
||||
this.uniQueryMapper = uniQueryMapper;
|
||||
this.handlerReader = handlerReader;
|
||||
this.dynamicDataSearchService = dynamicDataSearchService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object mockExecute(DataAdapter dataAdapter, Object param) {
|
||||
if (!(dataAdapter.getSource() == DataAdapterSource.TOPO_QUERY || dataAdapter.getSource() == DataAdapterSource.SQL_QUERY)) {
|
||||
return null;
|
||||
}
|
||||
handlerReader.preconditioning(dataAdapter);
|
||||
if (null == param) {
|
||||
throw new CustomException("参数对象不能为空");
|
||||
}
|
||||
if (!(param instanceof SearchInfo)) {
|
||||
throw new CustomException("数据类型不匹配");
|
||||
}
|
||||
SearchInfo info = (SearchInfo) param;
|
||||
UniQuery query = uniQueryMapper.selectSampleById(dataAdapter.getDataSourceId());
|
||||
if (null == query) {
|
||||
throw new CustomException("数据源为空!");
|
||||
}
|
||||
//根据设置的参数动态调整当前是否需要分页操作
|
||||
TableDataInfo<Map<String, Object>> tableDataInfo = dynamicDataSearchService.searchData(info.getList(), query, null, Boolean.TRUE);
|
||||
return handlerReader.execute(dataAdapter, tableDataInfo.getRows(), true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(DataAdapter dataAdapter, Object param) {
|
||||
if (!(dataAdapter.getSource() == DataAdapterSource.TOPO_QUERY || dataAdapter.getSource() == DataAdapterSource.SQL_QUERY)) {
|
||||
return null;
|
||||
}
|
||||
handlerReader.preconditioning(dataAdapter);
|
||||
List<Map<String, Object>> data = JSON.parseObject(dataAdapter.getMockData(), new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
return handlerReader.execute(dataAdapter, data, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.fateverse.query.handler.engine;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
|
||||
public interface EngineExecuteHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 执行方法
|
||||
*
|
||||
* @param dataAdapter 数据适配器
|
||||
* @param data 数据列表
|
||||
* @param development
|
||||
* @return JSONObject对象
|
||||
*/
|
||||
Object execute(DataAdapter dataAdapter, Object data, boolean development);
|
||||
|
||||
/**
|
||||
* 预处理数据适配器
|
||||
*
|
||||
* @param dataAdapter 数据适配器
|
||||
*/
|
||||
Boolean preconditioning(DataAdapter dataAdapter);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package cn.fateverse.query.handler.engine.impl;
|
||||
|
||||
import cn.fateverse.common.code.engine.JavaCodeEngine;
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.enums.DataAdapterType;
|
||||
import cn.fateverse.query.handler.engine.EngineExecuteHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Java代码执行器
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2023-10-29 19:34
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JavaEngineExecuteHandler implements EngineExecuteHandler {
|
||||
|
||||
private final JavaCodeEngine javaCodeEngine;
|
||||
|
||||
|
||||
private final String IMPORT_CODE =
|
||||
"import java.util.*;\n" +
|
||||
"import java.util.stream.*;\n";
|
||||
|
||||
public JavaEngineExecuteHandler(JavaCodeEngine javaCodeEngine) {
|
||||
this.javaCodeEngine = javaCodeEngine;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(DataAdapter dataAdapter, Object data, boolean development) {
|
||||
if (dataAdapter.getType() != DataAdapterType.JAVA) {
|
||||
return null;
|
||||
}
|
||||
return javaCodeEngine.execute(dataAdapter.getExecuteCode(), getClassName(dataAdapter),
|
||||
"execute", new Class[]{List.class}, new Object[]{data}, development);
|
||||
}
|
||||
|
||||
private static String getClassName(DataAdapter dataAdapter) {
|
||||
return "DataAdapter" + dataAdapter.getAdapterId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean preconditioning(DataAdapter dataAdapter) {
|
||||
if (dataAdapter.getType() != DataAdapterType.JAVA) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
String modifiedCode = modifiedCode(dataAdapter.getCode());
|
||||
String replacedCode = replacedClass(modifiedCode, getClassName(dataAdapter));
|
||||
dataAdapter.setExecuteCode(IMPORT_CODE + replacedCode);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 替换类定义
|
||||
*
|
||||
* @param code 待替换的代码
|
||||
* @param className 替换后的类名
|
||||
* @return 替换后的代码
|
||||
* @throws CustomException 如果类定义未被匹配到则抛出异常
|
||||
*/
|
||||
private String replacedClass(String code, String className) {
|
||||
// 正则表达式匹配类定义
|
||||
String regex = "public class .*? ";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(code);
|
||||
if (matcher.find()) {
|
||||
// 执行替换操作
|
||||
return code.replaceFirst(regex, "public class " + className + " ");
|
||||
} else {
|
||||
throw new CustomException("请勿修改类定义");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除import引入的内容
|
||||
*
|
||||
* @param code 需要去除的代码
|
||||
* @return 处理完成的代码
|
||||
*/
|
||||
private String modifiedCode(String code) {
|
||||
// 定义正则表达式,用于匹配代码中的指定内容
|
||||
String regex = "public class DataAdapter \\{";
|
||||
// 编译正则表达式
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
// 使用编译后的正则表达式对代码进行匹配
|
||||
Matcher matcher = pattern.matcher(code);
|
||||
// 如果匹配成功,则执行删除操作
|
||||
if (matcher.find()) {
|
||||
// 使用replaceFirst方法替换匹配到的内容为空字符串,实现删除操作
|
||||
int classIndex = matcher.start();
|
||||
return code.substring(classIndex);
|
||||
} else {
|
||||
// 如果匹配失败,则抛出自定义异常
|
||||
throw new CustomException("代码格式异常,请检查");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.fateverse.query.handler.engine.impl;
|
||||
|
||||
import cn.fateverse.common.code.engine.JavaScriptEngine;
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.handler.engine.EngineExecuteHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* JavaScript 代码执行器
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2023-10-29 19:35
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JavaScriptEngineExecuteHandler implements EngineExecuteHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(DataAdapter dataAdapter, Object data, boolean development) {
|
||||
return JavaScriptEngine.executeScript(dataAdapter.getExecuteCode(), "execute", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean preconditioning(DataAdapter dataAdapter) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.fateverse.query.handler.reader;
|
||||
|
||||
|
||||
import cn.fateverse.common.core.exception.CustomException;
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.handler.adapter.DataAdapterHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据适配器的执行器
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2023-10-31 20:55
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataAdapterHandlerReader {
|
||||
|
||||
private final List<DataAdapterHandler> handlerList;
|
||||
|
||||
|
||||
public DataAdapterHandlerReader(List<DataAdapterHandler> handlerList) {
|
||||
this.handlerList = handlerList;
|
||||
}
|
||||
|
||||
|
||||
public Object mockExecute(DataAdapter dataAdapter, Object params) {
|
||||
for (DataAdapterHandler dataAdapterHandler : handlerList) {
|
||||
Object result = dataAdapterHandler.mockExecute(dataAdapter, params);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw new CustomException("当前数据源类型不支持!");
|
||||
}
|
||||
|
||||
|
||||
public Object execute(DataAdapter dataAdapter, Object params) {
|
||||
for (DataAdapterHandler dataAdapterHandler : handlerList) {
|
||||
Object result = dataAdapterHandler.execute(dataAdapter, params);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw new CustomException("当前数据源类型不支持!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.fateverse.query.handler.reader;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.handler.engine.EngineExecuteHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-10-29 19:31
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EngineExecuteHandlerReader {
|
||||
|
||||
|
||||
private final List<EngineExecuteHandler> handlerList;
|
||||
|
||||
public EngineExecuteHandlerReader(List<EngineExecuteHandler> handlerList) {
|
||||
this.handlerList = handlerList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 预处理方法,用于对传入的数据适配器进行预处理
|
||||
*
|
||||
* @param dataAdapter 数据适配器
|
||||
*/
|
||||
public void preconditioning(DataAdapter dataAdapter) {
|
||||
// 遍历引擎执行处理器列表
|
||||
for (EngineExecuteHandler engineExecuteHandler : handlerList) {
|
||||
// 执行预处理方法
|
||||
Boolean result = engineExecuteHandler.preconditioning(dataAdapter);
|
||||
if (result) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行方法
|
||||
*
|
||||
* @param dataAdapter 数据适配器
|
||||
* @param data 数据列表
|
||||
* @return 执行结果
|
||||
*/
|
||||
public Object execute(DataAdapter dataAdapter, Object data, boolean development) {
|
||||
// 遍历引擎执行处理器列表
|
||||
for (EngineExecuteHandler engineExecuteHandler : handlerList) {
|
||||
// 执行数据适配器的处理方法
|
||||
Object result = engineExecuteHandler.execute(dataAdapter, data, development);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// 若未找到匹配的数据适配器处理器,则返回null
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.DataAdapter;
|
||||
import cn.fateverse.query.entity.query.DataAdapterQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源适配器 Mapper
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
public interface DataAdapterMapper {
|
||||
|
||||
/**
|
||||
* 查询数据源适配器
|
||||
*
|
||||
* @param adapterId 数据源适配器Id
|
||||
* @return 数据源适配器
|
||||
*/
|
||||
DataAdapter selectById(Long adapterId);
|
||||
|
||||
/**
|
||||
* 查询数据源适配器列表
|
||||
*
|
||||
* @param query 数据源适配器查询
|
||||
* @return 数据源适配器集合
|
||||
*/
|
||||
List<DataAdapter> selectList(DataAdapterQuery query);
|
||||
|
||||
/**
|
||||
* 新增数据源适配器
|
||||
*
|
||||
* @param dataAdapter 数据源适配器
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(DataAdapter dataAdapter);
|
||||
|
||||
/**
|
||||
* 修改数据源适配器
|
||||
*
|
||||
* @param dataAdapter 数据源适配器
|
||||
* @return 结果
|
||||
*/
|
||||
int update(DataAdapter dataAdapter);
|
||||
|
||||
/**
|
||||
* 删除数据源适配器
|
||||
*
|
||||
* @param adapterId 需要删除的数据源适配器Id
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteById(Long adapterId);
|
||||
|
||||
/**
|
||||
* 批量删除数据源适配器
|
||||
*
|
||||
* @param adapterIdList 需要删除的数据源适配器Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBatchByIdList(List<Long> adapterIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManage;
|
||||
import cn.fateverse.query.entity.query.DataSourceManageQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源管理 Mapper
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface DataSourceManageMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据源管理
|
||||
*
|
||||
* @param id 数据源管理Id
|
||||
* @return 数据源管理
|
||||
*/
|
||||
DataSourceManage selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询数据源管理列表
|
||||
*
|
||||
* @param query 数据源管理查询
|
||||
* @return 数据源管理集合
|
||||
*/
|
||||
List<DataSourceManage> selectList(DataSourceManageQuery query);
|
||||
|
||||
/**
|
||||
* 新增数据源管理
|
||||
*
|
||||
* @param dataSourceManage 数据源管理
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(DataSourceManage dataSourceManage);
|
||||
|
||||
/**
|
||||
* 修改数据源管理
|
||||
*
|
||||
* @param dataSourceManage 数据源管理
|
||||
* @return 结果
|
||||
*/
|
||||
int update(DataSourceManage dataSourceManage);
|
||||
|
||||
/**
|
||||
* 删除数据源管理
|
||||
*
|
||||
* @param id 需要删除的数据源管理Id
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据源管理
|
||||
*
|
||||
* @param idList 需要删除的数据源管理Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBatchByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.DynamicPage;
|
||||
import cn.fateverse.query.entity.DynamicTable;
|
||||
import cn.fateverse.query.entity.Table;
|
||||
import cn.fateverse.query.entity.TableColumn;
|
||||
import cn.fateverse.query.entity.bo.SqlSelect;
|
||||
import cn.fateverse.query.entity.bo.TopologySelect;
|
||||
import cn.fateverse.query.entity.query.DynamicTableQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface DynamicDataSourceMapper {
|
||||
|
||||
/**
|
||||
* 检查数据库是否可连接
|
||||
*
|
||||
* @return 连接后查询的结果
|
||||
*/
|
||||
Integer checkSource();
|
||||
|
||||
/**
|
||||
* topology数据查询
|
||||
*
|
||||
* @param select 需要查询的数据信息
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<Map<String, Object>> uniSingleQueryTopology(@Param("select") TopologySelect select, @Param("page") DynamicPage page);
|
||||
|
||||
/**
|
||||
* topology数据查询 获取总数
|
||||
*
|
||||
* @param select 需要查询的数据信息
|
||||
* @return 查询结果
|
||||
*/
|
||||
Long uniSingleQueryTopologyCount(@Param("select") TopologySelect select);
|
||||
|
||||
/**
|
||||
* 多表查询数据
|
||||
*
|
||||
* @param select 查询条件
|
||||
* @param page 分页信息
|
||||
* @return 返回数据
|
||||
*/
|
||||
List<Map<String, Object>> uniMultiListQueryTopology(@Param("select") TopologySelect select, @Param("page") DynamicPage page);
|
||||
|
||||
|
||||
/**
|
||||
* 多表查询总数
|
||||
*
|
||||
* @param select topo查询
|
||||
* @return 总数
|
||||
*/
|
||||
Long uniMultiListQueryTopologyCount(@Param("select") TopologySelect select);
|
||||
|
||||
|
||||
/**
|
||||
* sql自定义查询
|
||||
*
|
||||
* @param select 查询信息
|
||||
* @param page 分页信息
|
||||
* @return 返回数据
|
||||
*/
|
||||
List<Map<String, Object>> uniQuerySql(@Param("select") SqlSelect select, @Param("page") DynamicPage page);
|
||||
|
||||
/**
|
||||
* 自定义查询总数获取
|
||||
*
|
||||
* @param select 查询条件信息
|
||||
* @return 总数
|
||||
*/
|
||||
Long uniQuerySqlCount(@Param("select") SqlSelect select);
|
||||
|
||||
/**
|
||||
* 查询动态的表格源信息列表
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @param page 分页对象
|
||||
* @param tableName 表名称
|
||||
* @return 查询数据
|
||||
*/
|
||||
List<DynamicTable> selectTableList(@Param("table") DynamicTableQuery query, @Param("page") DynamicPage page, @Param("list") List<String> tableName, @Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询动态的表格源信息 总数
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @param tableName 表名称
|
||||
* @return 总数
|
||||
*/
|
||||
Long selectTableListCount(@Param("table") DynamicTableQuery query, @Param("list") List<String> tableName, @Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过表名称查询
|
||||
*
|
||||
* @param tables 表名称
|
||||
* @return 表格信息
|
||||
*/
|
||||
List<Table> selectDynamicTableListByNameList(@Param("list") List<String> tables, @Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据tablename list 获取到所有的
|
||||
*
|
||||
* @param tables 表名称
|
||||
* @return 表格信息
|
||||
*/
|
||||
List<TableColumn> selectDynamicTableColumnsByNameList(@Param("list") List<String> tables, @Param("params") Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.DynamicEcharts;
|
||||
import cn.fateverse.query.entity.query.DynamicEchartsQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态echarts图表 Mapper
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-11-16
|
||||
*/
|
||||
public interface DynamicEchartsMapper {
|
||||
|
||||
/**
|
||||
* 查询动态echarts图表
|
||||
*
|
||||
* @param echartsId 动态echarts图表Id
|
||||
* @return 动态echarts图表
|
||||
*/
|
||||
DynamicEcharts selectById(Long echartsId);
|
||||
|
||||
/**
|
||||
* 查询动态echarts图表列表
|
||||
*
|
||||
* @param query 动态echarts图表查询
|
||||
* @return 动态echarts图表集合
|
||||
*/
|
||||
List<DynamicEcharts> selectList(DynamicEchartsQuery query);
|
||||
|
||||
/**
|
||||
* 新增动态echarts图表
|
||||
*
|
||||
* @param dynamicEcharts 动态echarts图表
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(DynamicEcharts dynamicEcharts);
|
||||
|
||||
/**
|
||||
* 修改动态echarts图表
|
||||
*
|
||||
* @param dynamicEcharts 动态echarts图表
|
||||
* @return 结果
|
||||
*/
|
||||
int update(DynamicEcharts dynamicEcharts);
|
||||
|
||||
/**
|
||||
* 删除动态echarts图表
|
||||
*
|
||||
* @param echartsId 需要删除的动态echarts图表Id
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteById(Long echartsId);
|
||||
|
||||
/**
|
||||
* 批量删除动态echarts图表
|
||||
*
|
||||
* @param echartsIdList 需要删除的动态echarts图表Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBatchByIdList(List<Long> echartsIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.TableColumn;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface TableColumnMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 批量新增列信息
|
||||
*
|
||||
* @param columns 列信息
|
||||
* @return 处理结果
|
||||
*/
|
||||
Integer batchInsert(List<TableColumn> columns);
|
||||
|
||||
/**
|
||||
* 批量更新列信息
|
||||
*
|
||||
* @param columns 列信息
|
||||
* @return 处理结果
|
||||
*/
|
||||
Integer batchUpdate(List<TableColumn> columns);
|
||||
|
||||
/**
|
||||
* 同步时的批量更新
|
||||
*
|
||||
* @param columns 列信息
|
||||
* @return 处理结果
|
||||
*/
|
||||
Integer syncUpdate(List<TableColumn> columns);
|
||||
|
||||
/**
|
||||
* 批量删除列信息
|
||||
*
|
||||
* @param ids 需要删除的id
|
||||
* @return 影响数据条数
|
||||
*/
|
||||
Integer batchRemove(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据表格id删除列信息
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 删除行
|
||||
*/
|
||||
Integer deleteByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 根据表格id查询列信息
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 列信息
|
||||
*/
|
||||
List<TableColumn> selectByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 根据表格id获取列信息
|
||||
*
|
||||
* @param tableIds 表格id
|
||||
* @return 列信息
|
||||
*/
|
||||
List<TableColumn> selectByTableIds(List<Long> tableIds);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.DataSourceManageCount;
|
||||
import cn.fateverse.query.entity.Table;
|
||||
import cn.fateverse.query.entity.query.TableQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface TableMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 根据表格id查询信息
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 表格信息
|
||||
*/
|
||||
Table selectById(Long tableId);
|
||||
|
||||
/**
|
||||
* 根据数据源id查询表格名称
|
||||
*
|
||||
* @param dataSourceId
|
||||
* @return
|
||||
*/
|
||||
Set<String> selectTableNameByDataSourceId(Long dataSourceId);
|
||||
|
||||
/**
|
||||
* 根据数据源id获取到表格信息
|
||||
*
|
||||
* @param dataSourceId 数据源id
|
||||
* @return 表格信息
|
||||
*/
|
||||
List<Table> selectListByDataSourceId(Long dataSourceId);
|
||||
|
||||
/**
|
||||
* 查询表格list
|
||||
*
|
||||
* @param query
|
||||
* @return 业务集合
|
||||
*/
|
||||
List<Table> selectList(TableQuery query);
|
||||
|
||||
/**
|
||||
* 根据数据源id查询当前数据源id下存在多少张表信息
|
||||
*
|
||||
* @param idList 数据源id列表
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<DataSourceManageCount> selectCountByDataSourceIds(List<Long> idList);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
int insert(Table table);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
int update(Table table);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param tableId
|
||||
* @return
|
||||
*/
|
||||
int deleteById(Long tableId);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int deleteByIds(Long[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.TableRelationalMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
public interface TableRelationalMappingMapper {
|
||||
|
||||
/**
|
||||
* 批量新增表格的映射关系
|
||||
*
|
||||
* @param list 表格映射关系
|
||||
* @return 插入行数
|
||||
*/
|
||||
Integer batchInsert(List<TableRelationalMapping> list);
|
||||
|
||||
/**
|
||||
* 根据表格id查询关联关系
|
||||
*
|
||||
* @param mainId 表格id
|
||||
* @return 关联列表
|
||||
*/
|
||||
List<TableRelationalMapping> selectByMainId(Long mainId);
|
||||
|
||||
/**
|
||||
* 获取到表格对应的关系
|
||||
* @param mainIds
|
||||
* @return
|
||||
*/
|
||||
List<TableRelationalMapping> selectByMainIds(List<Long> mainIds);
|
||||
|
||||
/**
|
||||
* 根据表格id删除关联关系
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 删除条数
|
||||
*/
|
||||
Integer deleteByMainId(Long tableId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.TableRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-17
|
||||
*/
|
||||
public interface TableRoleMapper {
|
||||
/**
|
||||
* 根据表格查询表格与角色的关系
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 关系
|
||||
*/
|
||||
List<TableRole> selectByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 批量新增角色关系
|
||||
*
|
||||
* @param list 角色关系
|
||||
* @return 新增条数
|
||||
*/
|
||||
Integer batchInsert(List<TableRole> list);
|
||||
|
||||
/**
|
||||
* 根据表格id删除关系
|
||||
*
|
||||
* @param tableId 表格id
|
||||
* @return 删除结果
|
||||
*/
|
||||
Integer deleteByTableId(Long tableId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.UniColumn;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
public interface UniColumnMapper {
|
||||
|
||||
/**
|
||||
* 查询展示列表
|
||||
*
|
||||
* @param queryId id
|
||||
* @return 结果
|
||||
*/
|
||||
List<UniColumn> selectByQueryId(Long queryId);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
*
|
||||
* @param columns 列
|
||||
* @return 处理结果
|
||||
*/
|
||||
Integer batchInsert(List<UniColumn> columns);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param queryId 查询的id
|
||||
* @return 处理结果
|
||||
*/
|
||||
Integer batchDeleteByQueryId(Long queryId);
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
*/
|
||||
int batchUpdate(List<UniColumn> updateList);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
int batchRemove(@Param("ids") List<Long> removeIds);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-22
|
||||
*/
|
||||
public interface UniConMapper {
|
||||
|
||||
/**
|
||||
* 根据自定义查询查找查询条件
|
||||
*
|
||||
* @param queryId 自定义查询id
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<UniCon> selectByQueryId(Long queryId);
|
||||
|
||||
/**
|
||||
* 根据自身id和query id联合查询
|
||||
*/
|
||||
List<UniCon> selectByQueryIdAndUcIdList(@Param("queryId") Long queryId, @Param("list") List<Long> conIdList);
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
*/
|
||||
int batchUpdate(List<UniCon> updateList);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
Integer batchInsert(List<UniCon> list);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
Integer batchDelete(Long queryId);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
int batchRemove(@Param("ids") List<Long> ids);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.fateverse.query.mapper;
|
||||
|
||||
import cn.fateverse.query.entity.UniQuery;
|
||||
import cn.fateverse.query.entity.query.UniQueryQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 万能查询 Mapper
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-03-01
|
||||
*/
|
||||
public interface UniQueryMapper {
|
||||
|
||||
/**
|
||||
* 查询万能查询
|
||||
*
|
||||
* @param id 万能查询Id
|
||||
* @return 万能查询
|
||||
*/
|
||||
UniQuery selectById(Long id);
|
||||
|
||||
/**
|
||||
* 获取简单的自定义查询条目
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
UniQuery selectSampleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询万能查询列表
|
||||
*
|
||||
* @param query 万能查询查询
|
||||
* @return 万能查询集合
|
||||
*/
|
||||
List<UniQuery> selectList(UniQueryQuery query);
|
||||
|
||||
/**
|
||||
* 新增万能查询
|
||||
*
|
||||
* @param uniQuery 万能查询
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(UniQuery uniQuery);
|
||||
|
||||
/**
|
||||
* 修改万能查询
|
||||
*
|
||||
* @param uniQuery 万能查询
|
||||
* @return 结果
|
||||
*/
|
||||
int update(UniQuery uniQuery);
|
||||
|
||||
/**
|
||||
* 删除万能查询
|
||||
*
|
||||
* @param id 需要删除的万能查询Id
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除万能查询
|
||||
*
|
||||
* @param idList 需要删除的万能查询Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBatchByIdList(List<Long> idList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.fateverse.query.mapper.dynamic;
|
||||
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface MariaDynamicDataSourceMapper extends DynamicDataSourceMapper {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.fateverse.query.mapper.dynamic;
|
||||
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface MySqlDynamicDataSourceMapper extends DynamicDataSourceMapper {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.fateverse.query.mapper.dynamic;
|
||||
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-24
|
||||
*/
|
||||
public interface OracleDynamicDataSourceMapper extends DynamicDataSourceMapper {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.fateverse.query.mapper.dynamic;
|
||||
|
||||
import cn.fateverse.query.mapper.DynamicDataSourceMapper;
|
||||
|
||||
/**
|
||||
* @author Clay
|
||||
* @date 2023-07-25
|
||||
*/
|
||||
public interface PostgresDynamicDataSourceMapper extends DynamicDataSourceMapper {
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package cn.fateverse.query.service;
|
||||
|
||||
import cn.fateverse.query.entity.dto.DataAdapterDto;
|
||||
import cn.fateverse.query.entity.vo.DataAdapterVo;
|
||||
import cn.fateverse.query.entity.query.DataAdapterQuery;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源适配器 Service
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-10-29
|
||||
*/
|
||||
public interface DataAdapterService {
|
||||
|
||||
/**
|
||||
* 查询数据源适配器
|
||||
*
|
||||
* @param adapterId 数据源适配器Id
|
||||
* @return 数据源适配器
|
||||
*/
|
||||
DataAdapterVo searchById(Long adapterId);
|
||||
|
||||
/**
|
||||
* 查询数据源适配器列表
|
||||
*
|
||||
* @param query 数据源适配器
|
||||
* @return 数据源适配器集合
|
||||
*/
|
||||
TableDataInfo<DataAdapterVo> searchList(DataAdapterQuery query);
|
||||
|
||||
/**
|
||||
* 查询数据源适配器option
|
||||
*
|
||||
* @return 选项集合
|
||||
*/
|
||||
List<Option> searchOptionList();
|
||||
|
||||
/**
|
||||
* 导出数据源适配器列表
|
||||
*
|
||||
* @param query query 数据源适配器
|
||||
* @return 数据源适配器集合
|
||||
*/
|
||||
List<DataAdapterVo> exportList(DataAdapterQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 执行代码,并返回结果
|
||||
*
|
||||
* @param dataAdapter 适配器对象
|
||||
* @return 执行结果
|
||||
*/
|
||||
Object mockExecute(DataAdapterDto dataAdapter);
|
||||
|
||||
/**
|
||||
* 新增数据源适配器
|
||||
*
|
||||
* @param dataAdapter 数据源适配器
|
||||
* @return 结果
|
||||
*/
|
||||
int save(DataAdapterDto dataAdapter);
|
||||
|
||||
/**
|
||||
* 修改数据源适配器
|
||||
*
|
||||
* @param dataAdapter 数据源适配器
|
||||
* @return 结果
|
||||
*/
|
||||
int edit(DataAdapterDto dataAdapter);
|
||||
|
||||
/**
|
||||
* 删除数据源适配器
|
||||
*
|
||||
* @param adapterId 需要删除的数据源适配器Id
|
||||
* @return 结果
|
||||
*/
|
||||
int removeDataAdapterById(Long adapterId);
|
||||
|
||||
/**
|
||||
* 批量删除数据源适配器
|
||||
*
|
||||
* @param adapterIdList 需要删除的数据源适配器Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int removeBatch(List<Long> adapterIdList);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package cn.fateverse.query.service;
|
||||
|
||||
import cn.fateverse.query.entity.dto.DataSourceManageDto;
|
||||
import cn.fateverse.query.entity.vo.DataSourceManageVo;
|
||||
import cn.fateverse.query.entity.query.DataSourceManageQuery;
|
||||
import cn.fateverse.common.core.entity.Option;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源管理 Service
|
||||
*
|
||||
* @author clay
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
public interface DataSourceManageService {
|
||||
|
||||
/**
|
||||
* 查询数据源管理
|
||||
*
|
||||
* @param id 数据源管理Id
|
||||
* @return 数据源管理
|
||||
*/
|
||||
DataSourceManageVo searchById(Long id);
|
||||
|
||||
/**
|
||||
* 查询数据源管理列表
|
||||
*
|
||||
* @param query 数据源管理
|
||||
* @return 数据源管理集合
|
||||
*/
|
||||
TableDataInfo<DataSourceManageVo> searchList(DataSourceManageQuery query);
|
||||
|
||||
/**
|
||||
* 查询数据源管理option
|
||||
*
|
||||
* @return 选项集合
|
||||
*/
|
||||
List<Option> searchOptionList();
|
||||
|
||||
/**
|
||||
* 导出数据源管理列表
|
||||
*
|
||||
* @param query query 数据源管理
|
||||
* @return 数据源管理集合
|
||||
*/
|
||||
List<DataSourceManageVo> exportList(DataSourceManageQuery query);
|
||||
|
||||
/**
|
||||
* 新增数据源管理
|
||||
*
|
||||
* @param sourceManageDto 数据源管理
|
||||
* @return 结果
|
||||
*/
|
||||
int save(DataSourceManageDto sourceManageDto);
|
||||
|
||||
/**
|
||||
* 修改数据源管理
|
||||
*
|
||||
* @param sourceManageDto 数据源管理
|
||||
* @return 结果
|
||||
*/
|
||||
int edit(DataSourceManageDto sourceManageDto);
|
||||
|
||||
/**
|
||||
* 删除数据源管理
|
||||
*
|
||||
* @param id 需要删除的数据源管理Id
|
||||
* @return 结果
|
||||
*/
|
||||
int removeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据源管理
|
||||
*
|
||||
* @param idList 需要删除的数据源管理Id 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int removeBatch(List<Long> idList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.fateverse.query.service;
|
||||
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.query.entity.DynamicPage;
|
||||
import cn.fateverse.query.entity.UniCon;
|
||||
import cn.fateverse.query.entity.UniQuery;
|
||||
import cn.fateverse.query.entity.bo.SqlSelect;
|
||||
import cn.fateverse.query.entity.bo.TopologySelect;
|
||||
import cn.fateverse.query.mapper.UniConMapper;
|
||||
import cn.fateverse.query.entity.dto.UniConDto;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 动态数据查询
|
||||
*
|
||||
* @author Clay
|
||||
* @date 2023-08-05
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DynamicDataSearchService {
|
||||
|
||||
private final UniConMapper uniConMapper;
|
||||
|
||||
private final DynamicDataSourceTableService dynamicDataSourceTableService;
|
||||
|
||||
public DynamicDataSearchService(UniConMapper uniConMapper,
|
||||
DynamicDataSourceTableService dynamicDataSourceTableService) {
|
||||
this.uniConMapper = uniConMapper;
|
||||
this.dynamicDataSourceTableService = dynamicDataSourceTableService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据信息
|
||||
*
|
||||
* @param list 查询条件列表
|
||||
* @param query 查询对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
public TableDataInfo<Map<String, Object>> searchData(List<UniConDto> list, UniQuery query) {
|
||||
return searchData(list, query, null, Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据信息 (可以设置是否分页)
|
||||
*
|
||||
* @param list 查询条件列表
|
||||
* @param query 查询对象
|
||||
* @param page 分页信息
|
||||
* @param paging 是否分页
|
||||
* @return 查询结果
|
||||
*/
|
||||
public TableDataInfo<Map<String, Object>> searchData(List<UniConDto> list, UniQuery query, DynamicPage page, Boolean paging) {
|
||||
List<Long> ids = new ArrayList<>();
|
||||
Map<Long, Object> queryMap = new HashMap<>();
|
||||
list.forEach(con -> {
|
||||
ids.add(con.getUcId());
|
||||
queryMap.put(con.getUcId(), con.getQuery());
|
||||
});
|
||||
List<UniCon> uniConList;
|
||||
if (ids.isEmpty()) {
|
||||
uniConList = new ArrayList<>();
|
||||
} else {
|
||||
uniConList = uniConMapper.selectByQueryIdAndUcIdList(query.getId(), ids);
|
||||
}
|
||||
uniConList = uniConList.stream().filter(uniCon -> null != queryMap.get(uniCon.getUcId())).peek(uniCon -> uniCon.setUcMock(queryMap.get(uniCon.getUcId()))).collect(Collectors.toList());
|
||||
if (query.getType() == 1) {
|
||||
SqlSelect select = new SqlSelect();
|
||||
select.setSelectSql(query.getUqSql());
|
||||
select.setUniCons(uniConList);
|
||||
return dynamicDataSourceTableService.uniQuerySql(select, page, paging, query.getDataSourceId());
|
||||
} else {
|
||||
List<String> relevance = JSON.parseArray(query.getRelevance(), String.class);
|
||||
TopologySelect select = TopologySelect.builder()
|
||||
.selectKey(query.getSelectKey())
|
||||
.tableInfo(query.getTableInfo())
|
||||
.single(query.getSingle())
|
||||
.relevance(relevance)
|
||||
.uniCons(uniConList)
|
||||
.build();
|
||||
return dynamicDataSourceTableService.uniQueryTopology(select, page, paging, query.getDataSourceId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user