Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow2
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow2
Commits
fbb36ba4
提交
fbb36ba4
authored
8月 27, 2021
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[模型模块]新增根据processKey查询接口
上级
b67a2fe1
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
106 行增加
和
19 行删除
+106
-19
TableInfoController.java
...kj/workflowcore/model/controller/TableInfoController.java
+7
-8
TableInfoExController.java
.../workflowcore/model/controller/TableInfoExController.java
+24
-8
TableInfoEx.java
.../java/com/tykj/workflowcore/model/entity/TableInfoEx.java
+1
-0
TableInfoExRepository.java
.../workflowcore/model/repository/TableInfoExRepository.java
+2
-0
TableInfoRepository.java
...kj/workflowcore/model/repository/TableInfoRepository.java
+2
-0
TableInfoExService.java
...m/tykj/workflowcore/model/service/TableInfoExService.java
+63
-0
TableInfoService.java
...com/tykj/workflowcore/model/service/TableInfoService.java
+7
-3
没有找到文件。
src/main/java/com/tykj/workflowcore/model/controller/TableInfoController.java
浏览文件 @
fbb36ba4
package
com
.
tykj
.
workflowcore
.
model
.
controller
;
import
com.tykj.workflowcore.base.result.ResultObj
;
import
com.tykj.workflowcore.base.result.ResultUtil
;
import
com.google.common.collect.ImmutableMap
;
import
com.tykj.workflowcore.model.entity.TableInfo
;
import
com.tykj.workflowcore.model.service.TableInfoService
;
import
io.swagger.annotations.Api
;
...
...
@@ -23,23 +22,23 @@ public class TableInfoController {
@ApiOperation
(
value
=
"新增基础模型"
)
@PostMapping
public
ResponseEntity
save
(
@RequestBody
TableInfo
tableInfo
){
public
ResponseEntity
save
(
@RequestBody
TableInfo
tableInfo
)
{
tableInfoService
.
save
(
tableInfo
);
return
ResponseEntity
.
ok
(
"新增成功"
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"message"
,
"新增成功"
)
);
}
@ApiOperation
(
value
=
"修改基础模型"
)
@PutMapping
public
ResponseEntity
update
(
@RequestBody
TableInfo
tableInfo
){
public
ResponseEntity
update
(
@RequestBody
TableInfo
tableInfo
)
{
tableInfoService
.
update
(
tableInfo
);
return
ResponseEntity
.
ok
(
"修改成功"
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"message"
,
"修改成功"
)
);
}
@ApiOperation
(
value
=
"查询所有基础模型"
)
@GetMapping
public
ResponseEntity
<
List
<
TableInfo
>>
findAll
()
{
public
ResponseEntity
findAll
()
{
List
<
TableInfo
>
tableInfos
=
tableInfoService
.
findAll
();
return
ResponseEntity
.
ok
(
tableInfos
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"data"
,
tableInfos
)
);
}
}
src/main/java/com/tykj/workflowcore/model/controller/TableInfoExController.java
浏览文件 @
fbb36ba4
package
com
.
tykj
.
workflowcore
.
model
.
controller
;
import
com.google.common.collect.ImmutableMap
;
import
com.tykj.workflowcore.model.entity.TableInfoEx
;
import
com.tykj.workflowcore.model.service.TableInfoExService
;
import
io.swagger.annotations.Api
;
...
...
@@ -9,10 +10,11 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
@Api
(
tags
=
"聚合模型接口"
)
@CrossOrigin
@RequestMapping
(
"/tableinfoex"
)
@RequestMapping
(
"/tableinfo
/
ex"
)
@RestController
public
class
TableInfoExController
{
...
...
@@ -21,23 +23,37 @@ public class TableInfoExController {
@ApiOperation
(
value
=
"新增聚合模型"
)
@PostMapping
public
ResponseEntity
save
(
@RequestBody
TableInfoEx
tableInfoEx
){
public
ResponseEntity
save
(
@RequestBody
TableInfoEx
tableInfoEx
)
{
tableInfoExService
.
save
(
tableInfoEx
);
return
ResponseEntity
.
ok
(
"新增成功"
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"message"
,
"新增成功"
)
);
}
@ApiOperation
(
value
=
"修改聚合模型"
)
@PutMapping
public
ResponseEntity
update
(
@RequestBody
TableInfoEx
tableInfoEx
){
public
ResponseEntity
update
(
@RequestBody
TableInfoEx
tableInfoEx
)
{
tableInfoExService
.
update
(
tableInfoEx
);
return
ResponseEntity
.
ok
(
"修改成功"
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"message"
,
"修改成功"
)
);
}
@ApiOperation
(
value
=
"查询所有聚合模型"
)
@GetMapping
public
ResponseEntity
<
List
<
TableInfoEx
>>
findAll
(){
List
<
TableInfoEx
>
tableInfos
=
tableInfoExService
.
findAll
();
return
ResponseEntity
.
ok
(
tableInfos
);
public
ResponseEntity
findAll
()
{
List
<
TableInfoEx
>
tableInfoExes
=
tableInfoExService
.
findAll
();
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"data"
,
tableInfoExes
));
}
@ApiOperation
(
value
=
"根据process查询"
)
@GetMapping
(
"/processKey/{processKey}"
)
public
ResponseEntity
findByProcessKey
(
@PathVariable
String
processKey
)
{
List
<
TableInfoEx
>
tableInfoExes
=
tableInfoExService
.
findByProcessKey
(
processKey
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"data"
,
tableInfoExes
));
}
@ApiOperation
(
value
=
"根据process查询 以Json形式返回"
)
@GetMapping
(
"/processKey/json/{processKey}"
)
public
ResponseEntity
findByProcessKeyInMap
(
@PathVariable
String
processKey
)
{
List
<
Map
<
String
,
Map
<
String
,
Object
>>>
tableInfoExes
=
tableInfoExService
.
findByProcessKeyInMap
(
processKey
);
return
ResponseEntity
.
ok
(
ImmutableMap
.
of
(
"data"
,
tableInfoExes
));
}
}
src/main/java/com/tykj/workflowcore/model/entity/TableInfoEx.java
浏览文件 @
fbb36ba4
...
...
@@ -51,4 +51,5 @@ public class TableInfoEx {
@ApiModelProperty
(
value
=
"绑定信息"
,
position
=
5
)
@Transient
private
List
<
Bind
>
binds
;
}
src/main/java/com/tykj/workflowcore/model/repository/TableInfoExRepository.java
浏览文件 @
fbb36ba4
...
...
@@ -13,4 +13,6 @@ public interface TableInfoExRepository extends JpaRepository<TableInfoEx, Intege
List
<
TableInfoEx
>
findByName
(
String
name
);
List
<
TableInfoEx
>
findByProcessKey
(
String
processKey
);
}
src/main/java/com/tykj/workflowcore/model/repository/TableInfoRepository.java
浏览文件 @
fbb36ba4
...
...
@@ -10,6 +10,8 @@ public interface TableInfoRepository extends JpaRepository<TableInfo, Integer> {
Integer
countByName
(
String
name
);
TableInfo
findByNameAndVersion
(
String
name
,
Integer
version
);
void
deleteAllByName
(
String
name
);
void
deleteAllByNameAndVersion
(
String
name
,
Integer
version
);
...
...
src/main/java/com/tykj/workflowcore/model/service/TableInfoExService.java
浏览文件 @
fbb36ba4
package
com
.
tykj
.
workflowcore
.
model
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.ImmutableMap
;
import
com.tykj.workflowcore.model.entity.Bind
;
import
com.tykj.workflowcore.model.entity.ColumnInfo
;
import
com.tykj.workflowcore.model.entity.TableInfo
;
import
com.tykj.workflowcore.model.entity.TableInfoEx
;
import
com.tykj.workflowcore.model.repository.BindRepository
;
import
com.tykj.workflowcore.model.repository.TableInfoExRepository
;
import
com.tykj.workflowcore.model.repository.TableInfoRepository
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,6 +29,8 @@ public class TableInfoExService {
TableInfoRepository
tableInfoRepository
;
@Autowired
BindRepository
bindRepository
;
@Autowired
TableInfoService
tableInfoService
;
public
void
save
(
TableInfoEx
tableInfoEx
)
{
//数据检查
...
...
@@ -76,6 +83,30 @@ public class TableInfoExService {
.
collect
(
Collectors
.
toList
());
}
public
List
<
TableInfoEx
>
findByProcessKey
(
String
processKey
)
{
return
tableInfoExRepository
.
findByProcessKey
(
processKey
).
stream
()
.
map
(
this
::
getBinds
)
.
collect
(
Collectors
.
toList
());
}
public
List
<
Map
<
String
,
Map
<
String
,
Object
>>>
findByProcessKeyInMap
(
String
processKey
)
{
return
tableInfoExRepository
.
findByProcessKey
(
processKey
).
stream
()
.
map
(
TableInfoEx:
:
getName
)
.
distinct
()
.
map
(
name
->
ImmutableMap
.
of
(
name
,
findByNameInMap
(
name
)))
.
collect
(
Collectors
.
toList
());
}
public
String
findByNameInJson
(
String
name
)
{
Map
<
String
,
Object
>
result
=
findByNameInMap
(
name
);
try
{
return
new
ObjectMapper
().
writeValueAsString
(
result
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
return
"{}"
;
}
}
public
void
updateRelatedTableInfoEx
(
TableInfo
tableInfo
)
{
List
<
String
>
names
=
bindRepository
.
findByName
(
tableInfo
.
getName
()).
stream
()
.
map
(
Bind:
:
getTableInfoExId
)
...
...
@@ -104,6 +135,19 @@ public class TableInfoExService {
//-----------------------------------------------------------------------------//
private
Map
<
String
,
Object
>
findByNameInMap
(
String
name
)
{
TableInfoEx
tableInfoEx
=
tableInfoExRepository
.
findByName
(
name
).
stream
()
.
max
(
Comparator
.
comparingInt
(
TableInfoEx:
:
getVersion
))
.
map
(
this
::
getBinds
)
.
orElseThrow
(()
->
new
RuntimeException
(
"查询数据失败"
));
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
for
(
Bind
bind
:
tableInfoEx
.
getBinds
())
{
Map
<
String
,
Object
>
map
=
bindToMap
(
bind
);
result
.
put
(
bind
.
getName
(),
map
);
}
return
result
;
}
private
List
<
Bind
>
newBinds
(
List
<
Bind
>
binds
,
TableInfo
tableInfo
)
{
List
<
Bind
>
newBinds
=
new
ArrayList
<>();
for
(
Bind
bind
:
binds
)
{
...
...
@@ -156,4 +200,23 @@ public class TableInfoExService {
return
bind
;
}
private
Map
<
String
,
Object
>
bindToMap
(
Bind
bind
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
TableInfo
tableInfo
=
tableInfoService
.
findByNameAndVersion
(
bind
.
getName
(),
bind
.
getVersion
());
if
(
nonNull
(
tableInfo
))
{
List
<
ColumnInfo
>
columnInfos
=
tableInfo
.
getColumnInfos
();
for
(
ColumnInfo
columnInfo
:
columnInfos
)
{
result
.
put
(
columnInfo
.
getName
(),
Strings
.
EMPTY
);
}
if
(
hasChildren
(
bind
))
{
for
(
Bind
child
:
bind
.
getChildren
())
{
Map
<
String
,
Object
>
childMap
=
bindToMap
(
child
);
result
.
put
(
child
.
getName
(),
childMap
);
}
}
}
return
result
;
}
}
src/main/java/com/tykj/workflowcore/model/service/TableInfoService.java
浏览文件 @
fbb36ba4
...
...
@@ -12,6 +12,7 @@ import java.util.Date;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
Objects
.
isNull
;
import
static
java
.
util
.
Objects
.
nonNull
;
@SuppressWarnings
(
"Duplicates"
)
...
...
@@ -73,9 +74,12 @@ public class TableInfoService {
tableInfoExService
.
updateRelatedTableInfoEx
(
tableInfo
);
}
public
TableInfo
findById
(
Integer
id
)
{
TableInfo
tableInfo
=
tableInfoRepository
.
findById
(
id
).
orElseThrow
(()
->
new
RuntimeException
(
"该模型不存在"
));
List
<
ColumnInfo
>
columnInfos
=
columnInfoRepository
.
findByTableInfoId
(
id
);
public
TableInfo
findByNameAndVersion
(
String
name
,
Integer
version
)
{
TableInfo
tableInfo
=
tableInfoRepository
.
findByNameAndVersion
(
name
,
version
);
if
(
isNull
(
tableInfo
))
{
throw
new
RuntimeException
(
"该模型不存在"
);
}
List
<
ColumnInfo
>
columnInfos
=
columnInfoRepository
.
findByTableInfoId
(
tableInfo
.
getId
());
tableInfo
.
setColumnInfos
(
columnInfos
);
return
tableInfo
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论