Commit 7e1db985 by ljb

QueryDb id改为整形

parent 1f5df8c9
......@@ -35,7 +35,7 @@ public class CommonQueryController {
@ApiOperation("获取全部数据源")
@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));
}
......@@ -119,7 +119,7 @@ public class CommonQueryController {
AssertUtils.notNull(id, "缺失ID");
Object tableName = body.get("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("查询表内容")
......
......@@ -68,7 +68,7 @@ public class MetaDataMapping {
/**
* 查询数据源id
*/
private Long queryDbId;
private Integer queryDbId;
/**
* createTime
......
......@@ -17,7 +17,7 @@ public class QueryDb {
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
private Integer id;
/**
* 数据库名称
......
......@@ -26,7 +26,7 @@ public class DatabaseRunner implements ApplicationRunner {
@Resource
private CommonQueryService service;
private Map<Long, DruidPooledConnection> connectionMap = new HashMap<>();
private Map<Integer, DruidPooledConnection> connectionMap = new HashMap<>();
@Override
public void run(ApplicationArguments args) throws SQLException {
......
......@@ -97,7 +97,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
Long id = Long.valueOf(jsonObject.get("id").toString());
List<MetaDataMapping> list = metaDataMappingDao.selectByCateId(id);
String tableSqlname = null;
Long queryDbId = null;
Integer queryDbId = null;
for (MetaDataMapping mapping : list) {
tableSqlname = mapping.getTableSqlname();
queryDbId = mapping.getQueryDbId();
......@@ -120,7 +120,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
pageVo.setStart((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);
List<Map> results = null;
List<Map> list = null;
......@@ -138,7 +138,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
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;
try {
Connection connection = ConnectionUtil.get(queryId);
......@@ -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);
List<Map> results = null;
if (queryDb != null) {
......@@ -175,7 +175,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object selectTable(Map<String, Object> body) throws Exception {
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 sql="SELECT * FROM "+tableName;
return commonQuery(sql,id);
......@@ -185,7 +185,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//去重
public Object removeRepeat(Map<String, Object> body) throws Exception {
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 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'";
......@@ -207,7 +207,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//身份证清洗
public Object identityClean(Map<String, Object> body) throws Exception {
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 metaData = jsonObject.get("metaData").toString();
String sql="SELECT * FROM " + tableName;
......@@ -228,7 +228,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
//字符串替换
public Object replaceString(Map<String, Object> body) throws Exception {
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 metaData = jsonObject.get("metaData").toString();
String originStr= jsonObject.get("originStr").toString();
......@@ -243,7 +243,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object SortRecord(Map<String, Object> body) throws Exception {
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 metaData = jsonObject.get("metaData").toString();
String sortStr=jsonObject.get("sortStr").toString();
......@@ -258,7 +258,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object CutString(Map<String, Object> body) throws Exception {
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 beginStr = jsonObject.get("beginStr").toString();
String indexStr = jsonObject.get("indexStr").toString();
......@@ -273,7 +273,7 @@ public class CommonQueryService extends ServiceImpl<CommonQuerySettingDao, Commo
public Object validateNumber(Map<String, Object> body) throws Exception {
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 metaData = jsonObject.get("metaData").toString();
HashMap<String, Object> map = new HashMap<>();
......
......@@ -7,13 +7,13 @@ import java.util.Map;
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;
}
public static Connection get(Long id){
public static Connection get(Integer id){
return connectionMap.get(id).getConnection();
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ import java.util.List;
public class TableUtil {
@SneakyThrows
public static Object getColumns(Long queryId, String tableName) {
public static Object getColumns(Integer queryId, String tableName) {
String driver = "com.mysql.cj.jdbc.Driver";
Class.forName(driver);
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