This commit is contained in:
2019-04-23 15:47:08 +08:00
parent e5a4451a7e
commit 8a03b03888
9 changed files with 119 additions and 74 deletions

View File

@@ -109,6 +109,14 @@ public class MetaKit {
return table.orElse(null);
}
public static MetaTable getMetaTable(String name, String token) {
Optional<MetaTable> any = getMetaTables().stream().filter(x -> {
return x.getName().equals(name) && x.getSysPlatId().equals(getPlatId(token));
}).findAny();
return any.get();
}
/**
* 通过 MetaLink[] 得到 MetaTable{}
* @param links
@@ -140,7 +148,7 @@ public class MetaKit {
* @param name
* @return
*/
public static MetaService getMetaService(String name) {
public static MetaService getMetaService(String name, String token) {
Optional<MetaService> service = metaServices.stream().filter(x -> x.getName().equals(name)).findAny();
//处理业务逻辑
service.ifPresent(x -> {
@@ -246,8 +254,8 @@ public class MetaKit {
return cfg;
};
public static Map cfg(String name) {
MetaService metaService = getMetaService(name);
public static Map cfg(String name, String token) {
MetaService metaService = getMetaService(name, token);
Kv<String, MetaTable> metaTables = getMetaTables(metaService, false);
List<String> shows = metaService.getShows();
@@ -362,6 +370,30 @@ public class MetaKit {
.set("details", _details);
}
@Comment("业务导出表头配置")
public Kv cfgExport(String name, String token) {
MetaService metaService = getMetaService(name, token);
Kv<String, MetaTable> tables = getMetaTables(metaService, true);
List<String> exports = metaService.getExports();
Kv kv = Kv.of();
//从 meta-table 中得到字段label
exports.forEach(x -> {
try {
String[] arr = x.split("[.]");
MetaTable table = tables.get(arr[0]);
Optional<Field> any = table.getItems().stream().filter(y -> y.getName().equals(arr[1])).findAny();
Field field = any.get();
kv.put(x, field.getLabel());
} catch (Exception e) {
new IllegalArgumentException(String.format("字段信息处理异常:[%s]", x), e);
}
});
return kv;
}
//itemUpdate
public static BiFunction<MetaTable, List<Field>, MetaTable> itemUpdate = (t, fields) -> {
List<Field> items = t.getItems();
@@ -376,9 +408,9 @@ public class MetaKit {
};
//showUpdate
public static BiFunction<String, List<String>, MetaService> showUpdate = (serviceKey, shows) -> {
/*public static BiFunction<String, List<String>, MetaService> showUpdate = (name, shows) -> {
MetaService metaService = getMetaService(serviceKey);
MetaService metaService = getMetaService(name, "");
MetaService _metaService = MetaService.dao.findByKey(metaService.getKey());
_metaService.setShows(shows);
@@ -386,7 +418,7 @@ public class MetaKit {
metaService.setShows(shows);//更新缓存
return metaService;
};
};*/
public static MetaTable getMetaTableByKey(String key) {