提交 1ea17d87 authored 作者: 黄承天's avatar 黄承天

[数据模型]生成示例展示方法修改

上级 dc0c6188
......@@ -42,11 +42,16 @@ public class ModelHelper {
public String getJsonExpample(Integer tableInfoId) {
/* 你要放10个元素,10/0.75+1=14 */
Map<String, Object> result = new HashMap<>();
TableInfo tableInfo = tableInfoDao.findById(tableInfoId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoId)));
String resultKey = tableInfo.getModelName();
Map<String, Object> resultValue = new HashMap<>();
//根据表id查出字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoId);
for (ColumnInfo columnInfo : columnInfos) {
result.put(columnInfo.getFieldName(), null);
resultValue.put(columnInfo.getFieldName(), null);
}
result.put(resultKey, resultValue);
//做json转换并返回
try {
return new ObjectMapper().writeValueAsString(result);
......@@ -66,14 +71,19 @@ public class ModelHelper {
Map<String, Object> result = new HashMap<>();
TableInfo tableInfoEX = tableInfoDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
String resultKey = tableInfoEX.getModelName();
Map<String, Object> resultValue = new HashMap<>();
//根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId());
for (ColumnInfo columnInfo : columnInfos) {
result.put(columnInfo.getFieldName(), null);
resultValue.put(columnInfo.getFieldName(), null);
}
//查出相关聚合信息并做处理
List<Aggregation> aggregations = aggregationDao.findAllByTableInfoExIdAndParentId(tableInfoExId, null);
getSubResult(result, aggregations);
getSubResult(resultValue, aggregations);
result.put(resultKey,resultValue);
//做json转换并返回
try {
return new ObjectMapper().writeValueAsString(result);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论