Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
1c97e5f0
提交
1c97e5f0
authored
4月 07, 2021
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型]补充注释
上级
7dd9b66e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
2 行删除
+11
-2
ModelHelper.java
...kj/workflowcore/model_layer/service/impl/ModelHelper.java
+9
-0
application.yml
src/main/resources/application.yml
+2
-2
没有找到文件。
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelHelper.java
浏览文件 @
1c97e5f0
...
@@ -20,6 +20,9 @@ import java.util.Map;
...
@@ -20,6 +20,9 @@ import java.util.Map;
import
static
java
.
lang
.
String
.
format
;
import
static
java
.
lang
.
String
.
format
;
/**
* @author C
*/
@Service
@Service
public
class
ModelHelper
{
public
class
ModelHelper
{
...
@@ -40,10 +43,12 @@ public class ModelHelper {
...
@@ -40,10 +43,12 @@ public class ModelHelper {
*/
*/
public
String
getJsonExpample
(
Integer
tableInfoId
)
{
public
String
getJsonExpample
(
Integer
tableInfoId
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
//根据表id查出字段信息 并加入Map结果
List
<
ColumnInfo
>
columnInfos
=
columnInfoDao
.
findAllByDbId
(
tableInfoId
);
List
<
ColumnInfo
>
columnInfos
=
columnInfoDao
.
findAllByDbId
(
tableInfoId
);
for
(
ColumnInfo
columnInfo
:
columnInfos
)
{
for
(
ColumnInfo
columnInfo
:
columnInfos
)
{
result
.
put
(
columnInfo
.
getFieldName
(),
null
);
result
.
put
(
columnInfo
.
getFieldName
(),
null
);
}
}
//做json转换并返回
try
{
try
{
return
new
ObjectMapper
().
writeValueAsString
(
result
);
return
new
ObjectMapper
().
writeValueAsString
(
result
);
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
...
@@ -62,10 +67,12 @@ public class ModelHelper {
...
@@ -62,10 +67,12 @@ public class ModelHelper {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
TableInfoEx
tableInfoEX
=
tableInfoExDao
.
findById
(
tableInfoExId
)
TableInfoEx
tableInfoEX
=
tableInfoExDao
.
findById
(
tableInfoExId
)
.
orElseThrow
(()
->
new
ApiException
(
format
(
"未找到该id的数据:%s"
,
tableInfoExId
)));
.
orElseThrow
(()
->
new
ApiException
(
format
(
"未找到该id的数据:%s"
,
tableInfoExId
)));
//根据主表id查出主表部分字段信息 并加入Map结果
List
<
ColumnInfo
>
columnInfos
=
columnInfoDao
.
findAllByDbId
(
tableInfoEX
.
getMainTableId
());
List
<
ColumnInfo
>
columnInfos
=
columnInfoDao
.
findAllByDbId
(
tableInfoEX
.
getMainTableId
());
for
(
ColumnInfo
columnInfo
:
columnInfos
)
{
for
(
ColumnInfo
columnInfo
:
columnInfos
)
{
result
.
put
(
columnInfo
.
getFieldName
(),
null
);
result
.
put
(
columnInfo
.
getFieldName
(),
null
);
}
}
//查出相关聚合信息并做处理
List
<
Aggregation
>
aggregations
=
aggregationDao
.
findAllByTableInfoExId
(
tableInfoExId
);
List
<
Aggregation
>
aggregations
=
aggregationDao
.
findAllByTableInfoExId
(
tableInfoExId
);
for
(
Aggregation
aggregation
:
aggregations
)
{
for
(
Aggregation
aggregation
:
aggregations
)
{
List
<
ColumnInfo
>
subColumnInfos
=
columnInfoDao
.
findAllByDbId
(
aggregation
.
getSideTableId
());
List
<
ColumnInfo
>
subColumnInfos
=
columnInfoDao
.
findAllByDbId
(
aggregation
.
getSideTableId
());
...
@@ -76,6 +83,7 @@ public class ModelHelper {
...
@@ -76,6 +83,7 @@ public class ModelHelper {
String
subTableName
=
tableInfoDao
.
findById
(
aggregation
.
getSideTableId
())
String
subTableName
=
tableInfoDao
.
findById
(
aggregation
.
getSideTableId
())
.
orElseThrow
(()
->
new
RuntimeException
(
format
(
"未找到该id的数据:%s"
,
aggregation
.
getSideTableId
())))
.
orElseThrow
(()
->
new
RuntimeException
(
format
(
"未找到该id的数据:%s"
,
aggregation
.
getSideTableId
())))
.
getModelName
();
.
getModelName
();
//判断关联类型 根据关联类型做不同处理 0:一对一 1:一对多 2:多对多
Integer
relationshipType
=
aggregation
.
getRelationship
();
Integer
relationshipType
=
aggregation
.
getRelationship
();
switch
(
relationshipType
)
{
switch
(
relationshipType
)
{
case
0
:
case
0
:
...
@@ -91,6 +99,7 @@ public class ModelHelper {
...
@@ -91,6 +99,7 @@ public class ModelHelper {
throw
new
ApiException
(
format
(
"未识别的聚合类型:%s"
,
relationshipType
));
throw
new
ApiException
(
format
(
"未识别的聚合类型:%s"
,
relationshipType
));
}
}
}
}
//做json转换并返回
try
{
try
{
return
new
ObjectMapper
().
writeValueAsString
(
result
);
return
new
ObjectMapper
().
writeValueAsString
(
result
);
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
...
...
src/main/resources/application.yml
浏览文件 @
1c97e5f0
spring
:
spring
:
datasource
:
datasource
:
username
:
root
username
:
root
password
:
Huang123+
password
:
123456
url
:
jdbc:mysql://
47.106.142.73:3306/www?useSSL=false&serverTimezone=Asia/Shanghai
&characterEncoding=utf-8&nullCatalogMeansCurrent=true
url
:
jdbc:mysql://
localhost:3306/mydata?useSSL=false&serverTimezone=UTC
&characterEncoding=utf-8&nullCatalogMeansCurrent=true
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jpa
:
jpa
:
show-sql
:
true
show-sql
:
true
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论