Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
4f9b066e
提交
4f9b066e
authored
4月 06, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 新增聚合对象接口。
上级
1eeae3cc
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
131 行增加
和
28 行删除
+131
-28
pom.xml
pom.xml
+6
-0
TableInfoExController.java
...lowcore/model_layer/controller/TableInfoExController.java
+21
-0
AggregationRelationshipDao.java
...kflowcore/model_layer/dao/AggregationRelationshipDao.java
+4
-3
Aggregation.java
...com/tykj/workflowcore/model_layer/entity/Aggregation.java
+2
-2
AggregationVO.java
...ykj/workflowcore/model_layer/entity/vo/AggregationVO.java
+3
-2
AggregationService.java
.../workflowcore/model_layer/service/AggregationService.java
+2
-0
TableInfoExService.java
.../workflowcore/model_layer/service/TableInfoExService.java
+27
-0
AggregationImpl.java
...orkflowcore/model_layer/service/impl/AggregationImpl.java
+15
-15
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+4
-2
TableInfoExImpl.java
...orkflowcore/model_layer/service/impl/TableInfoExImpl.java
+41
-0
AggregationUtil.java
.../tykj/workflowcore/model_layer/utils/AggregationUtil.java
+5
-4
WorkflowCoreApplicationTests.java
...a/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
+1
-0
没有找到文件。
pom.xml
浏览文件 @
4f9b066e
...
...
@@ -115,6 +115,12 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cache
</artifactId>
</dependency>
<dependency>
<groupId>
org.jetbrains
</groupId>
<artifactId>
annotations
</artifactId>
<version>
RELEASE
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/tykj/workflowcore/model_layer/controller/TableInfoExController.java
0 → 100644
浏览文件 @
4f9b066e
package
com
.
tykj
.
workflowcore
.
model_layer
.
controller
;
import
com.tykj.workflowcore.model_layer.service.TableInfoExService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @ClassName TableInfoExController
* @Description TODO
* @Author WWW
* @Date 2021/4/6 10:37
* @Version 1.0
*/
@RestController
public
class
TableInfoExController
{
@Autowired
TableInfoExService
tableInfoExService
;
}
src/main/java/com/tykj/workflowcore/model_layer/dao/AggregationRelationshipDao.java
浏览文件 @
4f9b066e
package
com
.
tykj
.
workflowcore
.
model_layer
.
dao
;
import
com.tykj.workflowcore.model_layer.entity.AggregationRelationship
;
import
com.tykj.workflowcore.model_layer.entity.ColumnInfo
;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
...
...
@@ -12,6 +13,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @Date 2021/4/2 10:34
* @Version 1.0
*/
public
interface
AggregationRelationshipDao
extends
JpaRepository
<
Aggregation
Relationship
,
Integer
>,
JpaSpecificationExecutor
<
AggregationRelationship
>
{
public
interface
AggregationRelationshipDao
extends
JpaRepository
<
Aggregation
,
Integer
>,
JpaSpecificationExecutor
<
Aggregation
>
{
}
src/main/java/com/tykj/workflowcore/model_layer/entity/Aggregation
Relationship
.java
→
src/main/java/com/tykj/workflowcore/model_layer/entity/Aggregation.java
浏览文件 @
4f9b066e
...
...
@@ -23,12 +23,12 @@ import javax.persistence.Entity;
@Entity
@SQLDelete
(
sql
=
"update column_info set deleted = 1 where id = ?"
)
@Where
(
clause
=
"deleted = 0"
)
public
class
Aggregation
Relationship
extends
BaseEntity
{
public
class
Aggregation
extends
BaseEntity
{
@ApiModelProperty
(
"聚合对象ID"
)
private
Integer
tableInfoExId
;
@ApiModelProperty
(
"
附
表id"
)
@ApiModelProperty
(
"
副
表id"
)
private
Integer
sideTableId
;
@ApiModelProperty
(
"聚合对象关系"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/AggregationVO.java
浏览文件 @
4f9b066e
package
com
.
tykj
.
workflowcore
.
model_layer
.
entity
.
vo
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.tykj.workflowcore.model_layer.entity.AggregationRelationship
;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
com.tykj.workflowcore.model_layer.entity.TableInfoEx
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -30,7 +31,7 @@ public class AggregationVO {
private
Integer
mainTableId
;
@ApiModelProperty
(
"关系集合"
)
private
List
<
Aggregation
Relationship
>
lists
;
private
List
<
Aggregation
>
lists
;
public
TableInfoEx
getTableInfoEx
(){
TableInfoEx
tableInfoEx
=
new
TableInfoEx
();
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/AggregationService.java
浏览文件 @
4f9b066e
...
...
@@ -4,6 +4,8 @@ import com.tykj.workflowcore.model_layer.entity.TableInfoEx;
import
com.tykj.workflowcore.model_layer.entity.vo.AggregationVO
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @ClassName Aggregation
* @Description TODO
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/TableInfoExService.java
0 → 100644
浏览文件 @
4f9b066e
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
;
import
com.tykj.workflowcore.model_layer.entity.TableInfoEx
;
import
java.util.List
;
/**
* @Author WWW
* @Description
* @Date 14:06 2021/4/6
* @return
**/
public
interface
TableInfoExService
{
/**
* 查询所有
* @return
*/
List
<
TableInfoEx
>
findAll
();
/**
* 根据id获取tableInfoExXML
* @param id
* @return
*/
String
findXml
(
Integer
id
);
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/AggregationImpl.java
浏览文件 @
4f9b066e
...
...
@@ -4,7 +4,8 @@ import com.tykj.workflowcore.base.result.ApiException;
import
com.tykj.workflowcore.model_layer.dao.AggregationRelationshipDao
;
import
com.tykj.workflowcore.model_layer.dao.TableInfoDao
;
import
com.tykj.workflowcore.model_layer.dao.TableInfoExDao
;
import
com.tykj.workflowcore.model_layer.entity.AggregationRelationship
;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
com.tykj.workflowcore.model_layer.entity.TableInfoEx
;
import
com.tykj.workflowcore.model_layer.entity.vo.AggregationVO
;
...
...
@@ -15,7 +16,7 @@ import org.dom4j.Document;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.UUID
;
...
...
@@ -28,6 +29,7 @@ import java.util.UUID;
*/
@Service
public
class
AggregationImpl
implements
AggregationService
{
@Autowired
TableInfoDao
tableInfoDao
;
@Autowired
...
...
@@ -51,22 +53,23 @@ public class AggregationImpl implements AggregationService {
// save TableInfoEx (name des mainTableId)
TableInfoEx
tableInfoEx
=
tableInfoExDao
.
save
(
aggregationVO
.
getTableInfoEx
());
// 遍历VO 根据聚合类型 生成对应的 XML 节点 并添加到DOCUMENT中
for
(
Aggregation
Relationship
aggregationRelationship
:
aggregationVO
.
getLists
())
{
//取出副表的table
i
nfo
for
(
Aggregation
aggregationRelationship
:
aggregationVO
.
getLists
())
{
//取出副表的table
I
nfo
Optional
<
TableInfo
>
sideTableById
=
tableInfoDao
.
findById
(
aggregationRelationship
.
getSideTableId
());
aggregationRelationship
.
setTableInfoExId
(
tableInfoEx
.
getId
());
if
(!
sideTableById
.
isPresent
()){
throw
new
ApiException
(
"id为:"
+
aggregationRelationship
.
getSideTableId
()+
"的副表不存在"
);
}
if
(
aggregationRelationship
.
getRelationship
().
equals
(
AggregationType
.
ONE_TO_ONE
)){
AggregationUtil
.
addOneToOne
(
aggregationRelationship
.
getSideTableConnectionKey
(),
sideTableById
.
get
().
getModelName
(),
mainTableDocument
);
Document
document
=
AggregationUtil
.
addOneToOne
(
aggregationRelationship
.
getSideTableConnectionKey
(),
sideTableById
.
get
().
getModelName
(),
mainTableDocument
);
tableInfoEx
.
setXml
(
document
.
asXML
());
}
if
(
aggregationRelationship
.
getRelationship
().
equals
(
AggregationType
.
ONE_TO_MANY
)){
//如果是一对多需要 为 aggregationRelationship 生成连接的KEY
String
mainTableConnectionKey
=
sideTableById
.
get
().
getModelName
()+
"
L
ist"
;
AggregationUtil
.
addOneToMany
(
sideTableById
.
get
().
getModelName
(),
mainTableConnectionKey
,
aggregationRelationship
.
getSideTableConnectionKey
(),
mainTableDocument
);
String
mainTableConnectionKey
=
sideTableById
.
get
().
getModelName
()+
"
_l
ist"
;
Document
document
=
AggregationUtil
.
addOneToMany
(
sideTableById
.
get
().
getModelName
(),
mainTableConnectionKey
,
aggregationRelationship
.
getSideTableConnectionKey
(),
mainTableDocument
);
tableInfoEx
.
setXml
(
document
.
asXML
());
}
if
(
aggregationRelationship
.
getRelationship
().
equals
(
AggregationType
.
MANY_TO_MANY
)){
//如果是多对多需要 为 aggregationRelationship 生成连接的KEY
...
...
@@ -75,16 +78,13 @@ public class AggregationImpl implements AggregationService {
aggregationRelationship
.
setMainTableConnectionKey
(
mainTableConnectionKey
);
aggregationRelationship
.
setSideTableConnectionKey
(
sideTableConnectionKey
);
//如果是多对多需要 为 aggregationRelationship 生成连接的中间表名
String
C
onnectionTableName
=
mainTableById
.
get
().
getModelName
()+
"_"
+
sideTableById
.
get
().
getModelName
()+
"_"
+
(
UUID
.
randomUUID
().
toString
().
substring
(
0
,
8
));
aggregationRelationship
.
setConnectionTableName
(
C
onnectionTableName
);
String
c
onnectionTableName
=
mainTableById
.
get
().
getModelName
()+
"_"
+
sideTableById
.
get
().
getModelName
()+
"_"
+
(
UUID
.
randomUUID
().
toString
().
substring
(
0
,
8
));
aggregationRelationship
.
setConnectionTableName
(
c
onnectionTableName
);
//Util.addManyToMany
AggregationUtil
.
addManyToMany
(
sideTableById
.
get
().
getModelName
(),
C
onnectionTableName
,
mainTableConnectionKey
,
sideTableConnectionKey
,
mainTableDocument
);
Document
document
=
AggregationUtil
.
addManyToMany
(
sideTableById
.
get
().
getModelName
(),
c
onnectionTableName
,
mainTableConnectionKey
,
sideTableConnectionKey
,
mainTableDocument
);
tableInfoEx
.
setXml
(
document
.
asXML
());
}
aggregationRelationshipDao
.
save
(
aggregationRelationship
);
}
}
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
4f9b066e
...
...
@@ -222,8 +222,10 @@ public class ModelImpl implements ModelService {
* @Date 16:17 2021/3/5
**/
public
void
insertValue
(
String
tableName
,
Map
map
)
{
// CreateTableUtil createTableUtil = new CreateTableUtil();
// Session newSession = createTableUtil.getSession(entityManagerFactory, xml);
/*
CreateTableUtil createTableUtil = new CreateTableUtil();
Session newSession = createTableUtil.getSession(entityManagerFactory, xml);
*/
Session
newSession
=
sessionUtil
.
getSession
();
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/TableInfoExImpl.java
0 → 100644
浏览文件 @
4f9b066e
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
.
impl
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.model_layer.dao.TableInfoExDao
;
import
com.tykj.workflowcore.model_layer.entity.TableInfoEx
;
import
com.tykj.workflowcore.model_layer.service.TableInfoExService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
sun.rmi.runtime.NewThreadAction
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @ClassName TableInfoExImpl
* @Description TODO
* @Author WWW
* @Date 2021/4/6 9:58
* @Version 1.0
*/
@Service
public
class
TableInfoExImpl
implements
TableInfoExService
{
@Autowired
TableInfoExDao
tableInfoExDao
;
@Override
public
List
<
TableInfoEx
>
findAll
()
{
return
tableInfoExDao
.
findAll
()
;
}
@Override
public
String
findXml
(
Integer
id
)
{
Optional
<
TableInfoEx
>
byId
=
tableInfoExDao
.
findById
(
id
);
if
(
byId
.
isPresent
()){
return
byId
.
get
().
getXml
();
}
throw
new
ApiException
(
"id错误!"
);
}
}
src/main/java/com/tykj/workflowcore/model_layer/utils/AggregationUtil.java
浏览文件 @
4f9b066e
...
...
@@ -2,14 +2,13 @@ package com.tykj.workflowcore.model_layer.utils;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.model_layer.myEnum.AggregationType
;
import
liquibase.pro.packaged.E
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
/**
* @ClassName AggregationUtil
...
...
@@ -19,6 +18,7 @@ import java.util.List;
* @Version 1.0
*/
public
class
AggregationUtil
{
//xml工具
public
static
Document
getDocument
(
String
xml
){
try
{
...
...
@@ -45,7 +45,7 @@ public class AggregationUtil {
}
public
static
Document
addOneToMany
(
String
sideTableName
,
String
mainTableConnectionKey
,
String
sideTableConnectionKey
,
Document
document
)
{
//创建ELEMTN
//创建ELEM
E
TN
Element
setElement
=
createSetElement
(
mainTableConnectionKey
,
sideTableName
,
""
,
mainTableConnectionKey
,
sideTableConnectionKey
,
AggregationType
.
ONE_TO_MANY
);
//创建结束
Element
classElement
=
getNode
(
document
);
...
...
@@ -92,6 +92,7 @@ public class AggregationUtil {
return
elementSet
;
}
// 字符串拼接
// private static String xmlStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
// "<!DOCTYPE hibernate-mapping PUBLIC\n" +
// " \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n" +
...
...
src/main/test/java/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
浏览文件 @
4f9b066e
...
...
@@ -431,6 +431,7 @@ class WorkflowCoreApplicationTests {
@Test
public
void
testOldProperty
()
throws
DocumentException
{
TableInfo
stus
=
tableInfoDao
.
findByModelName
(
"stus"
);
String
xml
=
stus
.
getXml
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论