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

[数据模型]补充注释

上级 7dd9b66e
......@@ -20,6 +20,9 @@ import java.util.Map;
import static java.lang.String.format;
/**
* @author C
*/
@Service
public class ModelHelper {
......@@ -40,10 +43,12 @@ public class ModelHelper {
*/
public String getJsonExpample(Integer tableInfoId) {
Map<String, Object> result = new HashMap<>();
//根据表id查出字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoId);
for (ColumnInfo columnInfo : columnInfos) {
result.put(columnInfo.getFieldName(), null);
}
//做json转换并返回
try {
return new ObjectMapper().writeValueAsString(result);
} catch (JsonProcessingException e) {
......@@ -62,10 +67,12 @@ public class ModelHelper {
Map<String, Object> result = new HashMap<>();
TableInfoEx tableInfoEX = tableInfoExDao.findById(tableInfoExId)
.orElseThrow(() -> new ApiException(format("未找到该id的数据:%s", tableInfoExId)));
//根据主表id查出主表部分字段信息 并加入Map结果
List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfoEX.getMainTableId());
for (ColumnInfo columnInfo : columnInfos) {
result.put(columnInfo.getFieldName(), null);
}
//查出相关聚合信息并做处理
List<Aggregation> aggregations = aggregationDao.findAllByTableInfoExId(tableInfoExId);
for (Aggregation aggregation : aggregations) {
List<ColumnInfo> subColumnInfos = columnInfoDao.findAllByDbId(aggregation.getSideTableId());
......@@ -76,6 +83,7 @@ public class ModelHelper {
String subTableName = tableInfoDao.findById(aggregation.getSideTableId())
.orElseThrow(() -> new RuntimeException(format("未找到该id的数据:%s", aggregation.getSideTableId())))
.getModelName();
//判断关联类型 根据关联类型做不同处理 0:一对一 1:一对多 2:多对多
Integer relationshipType = aggregation.getRelationship();
switch (relationshipType) {
case 0:
......@@ -91,6 +99,7 @@ public class ModelHelper {
throw new ApiException(format("未识别的聚合类型:%s", relationshipType));
}
}
//做json转换并返回
try {
return new ObjectMapper().writeValueAsString(result);
} catch (JsonProcessingException e) {
......
spring:
datasource:
username: root
password: Huang123+
url: jdbc:mysql://47.106.142.73:3306/www?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&nullCatalogMeansCurrent=true
password: 123456
url: jdbc:mysql://localhost:3306/mydata?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8&nullCatalogMeansCurrent=true
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论