Commit 7e1db985 by 梁家彪

QueryDb id改为整形

parent 1f5df8c9
...@@ -35,7 +35,7 @@ public class CommonQueryController { ...@@ -35,7 +35,7 @@ public class CommonQueryController {
@ApiOperation("获取全部数据源") @ApiOperation("获取全部数据源")
@GetMapping("/getTables/{id}") @GetMapping("/getTables/{id}")
public ResultVo getTables(@PathVariable Long id) throws Exception { public ResultVo getTables(@PathVariable Integer id) throws Exception {
return ResultVo.success(commonQueryService.getTables(id)); return ResultVo.success(commonQueryService.getTables(id));
} }
...@@ -119,7 +119,7 @@ public class CommonQueryController { ...@@ -119,7 +119,7 @@ public class CommonQueryController {
AssertUtils.notNull(id, "缺失ID"); AssertUtils.notNull(id, "缺失ID");
Object tableName = body.get("tableName"); Object tableName = body.get("tableName");
AssertUtils.notNull(tableName, "缺失表名"); AssertUtils.notNull(tableName, "缺失表名");
return ResultVo.success(TableUtil.getColumns(Convert.toLong(id), Convert.toStr(tableName))); return ResultVo.success(TableUtil.getColumns(Convert.toInt(id), Convert.toStr(tableName)));
} }
@ApiOperation("查询表内容") @ApiOperation("查询表内容")
......
...@@ -68,7 +68,7 @@ public class MetaDataMapping { ...@@ -68,7 +68,7 @@ public class MetaDataMapping {
/** /**
* 查询数据源id * 查询数据源id
*/ */
private Long queryDbId; private Integer queryDbId;
/** /**
* createTime * createTime
......
...@@ -17,7 +17,7 @@ public class QueryDb { ...@@ -17,7 +17,7 @@ public class QueryDb {
* id * id
*/ */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Integer id;
/** /**
* 数据库名称 * 数据库名称
......
...@@ -26,7 +26,7 @@ public class DatabaseRunner implements ApplicationRunner { ...@@ -26,7 +26,7 @@ public class DatabaseRunner implements ApplicationRunner {
@Resource @Resource
private CommonQueryService service; private CommonQueryService service;
private Map<Long, DruidPooledConnection> connectionMap = new HashMap<>(); private Map<Integer, DruidPooledConnection> connectionMap = new HashMap<>();
@Override @Override
public void run(ApplicationArguments args) throws SQLException { public void run(ApplicationArguments args) throws SQLException {
......
...@@ -97,7 +97,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -97,7 +97,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
Long id = Long.valueOf(jsonObject.get("id").toString()); Long id = Long.valueOf(jsonObject.get("id").toString());
List<MetaDataMapping> list = metaDataMappingDao.selectByCateId(id); List<MetaDataMapping> list = metaDataMappingDao.selectByCateId(id);
String tableSqlname = null; String tableSqlname = null;
Long queryDbId = null; Integer queryDbId = null;
for (MetaDataMapping mapping : list) { for (MetaDataMapping mapping : list) {
tableSqlname = mapping.getTableSqlname(); tableSqlname = mapping.getTableSqlname();
queryDbId = mapping.getQueryDbId(); queryDbId = mapping.getQueryDbId();
...@@ -120,7 +120,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -120,7 +120,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
pageVo.setStart((page - 1) * size); pageVo.setStart((page - 1) * size);
start = (page - 1) * size; start = (page - 1) * size;
} }
Long queryId = Long.valueOf(jsonObject.get("queryId").toString()); Integer queryId = Integer.valueOf(jsonObject.get("queryId").toString());
QueryDb queryDb = queryDbDao.selectById(queryId); QueryDb queryDb = queryDbDao.selectById(queryId);
List<Map> results = null; List<Map> results = null;
List<Map> list = null; List<Map> list = null;
...@@ -138,7 +138,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -138,7 +138,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
return pageVo; return pageVo;
} }
public List<Map> commonQuery(String sql, Long queryId) throws Exception { public List<Map> commonQuery(String sql, Integer queryId) throws Exception {
ResultSet resultSet = null; ResultSet resultSet = null;
try { try {
Connection connection = ConnectionUtil.get(queryId); Connection connection = ConnectionUtil.get(queryId);
...@@ -163,7 +163,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -163,7 +163,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
} }
} }
public Object getTables(Long id) throws Exception { public Object getTables(Integer id) throws Exception {
QueryDb queryDb = queryDbDao.selectById(id); QueryDb queryDb = queryDbDao.selectById(id);
List<Map> results = null; List<Map> results = null;
if (queryDb != null) { if (queryDb != null) {
...@@ -175,7 +175,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -175,7 +175,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object selectTable(Map<String, Object> body) throws Exception { public Object selectTable(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long id = Long.valueOf(jsonObject.get("id").toString()); Integer id = Integer.valueOf(jsonObject.get("id").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String sql="SELECT * FROM "+tableName; String sql="SELECT * FROM "+tableName;
return commonQuery(sql,id); return commonQuery(sql,id);
...@@ -185,7 +185,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -185,7 +185,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//去重 //去重
public Object removeRepeat(Map<String, Object> body) throws Exception { public Object removeRepeat(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String metaData = jsonObject.get("metaData").toString(); String metaData = jsonObject.get("metaData").toString();
String primarySql="SELECT distinct column_name FROM INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` WHERE table_name= '"+tableName+"' AND constraint_name='PRIMARY'"; String primarySql="SELECT distinct column_name FROM INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` WHERE table_name= '"+tableName+"' AND constraint_name='PRIMARY'";
...@@ -207,7 +207,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -207,7 +207,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//身份证清洗 //身份证清洗
public Object identityClean(Map<String, Object> body) throws Exception { public Object identityClean(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String metaData = jsonObject.get("metaData").toString(); String metaData = jsonObject.get("metaData").toString();
String sql="SELECT * FROM " + tableName; String sql="SELECT * FROM " + tableName;
...@@ -228,7 +228,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -228,7 +228,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//字符串替换 //字符串替换
public Object replaceString(Map<String, Object> body) throws Exception { public Object replaceString(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String metaData = jsonObject.get("metaData").toString(); String metaData = jsonObject.get("metaData").toString();
String originStr= jsonObject.get("originStr").toString(); String originStr= jsonObject.get("originStr").toString();
...@@ -243,7 +243,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -243,7 +243,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object SortRecord(Map<String, Object> body) throws Exception { public Object SortRecord(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String metaData = jsonObject.get("metaData").toString(); String metaData = jsonObject.get("metaData").toString();
String sortStr=jsonObject.get("sortStr").toString(); String sortStr=jsonObject.get("sortStr").toString();
...@@ -258,7 +258,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -258,7 +258,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object CutString(Map<String, Object> body) throws Exception { public Object CutString(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String beginStr = jsonObject.get("beginStr").toString(); String beginStr = jsonObject.get("beginStr").toString();
String indexStr = jsonObject.get("indexStr").toString(); String indexStr = jsonObject.get("indexStr").toString();
...@@ -273,7 +273,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo ...@@ -273,7 +273,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object validateNumber(Map<String, Object> body) throws Exception { public Object validateNumber(Map<String, Object> body) throws Exception {
JSONObject jsonObject = JSONUtil.parseObj(body); JSONObject jsonObject = JSONUtil.parseObj(body);
Long datasourceId = Long.valueOf(jsonObject.get("datasourceId").toString()); Integer datasourceId = Integer.valueOf(jsonObject.get("datasourceId").toString());
String tableName = jsonObject.get("tableName").toString(); String tableName = jsonObject.get("tableName").toString();
String metaData = jsonObject.get("metaData").toString(); String metaData = jsonObject.get("metaData").toString();
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
......
...@@ -7,13 +7,13 @@ import java.util.Map; ...@@ -7,13 +7,13 @@ import java.util.Map;
public class ConnectionUtil { public class ConnectionUtil {
private static Map<Long, DruidPooledConnection> connectionMap; private static Map<Integer, DruidPooledConnection> connectionMap;
public static void set(Map<Long, DruidPooledConnection> map) { public static void set(Map<Integer, DruidPooledConnection> map) {
connectionMap = map; connectionMap = map;
} }
public static Connection get(Long id){ public static Connection get(Integer id){
return connectionMap.get(id).getConnection(); return connectionMap.get(id).getConnection();
} }
} }
\ No newline at end of file
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
public class TableUtil { public class TableUtil {
@SneakyThrows @SneakyThrows
public static Object getColumns(Long queryId, String tableName) { public static Object getColumns(Integer queryId, String tableName) {
String driver = "com.mysql.cj.jdbc.Driver"; String driver = "com.mysql.cj.jdbc.Driver";
Class.forName(driver); Class.forName(driver);
Connection connection = ConnectionUtil.get(queryId); Connection connection = ConnectionUtil.get(queryId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment