Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow2
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow2
Commits
400de769
提交
400de769
authored
8月 11, 2021
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[对象模块]基础对象、聚合对象的新增、修改完成
上级
32ab4f0b
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
515 行增加
和
0 行删除
+515
-0
Bind.java
src/main/java/com/tykj/workflowcore/model/entity/Bind.java
+44
-0
ColumnInfo.java
...n/java/com/tykj/workflowcore/model/entity/ColumnInfo.java
+46
-0
TableInfo.java
...in/java/com/tykj/workflowcore/model/entity/TableInfo.java
+60
-0
TableInfoEx.java
.../java/com/tykj/workflowcore/model/entity/TableInfoEx.java
+49
-0
BindRepository.java
...om/tykj/workflowcore/model/repository/BindRepository.java
+16
-0
ColumnInfoRepository.java
...j/workflowcore/model/repository/ColumnInfoRepository.java
+10
-0
TableInfoExRepository.java
.../workflowcore/model/repository/TableInfoExRepository.java
+16
-0
TableInfoRepository.java
...kj/workflowcore/model/repository/TableInfoRepository.java
+17
-0
TableInfoExService.java
...m/tykj/workflowcore/model/service/TableInfoExService.java
+159
-0
TableInfoService.java
...com/tykj/workflowcore/model/service/TableInfoService.java
+98
-0
没有找到文件。
src/main/java/com/tykj/workflowcore/model/entity/Bind.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
import
java.util.List
;
@Accessors
(
chain
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public
class
Bind
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
/**
* 是否为复数(List)
*/
private
Boolean
isComplex
;
/**
* 绑定的TableInfo的name
*/
private
String
name
;
private
Integer
version
;
@JsonIgnore
private
Integer
tableInfoExId
;
@JsonIgnore
private
Integer
parentId
;
@Transient
private
List
<
Bind
>
children
;
}
src/main/java/com/tykj/workflowcore/model/entity/ColumnInfo.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
@Accessors
(
chain
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public
class
ColumnInfo
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
@JsonIgnore
private
Integer
id
;
//-----------------------------//
@ApiModelProperty
(
"是否是主键"
)
private
Boolean
isPrimary
;
@ApiModelProperty
(
"列名"
)
private
String
name
;
@ApiModelProperty
(
"列类型"
)
private
String
type
;
@ApiModelProperty
(
"长度"
)
private
Integer
length
;
@ApiModelProperty
(
"所属表id"
)
private
Integer
tableInfoId
;
@ApiModelProperty
(
"描述"
)
private
String
description
;
}
src/main/java/com/tykj/workflowcore/model/entity/TableInfo.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
import
java.util.Date
;
import
java.util.List
;
@Accessors
(
chain
=
true
)
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public
class
TableInfo
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"创建时间"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd hh:mm"
)
@JsonIgnore
private
Date
createdTime
;
@ApiModelProperty
(
"修改时间"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd hh:mm"
)
@JsonIgnore
private
Date
updatedTime
;
//------------------------------//
@ApiModelProperty
(
"表名,不能为空"
)
@Column
(
nullable
=
false
)
private
String
name
;
@ApiModelProperty
(
"描述"
)
private
String
description
;
@ApiModelProperty
(
"工作流预留字段"
)
private
String
processKey
;
@ApiModelProperty
(
"版本号"
)
private
Integer
version
;
@Transient
@ApiModelProperty
(
"字段信息"
)
private
List
<
ColumnInfo
>
columnInfos
;
}
src/main/java/com/tykj/workflowcore/model/entity/TableInfoEx.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
import
java.util.Date
;
import
java.util.List
;
@Accessors
(
chain
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public
class
TableInfoEx
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"创建时间"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd hh:mm"
)
@JsonIgnore
private
Date
createdTime
;
@ApiModelProperty
(
"修改时间"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd hh:mm"
)
@JsonIgnore
private
Date
updatedTime
;
private
String
name
;
private
String
description
;
private
String
processKey
;
private
Integer
version
;
@Transient
private
List
<
Bind
>
binds
;
}
src/main/java/com/tykj/workflowcore/model/repository/BindRepository.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
repository
;
import
com.tykj.workflowcore.model.entity.Bind
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
BindRepository
extends
JpaRepository
<
Bind
,
Integer
>
{
List
<
Bind
>
findByTableInfoExId
(
Integer
tableInfoExId
);
List
<
Bind
>
findByTableInfoExIdAndParentId
(
Integer
tableInfoExId
,
Integer
parentId
);
List
<
Bind
>
findByName
(
String
name
);
}
src/main/java/com/tykj/workflowcore/model/repository/ColumnInfoRepository.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
repository
;
import
com.tykj.workflowcore.model.entity.ColumnInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
ColumnInfoRepository
extends
JpaRepository
<
ColumnInfo
,
Integer
>
{
List
<
ColumnInfo
>
findByTableInfoId
(
Integer
tableInfoId
);
}
src/main/java/com/tykj/workflowcore/model/repository/TableInfoExRepository.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
repository
;
import
com.tykj.workflowcore.model.entity.TableInfoEx
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
TableInfoExRepository
extends
JpaRepository
<
TableInfoEx
,
Integer
>
{
boolean
existsByName
(
String
name
);
Integer
countByName
(
String
name
);
List
<
TableInfoEx
>
findByName
(
String
name
);
}
src/main/java/com/tykj/workflowcore/model/repository/TableInfoRepository.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
repository
;
import
com.tykj.workflowcore.model.entity.TableInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
TableInfoRepository
extends
JpaRepository
<
TableInfo
,
Integer
>
{
boolean
existsByName
(
String
name
);
Integer
countByName
(
String
name
);
void
deleteAllByName
(
String
name
);
void
deleteAllByNameAndVersion
(
String
name
,
Integer
version
);
}
src/main/java/com/tykj/workflowcore/model/service/TableInfoExService.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
service
;
import
com.tykj.workflowcore.model.entity.Bind
;
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.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
Objects
.
nonNull
;
@SuppressWarnings
(
"Duplicates"
)
@Service
public
class
TableInfoExService
{
@Autowired
TableInfoExRepository
tableInfoExRepository
;
@Autowired
TableInfoRepository
tableInfoRepository
;
@Autowired
BindRepository
bindRepository
;
public
void
save
(
TableInfoEx
tableInfoEx
)
{
//数据检查
boolean
exists
=
tableInfoExRepository
.
existsByName
(
tableInfoEx
.
getName
());
if
(
exists
)
{
throw
new
RuntimeException
(
"该模型已存在"
);
}
if
(
nonNull
(
tableInfoEx
.
getId
()))
{
throw
new
RuntimeException
(
"新增操作不可附带id"
);
}
//设置时间
Date
date
=
new
Date
();
tableInfoEx
.
setCreatedTime
(
date
);
tableInfoEx
.
setUpdatedTime
(
date
);
//设置版本号
tableInfoEx
.
setVersion
(
1
);
//保存数据
Integer
id
=
tableInfoExRepository
.
save
(
tableInfoEx
).
getId
();
if
(
nonNull
(
tableInfoEx
.
getBinds
()))
{
tableInfoEx
.
getBinds
().
forEach
(
bind
->
save
(
bind
,
id
));
}
}
public
void
update
(
TableInfoEx
tableInfoEx
)
{
//数据检查
boolean
exists
=
tableInfoExRepository
.
existsByName
(
tableInfoEx
.
getName
());
if
(!
exists
)
{
throw
new
RuntimeException
(
"该模型不存在"
);
}
if
(
nonNull
(
tableInfoEx
.
getId
()))
{
throw
new
RuntimeException
(
"修改操作不可附带id"
);
}
Integer
count
=
tableInfoExRepository
.
countByName
(
tableInfoEx
.
getName
());
//设置时间
Date
date
=
new
Date
();
tableInfoEx
.
setCreatedTime
(
date
);
tableInfoEx
.
setUpdatedTime
(
date
);
tableInfoEx
.
setVersion
(
count
+
1
);
//保存数据
Integer
id
=
tableInfoExRepository
.
save
(
tableInfoEx
).
getId
();
if
(
nonNull
(
tableInfoEx
.
getBinds
()))
{
tableInfoEx
.
getBinds
().
forEach
(
bind
->
save
(
bind
,
id
));
}
}
public
List
<
TableInfoEx
>
findAll
()
{
return
tableInfoExRepository
.
findAll
().
stream
()
.
map
(
this
::
getBinds
)
.
collect
(
Collectors
.
toList
());
}
public
void
updateRelatedTableInfoEx
(
TableInfo
tableInfo
)
{
List
<
String
>
names
=
bindRepository
.
findByName
(
tableInfo
.
getName
()).
stream
()
.
map
(
Bind:
:
getTableInfoExId
)
.
distinct
()
.
map
(
tableInfoExId
->
tableInfoExRepository
.
findById
(
tableInfoExId
).
orElse
(
null
))
.
filter
(
Objects:
:
nonNull
)
.
map
(
TableInfoEx:
:
getName
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
for
(
String
name
:
names
)
{
TableInfoEx
tableInfoEx
=
tableInfoExRepository
.
findByName
(
name
).
stream
()
.
max
(
Comparator
.
comparingInt
(
TableInfoEx:
:
getVersion
))
.
map
(
this
::
getBinds
)
.
orElseThrow
(()
->
new
RuntimeException
(
"计算中出现异常"
));
Integer
lastVersion
=
tableInfoEx
.
getVersion
();
List
<
Bind
>
binds
=
tableInfoEx
.
getBinds
();
TableInfoEx
newTableInfoEx
=
new
TableInfoEx
()
.
setName
(
tableInfoEx
.
getName
())
.
setDescription
(
tableInfoEx
.
getDescription
())
.
setProcessKey
(
tableInfoEx
.
getProcessKey
())
.
setVersion
(
lastVersion
+
1
)
.
setBinds
(
newBinds
(
binds
,
tableInfo
));
update
(
newTableInfoEx
);
}
}
//-----------------------------------------------------------------------------//
private
List
<
Bind
>
newBinds
(
List
<
Bind
>
binds
,
TableInfo
tableInfo
)
{
List
<
Bind
>
newBinds
=
new
ArrayList
<>();
for
(
Bind
bind
:
binds
)
{
Bind
newBind
=
new
Bind
()
.
setName
(
bind
.
getName
())
.
setVersion
(
bind
.
getVersion
())
.
setIsComplex
(
bind
.
getIsComplex
());
if
(
Objects
.
equals
(
bind
.
getName
(),
tableInfo
.
getName
()))
{
newBind
.
setVersion
(
tableInfo
.
getVersion
());
}
if
(
hasChildren
(
bind
))
{
List
<
Bind
>
children
=
bind
.
getChildren
();
newBind
.
setChildren
(
newBinds
(
children
,
tableInfo
));
}
newBinds
.
add
(
newBind
);
}
return
newBinds
;
}
private
boolean
hasChildren
(
Bind
bind
)
{
return
nonNull
(
bind
.
getChildren
())
&&
!
bind
.
getChildren
().
isEmpty
();
}
private
void
save
(
Bind
bind
,
Integer
tableInfoExId
)
{
Integer
lastVersion
=
tableInfoRepository
.
countByName
(
bind
.
getName
());
bind
.
setVersion
(
lastVersion
);
bind
.
setTableInfoExId
(
tableInfoExId
);
Integer
id
=
bindRepository
.
save
(
bind
).
getId
();
if
(
hasChildren
(
bind
))
{
List
<
Bind
>
childrenForSave
=
bind
.
getChildren
().
stream
()
.
map
(
child
->
child
.
setParentId
(
id
))
.
collect
(
Collectors
.
toList
());
childrenForSave
.
forEach
(
child
->
save
(
child
,
tableInfoExId
));
}
}
private
TableInfoEx
getBinds
(
TableInfoEx
tableInfoEx
)
{
List
<
Bind
>
binds
=
bindRepository
.
findByTableInfoExIdAndParentId
(
tableInfoEx
.
getId
(),
null
).
stream
()
.
map
(
this
::
getChildren
)
.
collect
(
Collectors
.
toList
());
tableInfoEx
.
setBinds
(
binds
);
return
tableInfoEx
;
}
private
Bind
getChildren
(
Bind
bind
)
{
List
<
Bind
>
children
=
bindRepository
.
findByTableInfoExIdAndParentId
(
bind
.
getTableInfoExId
(),
bind
.
getId
()).
stream
()
.
map
(
child
->
child
.
setChildren
(
Collections
.
emptyList
()))
.
collect
(
Collectors
.
toList
());
bind
.
setChildren
(
children
);
return
bind
;
}
}
src/main/java/com/tykj/workflowcore/model/service/TableInfoService.java
0 → 100644
浏览文件 @
400de769
package
com
.
tykj
.
workflowcore
.
model
.
service
;
import
com.tykj.workflowcore.model.entity.ColumnInfo
;
import
com.tykj.workflowcore.model.entity.TableInfo
;
import
com.tykj.workflowcore.model.repository.ColumnInfoRepository
;
import
com.tykj.workflowcore.model.repository.TableInfoRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
Objects
.
nonNull
;
@SuppressWarnings
(
"Duplicates"
)
@Service
public
class
TableInfoService
{
@Autowired
private
TableInfoExService
tableInfoExService
;
@Autowired
private
TableInfoRepository
tableInfoRepository
;
@Autowired
private
ColumnInfoRepository
columnInfoRepository
;
public
void
save
(
TableInfo
tableInfo
)
{
//数据检查
boolean
exists
=
tableInfoRepository
.
existsByName
(
tableInfo
.
getName
());
if
(
exists
)
{
throw
new
RuntimeException
(
"该模型已存在"
);
}
if
(
nonNull
(
tableInfo
.
getId
()))
{
throw
new
RuntimeException
(
"新增操作不可附带id"
);
}
//设置时间
Date
date
=
new
Date
();
tableInfo
.
setCreatedTime
(
date
);
tableInfo
.
setUpdatedTime
(
date
);
//设置版本号
tableInfo
.
setVersion
(
1
);
//保存数据
Integer
id
=
tableInfoRepository
.
save
(
tableInfo
).
getId
();
List
<
ColumnInfo
>
columnInfosForSave
=
tableInfo
.
getColumnInfos
().
stream
()
.
map
(
columnInfo
->
columnInfo
.
setTableInfoId
(
id
))
.
collect
(
Collectors
.
toList
());
columnInfosForSave
.
forEach
(
columnInfoRepository:
:
save
);
}
public
void
update
(
TableInfo
tableInfo
)
{
//数据检查
boolean
exists
=
tableInfoRepository
.
existsByName
(
tableInfo
.
getName
());
if
(!
exists
)
{
throw
new
RuntimeException
(
"该模型不存在"
);
}
if
(
nonNull
(
tableInfo
.
getId
()))
{
throw
new
RuntimeException
(
"修改操作不可附带id"
);
}
Integer
count
=
tableInfoRepository
.
countByName
(
tableInfo
.
getName
());
//设置时间
Date
date
=
new
Date
();
tableInfo
.
setCreatedTime
(
date
);
tableInfo
.
setUpdatedTime
(
date
);
tableInfo
.
setVersion
(
count
+
1
);
//保存数据
Integer
id
=
tableInfoRepository
.
save
(
tableInfo
).
getId
();
List
<
ColumnInfo
>
columnInfosForSave
=
tableInfo
.
getColumnInfos
().
stream
()
.
map
(
columnInfo
->
columnInfo
.
setTableInfoId
(
id
))
.
collect
(
Collectors
.
toList
());
columnInfosForSave
.
forEach
(
columnInfoRepository:
:
save
);
//更新有关联的聚合对象
tableInfoExService
.
updateRelatedTableInfoEx
(
tableInfo
);
}
public
TableInfo
findById
(
Integer
id
)
{
TableInfo
tableInfo
=
tableInfoRepository
.
findById
(
id
).
orElseThrow
(()
->
new
RuntimeException
(
"该模型不存在"
));
List
<
ColumnInfo
>
columnInfos
=
columnInfoRepository
.
findByTableInfoId
(
id
);
tableInfo
.
setColumnInfos
(
columnInfos
);
return
tableInfo
;
}
public
List
<
TableInfo
>
findAll
()
{
return
tableInfoRepository
.
findAll
().
stream
()
.
map
(
this
::
getColumnInfos
)
.
collect
(
Collectors
.
toList
());
}
//-----------------------------------------------------------------------------//
private
TableInfo
getColumnInfos
(
TableInfo
tableInfo
)
{
List
<
ColumnInfo
>
columnInfos
=
columnInfoRepository
.
findByTableInfoId
(
tableInfo
.
getId
());
tableInfo
.
setColumnInfos
(
columnInfos
);
return
tableInfo
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论