.
This commit is contained in:
@@ -213,6 +213,122 @@ public class MetaKit {
|
||||
return cfg;
|
||||
};
|
||||
|
||||
public static Map cfg(String name) {
|
||||
MetaService metaService = getMetaService(name);
|
||||
Kv<String, MetaTable> metaTables = getMetaTables(metaService, false);
|
||||
|
||||
List<String> shows = metaService.getShows();
|
||||
List<Map> edits = metaService.getEdits();
|
||||
List<String> details = metaService.getDetails();
|
||||
List<Map> filters = metaService.getFilters();
|
||||
String comment = metaService.getComment();
|
||||
|
||||
//List<Field> items = new ArrayList<>();
|
||||
Kv<String, Kv<String, Kv>> _items2 = Kv.of();
|
||||
metaTables.forEach((k, v) -> {
|
||||
Kv<String, Kv> _items = Kv.of();
|
||||
v.getItems().forEach(x -> {
|
||||
Kv kv = Kv.of();
|
||||
kv.set("col", x.getName());
|
||||
kv.set("label", x.getLabel());
|
||||
kv.set("InExt", x.getInExt());
|
||||
kv.set("inType", x.getInType());
|
||||
kv.set("expr", x.showField());
|
||||
_items.set(x.getName(), kv);
|
||||
});
|
||||
|
||||
_items2.set(k, _items);
|
||||
});
|
||||
|
||||
//shows
|
||||
List _shows = new ArrayList();
|
||||
shows.forEach(x -> {
|
||||
MetaTable metaTable = metaTables.get(x.split("[.]")[0]); // 表别名
|
||||
metaTable.getItems()
|
||||
.stream()
|
||||
.filter(y -> x.split("[.]")[1].equals(y.getName()))
|
||||
.findFirst().ifPresent(y -> _shows.add(Kv.of("col", x).set("order", true)));
|
||||
});
|
||||
|
||||
//filters
|
||||
List<Map> _filters = new ArrayList<>();
|
||||
filters.forEach(x -> {
|
||||
String col = String.valueOf(x.get("name"));
|
||||
MetaTable metaTable = metaTables.get(col.split("[.]")[0]); // 表别名
|
||||
|
||||
Kv filter = Kv.of();
|
||||
metaTable.getItems()
|
||||
.stream()
|
||||
.filter(y -> col.split("[.]")[1].equals(y.getName()))
|
||||
.findFirst()
|
||||
.ifPresent(y -> {
|
||||
filter.set("name", x.get("name"));
|
||||
filter.set("label", y.getLabel());
|
||||
List<Kv> types = new ArrayList<>();
|
||||
List<String> list = (List) x.get("filterType");
|
||||
list.forEach(t -> {
|
||||
FilterType type = FilterType.getFilterType(t);
|
||||
if (type != null) {
|
||||
types.add(Kv.of("name", t).set("remark", type.getRemark()));
|
||||
}
|
||||
});
|
||||
|
||||
filter.set("filterType", types);
|
||||
if (!types.isEmpty()) {//设置默认查询项
|
||||
filter.set("type", types.get(0).get("name"));
|
||||
}
|
||||
Object checked = x.getOrDefault("checked", false);
|
||||
filter.set("checked", checked instanceof Boolean ? checked : false);
|
||||
});
|
||||
_filters.add(filter);
|
||||
});
|
||||
|
||||
//edits
|
||||
List _edits = new ArrayList();//edits;
|
||||
edits.forEach(x -> {
|
||||
Kv kv = Kv.of();
|
||||
kv.set("col", x);
|
||||
|
||||
String col = x.get("col") + "";
|
||||
//readonly,hidden
|
||||
if ("id".equalsIgnoreCase(col)) {
|
||||
kv.set("upAttr", "hidden");
|
||||
kv.set("addAttr", "none");
|
||||
}
|
||||
if ("reportWay".equalsIgnoreCase(col)) {
|
||||
kv.set("upAttr", "readonly");
|
||||
kv.set("addAttr", "none");
|
||||
}
|
||||
if ("insertTime".equalsIgnoreCase(col)) {
|
||||
kv.set("upAttr", "readonly");
|
||||
kv.set("addAttr", "none");
|
||||
}
|
||||
|
||||
if ("ip".equalsIgnoreCase(col)) {
|
||||
kv.set("ck", "ip");
|
||||
}
|
||||
|
||||
_edits.add(kv);
|
||||
});
|
||||
|
||||
//details
|
||||
List _details = new ArrayList();//details;
|
||||
details.forEach(x -> {
|
||||
Kv kv = Kv.of();
|
||||
kv.set("col", x);
|
||||
|
||||
_details.add(kv);
|
||||
});
|
||||
|
||||
return Kv.of()
|
||||
.set("title", comment)
|
||||
.set("items", _items2)
|
||||
.set("shows", _shows)
|
||||
.set("filters", _filters)
|
||||
.set("edits", _edits)
|
||||
.set("details", _details);
|
||||
}
|
||||
|
||||
//itemUpdate
|
||||
public static BiFunction<MetaTable, List<Field>, MetaTable> itemUpdate = (t, fields) -> {
|
||||
List<Field> items = t.getItems();
|
||||
@@ -276,27 +392,42 @@ public class MetaKit {
|
||||
|
||||
public static Kv buildeDetail(MetaService metaService) {
|
||||
//tables
|
||||
Kv<String, MetaTable> tables = getMetaTables(metaService);
|
||||
Kv<String, MetaTable> tables = getMetaTables(metaService, true);
|
||||
return Kv.of("tables", tables)
|
||||
.set("links", Kv.of());
|
||||
}
|
||||
|
||||
public static Kv<String, MetaTable> getMetaTables(MetaService metaService) {
|
||||
public static Kv<String, MetaTable> getMetaTables(MetaService metaService, Boolean all) {
|
||||
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])
|
||||
);
|
||||
Set<String> allAlias;
|
||||
|
||||
if (!all) {
|
||||
allAlias = UtilityExt.streamConcat(
|
||||
metaService.getFilters().stream().map(f -> {
|
||||
String col = (String) f.get("name");
|
||||
String alias = col.split("[.]")[0];
|
||||
return alias;
|
||||
}),
|
||||
metaService.getExports().stream().map(x -> x.split("[.]")[0]),
|
||||
metaService.getShows().stream().map(x -> x.split("[.]")[0])/*, todo: xxx
|
||||
metaService.getEdits().stream().map(x -> x.split("[.]")[0])*/
|
||||
);
|
||||
|
||||
} else {
|
||||
allAlias = new HashSet<>();
|
||||
metaLinks.stream().forEach(x -> {
|
||||
if (table.equals(x.getTables()[0])) {
|
||||
allAlias.add(x.getTables()[1]);
|
||||
} else if (table.equals(x.getTables()[1])) {
|
||||
allAlias.add(x.getTables()[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
allAlias.forEach(x -> tables.set(x, getMetaTableByAlias(x)));
|
||||
return tables;
|
||||
|
||||
@@ -17,6 +17,7 @@ public class MetaLink extends Doc<MetaLink> {
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
|
||||
public String[] getTables() {
|
||||
return tables;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public class MetaService extends Doc<MetaService> {
|
||||
|
||||
|
||||
private List<String> shows = new ArrayList<>();
|
||||
private List<String> edits = new ArrayList<>();
|
||||
private List<Map> edits = new ArrayList<>();
|
||||
private List<String> details = new ArrayList<>();
|
||||
private List<Map> filters = new ArrayList<>();
|
||||
private List<String> exports = new ArrayList<>();
|
||||
|
||||
@@ -71,14 +72,22 @@ public class MetaService extends Doc<MetaService> {
|
||||
this.shows = shows;
|
||||
}
|
||||
|
||||
public List<String> getEdits() {
|
||||
public List<Map> getEdits() {
|
||||
return edits;
|
||||
}
|
||||
|
||||
public void setEdits(List<String> edits) {
|
||||
public void setEdits(List<Map> edits) {
|
||||
this.edits = edits;
|
||||
}
|
||||
|
||||
public List<String> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public List<Map> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user