.
This commit is contained in:
@@ -35,6 +35,18 @@ public class DbExecutors {
|
||||
List<Map> rows = listFuture.get();
|
||||
Integer total = countFuture.get();
|
||||
|
||||
/*rows.forEach(x -> {
|
||||
x.forEach((k,v) -> {
|
||||
if ("[B".equals(v.getClass().getName())) {
|
||||
try {
|
||||
//System.out.println(k + " : " + new String((byte[]) v, "UTF-8"));
|
||||
x.put(k, new String((byte[]) v, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
return PageBean.by(rows, total);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ package net.tccn.base.dbq.jdbc.api;
|
||||
|
||||
import lombok.Data;
|
||||
import net.tccn.base.arango.Doc;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 数据库平台
|
||||
*
|
||||
* @author: liangxianyou at 2018/11/14 12:58.
|
||||
*/
|
||||
@Data
|
||||
@@ -23,6 +25,7 @@ public class DbAccount extends Doc<DbAccount> {
|
||||
private String[] catalogs; //库
|
||||
|
||||
//----------------------------
|
||||
private boolean tmp; // TODO: 处理临时连接对象
|
||||
|
||||
public String accountKey() {
|
||||
int start = url.indexOf("//") + 2;
|
||||
@@ -32,6 +35,11 @@ public class DbAccount extends Doc<DbAccount> {
|
||||
endDef = url.length();
|
||||
}
|
||||
String host = url.substring(start, end == -1 ? url.length() : end);
|
||||
return user + "@" + host;
|
||||
return user + ":" + pwd + "@" + host;
|
||||
}
|
||||
|
||||
@ConvertColumn(ignore = true)
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.tccn.base.dbq.jdbc.api;
|
||||
|
||||
import net.tccn.base.MetaKit;
|
||||
import net.tccn.base.Utils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -9,7 +10,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
* Db 最终执行层
|
||||
* Created by liangxianyou at 2019/3/12 14:11.
|
||||
*/
|
||||
public class DbKit implements DbSource{
|
||||
public class DbKit implements DbSource {
|
||||
|
||||
private DbAccount dbAccount;
|
||||
private DbSource dbSource;
|
||||
@@ -31,6 +32,11 @@ public class DbKit implements DbSource{
|
||||
this.catalog = catalog;
|
||||
|
||||
try {
|
||||
if (Utils.isEmpty(dbAccount.getPwd())) {
|
||||
DbAccount account = MetaKit.getDbPlat(dbAccount.getKey());
|
||||
dbAccount.setPwd(account.getPwd());
|
||||
}
|
||||
|
||||
DbSource dbSource = Utils.getDbSource(DbSource.class, dbAccount.getCate());
|
||||
dbSource.setDbAccount(dbAccount);
|
||||
dbSource.setCatalog(catalog);
|
||||
@@ -87,12 +93,15 @@ public class DbKit implements DbSource{
|
||||
public <T> CompletableFuture<T> findfirstAsync(String sql, Class<T> type) {
|
||||
return CompletableFuture.supplyAsync(() -> findFirst(sql, type));
|
||||
}
|
||||
|
||||
public <T> CompletableFuture<List<T>> findListAsync(String sql, Class<T> type) {
|
||||
return CompletableFuture.supplyAsync(() -> findList(sql, type));
|
||||
}
|
||||
|
||||
public <T> CompletableFuture<T> queryColumnAsync(String sql, Class<T> type) {
|
||||
return CompletableFuture.supplyAsync(() -> findColumn(sql, type));
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> exetuteAsync(String sql) {
|
||||
return CompletableFuture.runAsync(() -> exetute(sql));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user