.
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
package net.tccn.dbq;
|
||||
|
||||
import net.tccn.base.Kv;
|
||||
import net.tccn.base.PageBean;
|
||||
import net.tccn.dbq.fbean.FBean;
|
||||
import net.tccn.dbq.jdbc.api.DbAccount;
|
||||
import net.tccn.dbq.jdbc.api.DbKit;
|
||||
import net.tccn.dbq.parser.ParseMysql;
|
||||
import net.tccn.dbq.parser.Parser;
|
||||
import net.tccn.meta.MetaKit;
|
||||
import net.tccn.meta.MetaService;
|
||||
import net.tccn.meta.MetaTable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DbExecutors {
|
||||
private final static Parser PARSER = new ParseMysql();
|
||||
@@ -15,8 +20,20 @@ public class DbExecutors {
|
||||
|
||||
String[] sqls = PARSER.parse(fBean);
|
||||
|
||||
//当前的业务 => 获取主表 信息 => 数据源信息 => 数据源对象 => 创建数据工具对象 => 查询数据
|
||||
MetaService metaService = MetaKit.getMetaService(fBean.getName());
|
||||
|
||||
MetaTable mainTable = MetaKit.getMetaTableByAlias(metaService.getTable());
|
||||
|
||||
return PageBean.by(Arrays.asList(Kv.of("findSql:", sqls[0]).set("countSql", sqls[1]) ), 0);
|
||||
DbAccount dbAccount = DbAccount.dao.findByKey(mainTable.getDbPlatId());
|
||||
|
||||
DbKit dbKit = new DbKit(dbAccount);
|
||||
System.out.println("countSql: " + sqls[0]);
|
||||
System.out.println("findSql: " + sqls[1]);
|
||||
|
||||
Integer count = dbKit.queryColumn(sqls[0], int.class);
|
||||
List<Map> list = dbKit.findList(sqls[1], Map.class);
|
||||
|
||||
return PageBean.by(list, count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,17 +42,18 @@ public class DbSourceMysql implements DbSource {
|
||||
Map row = new HashMap();
|
||||
for (int i = 1; i <= count; i++) {
|
||||
String columnTypeName = metaData.getColumnTypeName(i);
|
||||
String columnName = metaData.getColumnName(i);
|
||||
row.put(columnName, null);
|
||||
//String columnName = metaData.getColumnName(i);
|
||||
String columnLabel = metaData.getColumnLabel(i);
|
||||
row.put(columnLabel, null);
|
||||
|
||||
if (rs.getObject(i) != null) {
|
||||
switch (columnTypeName) {
|
||||
case "DATETIME":
|
||||
case "TIMESTAMP":
|
||||
case "DATE":
|
||||
row.put(columnName, rs.getTimestamp(i).getTime()); break;
|
||||
row.put(columnLabel, rs.getTimestamp(i).getTime()); break;
|
||||
default:
|
||||
row.put(columnName, rs.getObject(i));
|
||||
row.put(columnLabel, rs.getObject(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ParseMysql implements Parser {
|
||||
if (!isEmpty.test(shows)) {
|
||||
shows.forEach(x -> {
|
||||
//buf.append("`").append("x").append("`").append(",");
|
||||
bufSelect.append(x).append(",");
|
||||
bufSelect.append(x).append(" as ").append("'").append(x.replace(".", "\\.")).append("',");
|
||||
});
|
||||
bufSelect.deleteCharAt(bufSelect.length() - 1);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user