find:()新增规则引擎方法调用
parent
697285a179
commit
954e5c330b
|
@ -2,7 +2,9 @@ package com.muyu.server.controller;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.domain.CoreDataList;
|
import com.muyu.common.domain.CoreDataList;
|
||||||
|
import com.muyu.common.domain.DataName;
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
|
import com.muyu.common.domain.TableNames;
|
||||||
import com.muyu.server.service.DataLinkService;
|
import com.muyu.server.service.DataLinkService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -52,4 +54,28 @@ public class DataLinkController {
|
||||||
return Result.success(longs);
|
return Result.success(longs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表数据下所有表表
|
||||||
|
* @param dataName 数据库名称
|
||||||
|
* @return 反护试图
|
||||||
|
*/
|
||||||
|
@PostMapping("/findSelectDataShow")
|
||||||
|
public Result<List<DataName>> findSelectDataShow(
|
||||||
|
@RequestParam("dataName") String dataName){
|
||||||
|
List<DataName> longs = dataLinkService.findSelectDataShow(dataName);
|
||||||
|
return Result.success(longs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表数据dashuju表
|
||||||
|
* @param dataTableName 查看表下的所有数据
|
||||||
|
* @return 反护试图
|
||||||
|
*/
|
||||||
|
@PostMapping("/findSelectDataShow")
|
||||||
|
public Result<List<TableNames>> findSelectTableShow(
|
||||||
|
@RequestParam("dataTableName") String dataTableName){
|
||||||
|
List<TableNames> longs = dataLinkService.findSelectTableShow(dataTableName);
|
||||||
|
return Result.success(longs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
package com.muyu.server.service;
|
package com.muyu.server.service;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.domain.DataName;
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
|
import com.muyu.common.domain.TableNames;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@Author:yang
|
*@Author:yang
|
||||||
|
@ -29,4 +36,18 @@ public interface DataLinkService {
|
||||||
* @return 反护试图
|
* @return 反护试图
|
||||||
*/
|
*/
|
||||||
DataValue[][] findSelectDataList(String dataName, String sql, String dataTableName, Long one, Integer two);
|
DataValue[][] findSelectDataList(String dataName, String sql, String dataTableName, Long one, Integer two);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表数据下所有表表
|
||||||
|
* @param dataName 数据库名称
|
||||||
|
* @return 反护试图
|
||||||
|
*/
|
||||||
|
List<DataName> findSelectDataShow(String dataName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表数据dashuju表
|
||||||
|
* @param dataTableName 查看表下的所有数据
|
||||||
|
* @return 反护试图
|
||||||
|
*/
|
||||||
|
List<TableNames> findSelectTableShow(String dataTableName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,28 @@ package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.muyu.common.domain.DataName;
|
||||||
import com.muyu.common.domain.DataValue;
|
import com.muyu.common.domain.DataValue;
|
||||||
|
import com.muyu.common.domain.TableFie;
|
||||||
|
import com.muyu.common.domain.TableNames;
|
||||||
|
import com.muyu.server.mapper.DataRunNameMapper;
|
||||||
import com.muyu.server.mysql.MySqlDataSource;
|
import com.muyu.server.mysql.MySqlDataSource;
|
||||||
import com.muyu.server.mysql.MySqlQuery;
|
import com.muyu.server.mysql.MySqlQuery;
|
||||||
import com.muyu.server.service.DataLinkService;
|
import com.muyu.server.service.*;
|
||||||
import com.muyu.server.util.JdbcHelper;
|
import com.muyu.server.util.JdbcHelper;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.AbstractList;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@Author:yang
|
*@Author:yang
|
||||||
|
@ -24,7 +35,12 @@ import java.sql.SQLException;
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class DataLinkServiceImpl implements DataLinkService {
|
public class DataLinkServiceImpl implements DataLinkService {
|
||||||
|
@Autowired
|
||||||
|
private DataNameService dataNameService;
|
||||||
|
@Autowired
|
||||||
|
private TableRunNameService tableRunNameService;
|
||||||
|
@Autowired
|
||||||
|
private DataRunNameService dataRunNameService;
|
||||||
/**
|
/**
|
||||||
* 查询表数据count
|
* 查询表数据count
|
||||||
* @param dataName 数据库名称
|
* @param dataName 数据库名称
|
||||||
|
@ -62,4 +78,60 @@ public class DataLinkServiceImpl implements DataLinkService {
|
||||||
DataValue[][] rows = mySqlDataSource.getSqlDataSource();
|
DataValue[][] rows = mySqlDataSource.getSqlDataSource();
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataName> findSelectDataShow(String dataName) {
|
||||||
|
ArrayList<DataName> dataNames = new ArrayList<>();
|
||||||
|
DataName dataName1 = new DataName();
|
||||||
|
dataName1.setName(dataName);
|
||||||
|
|
||||||
|
List<DataName> dataNameList = dataNameService.list(new LambdaQueryWrapper<DataName>()
|
||||||
|
.eq(DataName::getName, dataNames))
|
||||||
|
.stream()
|
||||||
|
.map(DataName::dataNameBuild)
|
||||||
|
.toList();
|
||||||
|
dataNameList.forEach(dataName2 -> {
|
||||||
|
//在取数据数据遍历里获取表名称查询方法
|
||||||
|
List<TableNames> tableNamesList = tableRunNameService.list(new LambdaQueryWrapper<TableNames>()
|
||||||
|
.eq(TableNames::getDataId, dataName2.getId()))
|
||||||
|
.stream()
|
||||||
|
.map(TableNames::tableNamesBuild)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
//判断tableNamesList查询数据为空直接返回
|
||||||
|
if (CollectionUtils.isEmpty(tableNamesList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//在每一次循环中创建一个新的集合
|
||||||
|
ArrayList<TableNames> namesArrayList = new ArrayList<>(tableNamesList);
|
||||||
|
//添加到数据库实体类集合字段上
|
||||||
|
dataName2.setTableNames(namesArrayList);
|
||||||
|
//将添加好的实体类集合进行遍历操作
|
||||||
|
log.info("数据库表名称:{}",dataName2.getTableNames());
|
||||||
|
if (CollectionUtils.isEmpty(dataName2.getTableNames())) {return;}
|
||||||
|
|
||||||
|
});
|
||||||
|
return dataNameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表数据dashuju表
|
||||||
|
* @param dataTableName 查看表下的所有数据
|
||||||
|
* @return 反护试图
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TableNames> findSelectTableShow(String dataTableName) {
|
||||||
|
|
||||||
|
List<TableNames> tableNamesList = tableRunNameService.list(new LambdaQueryWrapper<TableNames>()
|
||||||
|
.eq(TableNames::getName, dataTableName))
|
||||||
|
.stream()
|
||||||
|
.map(TableNames::tableNamesBuild)
|
||||||
|
.toList();
|
||||||
|
tableNamesList.forEach(tableNames -> {
|
||||||
|
List<TableFie> tableFies = dataRunNameService.tableStructureShow(tableNames);
|
||||||
|
tableNames.setTableFie(tableFies);
|
||||||
|
});
|
||||||
|
return tableNamesList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue