Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
4a54f0a7
提交
4a54f0a7
authored
5月 14, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 补全类的全参、无参构造,聚合对象修改
上级
da3be51d
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
141 行增加
和
71 行删除
+141
-71
AggregationController.java
...lowcore/model_layer/controller/AggregationController.java
+11
-5
ModelController.java
.../workflowcore/model_layer/controller/ModelController.java
+4
-4
AggregationDao.java
...com/tykj/workflowcore/model_layer/dao/AggregationDao.java
+1
-0
Aggregation.java
...com/tykj/workflowcore/model_layer/entity/Aggregation.java
+6
-2
TableInfo.java
...a/com/tykj/workflowcore/model_layer/entity/TableInfo.java
+4
-0
AggregationVO.java
...ykj/workflowcore/model_layer/entity/vo/AggregationVO.java
+6
-0
ColumnVO.java
...com/tykj/workflowcore/model_layer/entity/vo/ColumnVO.java
+4
-0
TableAndColumnInfoVO.java
...kflowcore/model_layer/entity/vo/TableAndColumnInfoVO.java
+4
-0
TableVO.java
.../com/tykj/workflowcore/model_layer/entity/vo/TableVO.java
+4
-0
ModelType.java
...a/com/tykj/workflowcore/model_layer/myEnum/ModelType.java
+17
-2
AggregationImpl.java
...orkflowcore/model_layer/service/impl/AggregationImpl.java
+61
-47
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+18
-10
SessionUtil.java
.../com/tykj/workflowcore/model_layer/utils/SessionUtil.java
+1
-1
没有找到文件。
src/main/java/com/tykj/workflowcore/model_layer/controller/AggregationController.java
浏览文件 @
4a54f0a7
...
...
@@ -5,16 +5,16 @@ import com.tykj.workflowcore.model_layer.dao.AggregationDao;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
com.tykj.workflowcore.model_layer.entity.vo.AggregationVO
;
import
com.tykj.workflowcore.model_layer.service.AggregationService
;
import
com.tykj.workflowcore.model_layer.service.impl.ModelHelper
;
import
io.swagger.annotations.Api
;
import
liquibase.pro.packaged.A
;
import
org.dom4j.Attribute
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -26,7 +26,7 @@ import java.util.List;
* @Date 2021/4/2 11:19
* @Version 1.0
*/
@Api
(
tags
=
"聚合对象"
)
@RestController
@RequestMapping
(
"/aggregation"
)
public
class
AggregationController
{
...
...
@@ -36,6 +36,8 @@ public class AggregationController {
@Autowired
AggregationDao
aggregationDao
;
@Autowired
ModelHelper
modelHelper
;
@PostMapping
(
"/add"
)
public
ResponseEntity
add
(
@RequestBody
AggregationVO
aggregationVO
)
{
...
...
@@ -85,4 +87,8 @@ public class AggregationController {
return
elementCLass
;
}
}
src/main/java/com/tykj/workflowcore/model_layer/controller/ModelController.java
浏览文件 @
4a54f0a7
...
...
@@ -128,7 +128,7 @@ public class ModelController {
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
return
ResultUtil
.
success
(
null
,
"获取失败!"
);
return
ResultUtil
.
failed
(
null
,
"获取失败!"
);
}
/**
...
...
@@ -147,7 +147,7 @@ public class ModelController {
if
(
list
!=
null
)
{
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
}
return
ResultUtil
.
success
(
null
,
"没有数据!"
);
return
ResultUtil
.
failed
(
null
,
"没有数据!"
);
}
@ApiOperation
(
"编辑操作"
)
...
...
@@ -158,7 +158,7 @@ public class ModelController {
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
}
return
ResultUtil
.
success
(
"业务类型不支持修改!"
);
return
ResultUtil
.
failed
(
"业务类型不支持修改!"
);
}
@ApiOperation
(
"删除操作"
)
...
...
@@ -169,7 +169,7 @@ public class ModelController {
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"删除成功!"
);
}
return
ResultUtil
.
success
(
"业务类型不支持删除!"
);
return
ResultUtil
.
failed
(
"业务类型不支持删除!"
);
}
...
...
src/main/java/com/tykj/workflowcore/model_layer/dao/AggregationDao.java
浏览文件 @
4a54f0a7
package
com
.
tykj
.
workflowcore
.
model_layer
.
dao
;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/Aggregation.java
浏览文件 @
4a54f0a7
...
...
@@ -3,8 +3,10 @@ package com.tykj.workflowcore.model_layer.entity;
import
com.tykj.workflowcore.base.entity.BaseEntity
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
...
...
@@ -18,12 +20,14 @@ import java.util.List;
* @Date 2021/4/2 9:49
* @Version 1.0
*/
@Accessors
(
chain
=
true
)
@WorkFlowCoreNoScan
@Data
@Table
(
name
=
"
workflow_
aggregation"
)
@Table
(
name
=
"aggregation"
)
@NoArgsConstructor
@AllArgsConstructor
@Entity
@SQLDelete
(
sql
=
"update
column_info
set deleted = 1 where id = ?"
)
@SQLDelete
(
sql
=
"update
aggregation
set deleted = 1 where id = ?"
)
@Where
(
clause
=
"deleted = 0"
)
public
class
Aggregation
extends
BaseEntity
{
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/TableInfo.java
浏览文件 @
4a54f0a7
...
...
@@ -4,7 +4,9 @@ package com.tykj.workflowcore.model_layer.entity;
import
com.tykj.workflowcore.base.entity.BaseEntity
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.*
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
...
...
@@ -25,6 +27,8 @@ import java.io.Serializable;
@Table
@EntityListeners
(
AuditingEntityListener
.
class
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@SQLDelete
(
sql
=
"update table_info set deleted = 1 where id = ?"
)
@Where
(
clause
=
"deleted = 0"
)
public
class
TableInfo
extends
BaseEntity
{
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/AggregationVO.java
浏览文件 @
4a54f0a7
...
...
@@ -7,7 +7,10 @@ import com.tykj.workflowcore.model_layer.entity.TableInfo;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
org.springframework.beans.BeanUtils
;
import
java.util.List
;
...
...
@@ -19,6 +22,9 @@ import java.util.List;
* @Date 2021/4/2 9:51
* @Version 1.0
*/
@AllArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@ApiModel
(
"聚合信息"
)
@Data
public
class
AggregationVO
{
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/ColumnVO.java
浏览文件 @
4a54f0a7
...
...
@@ -2,7 +2,9 @@ package com.tykj.workflowcore.model_layer.entity.vo;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @ClassName ColumnVO
...
...
@@ -13,6 +15,8 @@ import lombok.Data;
*/
@ApiModel
(
"列信息"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ColumnVO
{
@ApiModelProperty
(
"id"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/TableAndColumnInfoVO.java
浏览文件 @
4a54f0a7
...
...
@@ -2,7 +2,9 @@ package com.tykj.workflowcore.model_layer.entity.vo;
import
com.tykj.workflowcore.model_layer.entity.ColumnInfo
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
...
...
@@ -13,6 +15,8 @@ import java.util.List;
* @Date 2021/3/29 9:59
* @Version 1.0
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
TableAndColumnInfoVO
{
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/TableVO.java
浏览文件 @
4a54f0a7
...
...
@@ -2,7 +2,9 @@ package com.tykj.workflowcore.model_layer.entity.vo;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
...
...
@@ -15,6 +17,8 @@ import java.util.List;
*/
@ApiModel
(
"表信息"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
TableVO
{
@ApiModelProperty
(
"中文描述"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/myEnum/ModelType.java
浏览文件 @
4a54f0a7
package
com
.
tykj
.
workflowcore
.
model_layer
.
myEnum
;
/**
* @ClassName ModelType
* @Description TODO 模型的3种类型
...
...
@@ -9,6 +10,11 @@ package com.tykj.workflowcore.model_layer.myEnum;
*/
public
class
ModelType
{
/**
* 聚合对象
*/
// public static final Integer AGGREGATION = -1;
/**
* 基础扫描对象
*/
...
...
@@ -16,11 +22,20 @@ public class ModelType {
/**
* 业务对象
*/
public
static
final
Integer
BUSINESS
=
1
;
//
public static final Integer BUSINESS = 1;
/**
* 基础对象延伸
*/
public
static
final
Integer
BASICS_EXTENSION
=
2
;
// public static final Integer BASICS_EXTENSION = 2;
/**
* 数据源对象
*/
public
static
final
Integer
DATA_SOURCE
=
3
;
/**
*虚拟对象,业务对象加聚合对象
*/
public
static
final
Integer
VIRTUAL
=
4
;
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/AggregationImpl.java
浏览文件 @
4a54f0a7
...
...
@@ -8,8 +8,10 @@ import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import
com.tykj.workflowcore.model_layer.entity.Aggregation
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
com.tykj.workflowcore.model_layer.entity.vo.AggregationVO
;
import
com.tykj.workflowcore.model_layer.myEnum.AggregationType
;
import
com.tykj.workflowcore.model_layer.myEnum.ModelType
;
import
com.tykj.workflowcore.model_layer.service.AggregationService
;
import
com.tykj.workflowcore.model_layer.utils.AggregationUtil
;
import
com.tykj.workflowcore.model_layer.utils.SessionUtil
;
...
...
@@ -26,6 +28,7 @@ import javax.transaction.Transactional;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
/**
* @ClassName AggregationImpl
...
...
@@ -41,46 +44,37 @@ public class AggregationImpl implements AggregationService {
TableInfoDao
tableInfoDao
;
@Autowired
AggregationDao
aggregation
Relationship
Dao
;
AggregationDao
aggregationDao
;
@Autowired
SessionUtil
sessionUtil
;
@Override
@Transactional
(
rollbackOn
=
Exception
.
class
)
public
void
addAggregation
(
AggregationVO
aggregationVO
)
{
Document
mainTableDocument
;
//获取主表XML
Integer
mainTableId
=
aggregationVO
.
getMainTableId
();
Optional
<
TableInfo
>
mainTableById
=
tableInfoDao
.
findById
(
mainTableId
);
if
(
mainTableById
.
isPresent
()){
mainTableDocument
=
AggregationUtil
.
getDocument
(
mainTableById
.
get
().
getXml
());
}
else
{
throw
new
ApiException
(
"主表不存在"
);
throw
new
ApiException
(
"主表不存在
!
"
);
}
//改CLASS名字
AggregationUtil
.
changeClassName
(
aggregationVO
.
getModelName
(),
mainTableDocument
);
// save TableInfoEx (name des mainTableId)
List
<
TableInfo
>
all
=
tableInfoDao
.
findAll
();
for
(
TableInfo
tableInfo
:
all
)
{
if
(
aggregationVO
.
getModelName
().
equals
(
tableInfo
.
getModelName
())){
throw
new
ApiException
(
"名称已存在!"
);
}
}
TableInfo
tableInfoEx
=
tableInfoDao
.
save
(
aggregationVO
.
getTableInfo
());
try
{
createAggregationObjectXml
(
aggregationVO
.
getAggregations
(),
null
,
tableInfoEx
.
getId
(),
mainTableById
.
get
(),
mainTableDocument
.
getRootElement
());
tableInfoEx
.
setXml
(
mainTableDocument
.
asXML
());
createAggregationObjectXml
(
aggregationVO
.
getAggregations
(),
null
,
tableInfoEx
.
getId
(),
mainTableById
.
get
());
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
}
tableInfoDao
.
save
(
tableInfoEx
);
}
//假设获得的是一份XML
public
Element
createAggregationObjectXml
(
List
<
Aggregation
>
aggregations
,
Aggregation
parentAggregation
,
Integer
tableInfoExId
,
TableInfo
mainTableInfo
,
Element
rootElement
)
throws
DocumentException
{
// 假设获得的是一份XML
public
void
createAggregationObjectXml
(
List
<
Aggregation
>
aggregations
,
Aggregation
parentAggregation
,
Integer
tableInfoExId
,
TableInfo
mainTableInfo
)
throws
DocumentException
{
//这里需要一个class标签,
Boolean
isFirst
=
false
;
Element
elementClass
;
String
parentModeName
;
if
(
parentAggregation
!=
null
){
//如果不是第一层,则通过parentAggregation,查出副表的XML字符串
...
...
@@ -88,7 +82,6 @@ public class AggregationImpl implements AggregationService {
//取出Class标签,将Class标签赋值给elementClass
Optional
<
TableInfo
>
sideTableInfoOptional
=
tableInfoDao
.
findById
(
parentAggregation
.
getSideTableId
());
if
(
sideTableInfoOptional
.
isPresent
()){
elementClass
=
(
Element
)
DocumentHelper
.
parseText
(
sideTableInfoOptional
.
get
().
getXml
()).
getRootElement
().
element
(
"class"
).
clone
();
}
else
{
throw
new
ApiException
(
"id为:"
+
parentAggregation
.
getSideTableId
()+
"的副表不存在"
);
}
...
...
@@ -96,35 +89,26 @@ public class AggregationImpl implements AggregationService {
}
else
{
//如果是第一层 则通过rootElement 查出副表的XML字符串
//取出Class标签,将Class标签赋值给elementClass
elementClass
=
(
Element
)
rootElement
.
element
(
"class"
);
parentModeName
=
mainTableInfo
.
getModelName
();
isFirst
=
true
;
}
//循环
for
(
int
i
=
0
;
i
<
aggregations
.
size
();
i
++)
{
Aggregation
aggregationChild
=
aggregations
.
get
(
i
);
if
(
aggregationChild
.
getAggregations
()!=
null
&&
aggregationChild
.
getAggregations
().
size
()>
0
){
String
uuid
=
"tykj"
+
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
Element
elementClassChild
=
createAggregationObjectXml
(
aggregationChild
.
getAggregations
(),
aggregationChild
,
tableInfoExId
,
mainTableInfo
,
rootElement
);
//为element给一个UUID的entity_name
aggregationChild
.
setUuidTableName
(
uuid
);
elementClassChild
.
attribute
(
"entity-name"
).
setValue
(
uuid
);
Element
elementSet
=
aggregationToXmlElement
(
aggregationChild
,
tableInfoExId
,
parentModeName
);
elementClass
.
add
(
elementSet
);
createAggregationObjectXml
(
aggregationChild
.
getAggregations
(),
aggregationChild
,
tableInfoExId
,
mainTableInfo
);
aggregationToXmlElement
(
aggregationChild
,
tableInfoExId
,
parentModeName
);
}
else
{
//addSet
Element
elementSet
=
aggregationToXmlElement
(
aggregationChild
,
tableInfoExId
,
parentModeName
);
elementClass
.
add
(
elementSet
);
aggregationToXmlElement
(
aggregationChild
,
tableInfoExId
,
parentModeName
);
}
aggregationRelationshipDao
.
save
(
aggregationChild
);
}
if
(!
isFirst
){
rootElement
.
add
(
elementClass
);
aggregationDao
.
save
(
aggregationChild
);
}
return
elementClass
;
return
;
}
public
Element
aggregationToXmlElement
(
Aggregation
aggregation
,
Integer
tableInfoExId
,
String
parentModelName
){
public
void
aggregationToXmlElement
(
Aggregation
aggregation
,
Integer
tableInfoExId
,
String
parentModelName
){
//设置tableInfoExId
aggregation
.
setTableInfoExId
(
tableInfoExId
);
...
...
@@ -133,17 +117,10 @@ public class AggregationImpl implements AggregationService {
throw
new
ApiException
(
"id为:"
+
aggregation
.
getSideTableId
()+
"的副表不存在"
);
}
if
(
aggregation
.
getRelationship
().
equals
(
AggregationType
.
ONE_TO_ONE
)){
return
AggregationUtil
.
createOneToOneElement
(
sideTableById
.
get
().
getModelName
(),
aggregation
.
getSideTableConnectionKey
(),
StringUtils
.
isEmpty
(
aggregation
.
getUuidTableName
())?
sideTableById
.
get
().
getModelName
():
aggregation
.
getUuidTableName
()
);
return
;
}
if
(
aggregation
.
getRelationship
().
equals
(
AggregationType
.
ONE_TO_MANY
)){
return
AggregationUtil
.
createOneToManyElement
(
sideTableById
.
get
().
getModelName
(),
StringUtils
.
isEmpty
(
aggregation
.
getUuidTableName
())?
sideTableById
.
get
().
getModelName
():
aggregation
.
getUuidTableName
(),
aggregation
.
getSideTableConnectionKey
());
return
;
}
if
(
aggregation
.
getRelationship
().
equals
(
AggregationType
.
MANY_TO_MANY
)){
//如果是多对多需要 为 aggregationRelationship 生成连接的KEY
...
...
@@ -155,9 +132,46 @@ public class AggregationImpl implements AggregationService {
String
connectionTableName
=
parentModelName
+
"_"
+
sideTableById
.
get
().
getModelName
()+
"_"
+
(
UUID
.
randomUUID
().
toString
().
substring
(
0
,
8
));
aggregation
.
setConnectionTableName
(
connectionTableName
);
//Util.addManyToMany
return
AggregationUtil
.
createManyToManyElement
(
sideTableById
.
get
().
getModelName
(),
aggregation
.
getUuidTableName
(),
connectionTableName
,
mainTableConnectionKey
,
sideTableConnectionKey
)
;
return
;
}
return
null
;
return
;
}
//
// @Override
// public void addAggregation(AggregationVO aggregationVO) {
// Integer mainTableId = aggregationVO.getMainTableId();
// Optional<TableInfo> byId = tableInfoDao.findById(mainTableId);
// TableInfo tableInfo = new TableInfo();
// List<String> modelNames = tableInfoDao.findAll()
// .stream()
// .map(TableInfo::getModelName)
// .collect(Collectors.toList());
// if (byId.isPresent()){
// if (modelNames.contains(aggregationVO.getModelName())){
// throw new ApiException("表名已经存在!");
// }
// else {
// tableInfo.setModelType(ModelType.VIRTUAL);
// tableInfo = tableInfoDao.save(aggregationVO.getTableInfo());
// }
// }else {
// throw new ApiException("主表不存在!");
// }
// saveAggregation(aggregationVO,tableInfo.getId());
//
//
//
// }
//
// public void saveAggregation(AggregationVO aggregationVO,Integer tableInfoId){
// Aggregation aggregation=new Aggregation();
// aggregation.setConnectionTableName(aggregationVO.getModelName())
// .setRelationship(aggregationVO.getAggregations().get(0).getRelationship())
// .setMainTableConnectionKey(aggregationVO.getAggregations().get(0).getMainTableConnectionKey())
// .setSideTableId(aggregationVO.getAggregations().get(0).getSideTableId())
// .setTableInfoExId(tableInfoId)
// .setSideTableConnectionKey(aggregationVO.getAggregations().get(0).getSideTableConnectionKey());
// aggregationDao.save(aggregation);
// }
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
4a54f0a7
...
...
@@ -146,15 +146,22 @@ public class ModelImpl implements ModelService {
Integer
modelType
=
tableVO
.
getModelType
();
String
parentTable
=
null
;
//扫描新建类型
if
(
modelType
.
equals
(
ModelType
.
BASICS_EXTENSION
))
{
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
parentTable
=
tableVO
.
getParentTable
();
tableVO
.
setModelType
(
ModelType
.
BASICS_EXTENSION
);
tableVO
.
setModelType
(
ModelType
.
VIRTUAL
);
}
else
{
tableVO
.
setModelType
(
ModelType
.
BUSINESS
);
tableVO
.
setModelType
(
ModelType
.
VIRTUAL
);
}
// sessionUtil.addXml(xmlMapping);
Session
session
=
sessionUtil
.
getSession
();
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
List
<
String
>
collect
=
tableInfoDao
.
findAll
()
.
stream
()
.
map
(
TableInfo:
:
getModelName
)
.
collect
(
Collectors
.
toList
());
if
(
collect
.
contains
(
tableVO
.
getModelName
())){
throw
new
ApiException
(
"表名已经存在!"
);
}
TableInfo
tableInfo
=
new
TableInfo
();
tableInfo
.
setModelName
(
tableVO
.
getModelName
());
tableInfo
.
setModelTitle
(
tableVO
.
getModelTitle
());
...
...
@@ -164,8 +171,10 @@ public class ModelImpl implements ModelService {
tableInfo
.
setParentTable
(
parentTable
);
tableInfoDao
.
save
(
tableInfo
);
//默认存储ID字段
ColumnInfo
cId
=
new
ColumnInfo
(
0
,
"id"
,
"主键"
,
"java.lang.Integer"
,
11
,
tableInfo
.
getModelName
(),
tableInfo
.
getId
(),
"主键"
);
columnInfoDao
.
save
(
cId
);
if
(
tableInfo
.
getModelType
().
equals
(
ModelType
.
VIRTUAL
)){
ColumnInfo
cId
=
new
ColumnInfo
(
0
,
"id"
,
"主键"
,
"java.lang.Integer"
,
11
,
tableInfo
.
getModelName
(),
tableInfo
.
getId
(),
"主键"
);
columnInfoDao
.
save
(
cId
);
}
for
(
ColumnVO
columnVO
:
dataList
)
{
ColumnInfo
columnInfo
=
new
ColumnInfo
();
columnInfo
.
setFieldName
(
columnVO
.
getFieldName
());
...
...
@@ -208,7 +217,7 @@ public class ModelImpl implements ModelService {
tableInfo
=
(
TableInfo
)
one
.
get
();
}
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
))
{
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
//插入数据
...
...
@@ -476,9 +485,8 @@ public class ModelImpl implements ModelService {
Integer
dbId
=
updateTableInfoVO
.
getDbId
();
TableInfo
tableInfo
=
tableInfoDao
.
findById
(
dbId
).
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的表信息"
));
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
))
{
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
tableInfo
.
setUpdatedTime
(
new
Date
());
tableInfo
.
setDescription
(
tableVO
.
getDescription
());
tableInfo
.
setModelTitle
(
tableVO
.
getModelTitle
());
tableInfo
.
setModelType
(
tableVO
.
getModelType
());
...
...
@@ -524,7 +532,7 @@ public class ModelImpl implements ModelService {
return
1
;
}
if
(
modelType
.
equals
(
ModelType
.
BASICS_EXTENSION
))
{
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
columnInfoDao
.
deleteAllByDbId
(
updateTableInfoVO
.
getDbId
());
...
...
@@ -642,7 +650,7 @@ public class ModelImpl implements ModelService {
}
else
{
TableInfo
tableInfo
=
byId
.
get
();
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
)
||
modelType
.
equals
(
ModelType
.
BASICS_EXTENSION
))
{
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
)
||
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
tableInfoDao
.
deleteById
(
delTableVO
.
getId
());
List
<
ColumnInfo
>
allByDbId
=
columnInfoDao
.
findAllByDbId
(
delTableVO
.
getId
());
columnInfoDao
.
deleteInBatch
(
allByDbId
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/utils/SessionUtil.java
浏览文件 @
4a54f0a7
...
...
@@ -3,7 +3,7 @@ package com.tykj.workflowcore.model_layer.utils;
import
com.google.common.base.Strings
;
import
com.tykj.workflowcore.model_layer.dao.TableInfoDao
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
org.checkerframework.checker.units.qual.A
;
import
org.hibernate.Session
;
import
org.hibernate.SessionFactory
;
import
org.hibernate.boot.Metadata
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论