'多表支持修改,完成1、列表配置,2、查询配置,3、导出配置'

This commit is contained in:
2019-03-29 16:07:43 +08:00
parent 49be875e5d
commit 3df7e52e61
13 changed files with 579 additions and 310 deletions

View File

@@ -1,16 +1,12 @@
package net.tccn.meta;
import net.tccn.base.Kv;
import net.tccn.dbq.jdbc.api.DbAccount;
import net.tccn.base.UtilityExt;
import net.tccn.dbq.Field;
import net.tccn.dbq.fbean.FilterType;
import net.tccn.dbq.jdbc.api.DbAccount;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -111,7 +107,7 @@ public class MetaKit {
* @param name
* @return
*/
public static MetaService metaService(String name) {
public static MetaService getMetaService(String name) {
Optional<MetaService> service = metaServices.stream().filter(x -> x.getName().equals(name)).findAny();
//处理业务逻辑
service.ifPresent(x -> {
@@ -168,7 +164,7 @@ public class MetaKit {
Field field = getField.apply(x);
if (field != null) {
Kv col = Kv.of();
col.set("col", x.split("[.]]")[0] + field.showField());//a.createtime=dt
col.set("col", x.split("$]")[0] + field.showField());//a.createtime=dt
col.set("label", field.getLabel());
col.set("order", 1);//dev 是否支持排序
_cols.add(col);
@@ -233,7 +229,7 @@ public class MetaKit {
//showUpdate
public static BiFunction<String, List<String>, MetaService> showUpdate = (serviceKey, shows) -> {
MetaService metaService = metaService(serviceKey);
MetaService metaService = getMetaService(serviceKey);
MetaService _metaService = MetaService.dao.findByKey(metaService.getKey());
_metaService.setShows(shows);
@@ -277,4 +273,51 @@ public class MetaKit {
.collect(Collectors.toList());
return links;
}
public static Kv buildeDetail(MetaService metaService) {
//tables
Kv<String, MetaTable> tables = getMetaTables(metaService);
return Kv.of("tables", tables)
.set("links", Kv.of());
}
public static Kv<String, MetaTable> getMetaTables(MetaService metaService) {
Kv<String, MetaTable> tables = Kv.of();
String table = metaService.getTable();//
tables.set(table, getMetaTableByAlias(table));
//收集所有的col
Set<String> allAlias = UtilityExt.streamConcat(
metaService.getFilters().stream().map(f -> {
String col = (String) f.get("name");
String alias = col.split("[.]")[0];
return alias;
}),
metaService.getShows().stream().map(x -> x.split("[.]")[0]),
metaService.getEdits().stream().map(x -> x.split("[.]")[0])
);
allAlias.forEach(x -> tables.set(x, getMetaTableByAlias(x)));
return tables;
}
public String nextAlias(String x) {
return next(x, "");
}
//使用['a',...,'z'] 创建Table 别名
private String next(String x, String end) {
if (x == null || "".equals(x)) {
return "a" + end;
}
char c = x.charAt(x.length() - 1);
String sub = x.substring(0, x.length() - 1);
if (c < 'z') {
return sub + (++c) + end;
} else if (c == 'z') {
return next(sub, "a" + end);
}
return null;
}
}

View File

@@ -1,5 +1,6 @@
package net.tccn.meta;
import net.tccn.base.Kv;
import net.tccn.base.arango.Doc;
import javax.persistence.Table;
@@ -23,6 +24,7 @@ public class MetaService extends Doc<MetaService> {
private List<String> shows = new ArrayList<>();
private List<String> edits = new ArrayList<>();
private List<Map> filters = new ArrayList<>();
private List<String> exports = new ArrayList<>();
//待组装数据
//private MetaTable metaTable;
@@ -86,6 +88,14 @@ public class MetaService extends Doc<MetaService> {
this.filters = filters;
}
public List<String> getExports() {
return exports;
}
public void setExports(List<String> exports) {
this.exports = exports;
}
/*public MetaTable getMetaTable() {
return metaTable;
}