Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
8f2b67f9
提交
8f2b67f9
authored
4月 20, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 扫描类时bug。
上级
e9a12de7
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
96 行增加
和
69 行删除
+96
-69
WorkflowCoreApplication.java
...n/java/com/tykj/workflowcore/WorkflowCoreApplication.java
+17
-0
ModelController.java
.../workflowcore/model_layer/controller/ModelController.java
+30
-8
TableInfoExDao.java
...com/tykj/workflowcore/model_layer/dao/TableInfoExDao.java
+7
-0
ModelService.java
...m/tykj/workflowcore/model_layer/service/ModelService.java
+1
-2
ModelHelper.java
...kj/workflowcore/model_layer/service/impl/ModelHelper.java
+1
-0
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+36
-27
AggregationUtil.java
.../tykj/workflowcore/model_layer/utils/AggregationUtil.java
+0
-29
WorkflowCoreApplicationTests.java
...a/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
+4
-3
没有找到文件。
src/main/java/com/tykj/workflowcore/WorkflowCoreApplication.java
浏览文件 @
8f2b67f9
...
...
@@ -14,6 +14,23 @@ public class WorkflowCoreApplication {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
WorkflowCoreApplication
.
class
,
args
);
System
.
out
.
println
(
"█▀▀▀▀▀▀▀█▀▀▀█▀▀▀█▀▀▀█▀█▀▀▀▀▀▀▀█\n"
+
"█ █▀▀▀█ █ ▄ ▀█▄▀█▀▀▀▄▀█ █▀▀▀█ █\n"
+
"█ █ █ █▄▄█▄█▀ ▄ ▄ ▀▄█ █ █ █\n"
+
"█ ▀▀▀▀▀ █ █▀▄ █▀█▀█▀▄ █ ▀▀▀▀▀ █\n"
+
"█▀▀██▀▀▀██▄█▀▄▀█▀▄▄██▀██▀█▀▀▀▀█\n"
+
"█▀▄▄▄ ▄▀ ▄▄▀ ▄ ██ ▀▄ ▄▀ █\n"
+
"█ ▀ ██▀▀██ ▄▀▀███ ▄▄ ▄█ ▀█▄▄█\n"
+
"█▀▄█▀ █▀▀ ███ █ ▄███▀▄ ▄▄▀▀▄ █\n"
+
"█▀█▀▄▄ ▀▀▄ ▀▀▄▀▄ ▄ █▀▀ █▄▀▀█▄ █\n"
+
"█▄▄▀▀ ▀▀ █▀▀▀ ▄█ ▀██▀▀ ▄▀▀▄ █\n"
+
"█▀▀▀▀█▀▀██▄▀▄▀▀██▀ █ ▀ ▀ █▀██\n"
+
"█▀▀▀▀▀▀▀█▄█▀██▄▀ ▀ █▀ █▀█ █ ▄ █\n"
+
"█ █▀▀▀█ █ █▀▀▄▀▀▀█ █▀ ▀▀▀ ██▄▀█\n"
+
"█ █ █ ███▀▀ ▀ ▀ ▄▄█▄▄▀ █▄ ▀ █\n"
+
"█ ▀▀▀▀▀ █ █▄▀ ██▀ ██▀█▄ █ ▄█\n"
+
"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀"
);
}
}
src/main/java/com/tykj/workflowcore/model_layer/controller/ModelController.java
浏览文件 @
8f2b67f9
...
...
@@ -6,6 +6,7 @@ import com.tykj.workflowcore.base.result.ResultUtil;
import
com.tykj.workflowcore.model_layer.entity.vo.*
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
com.tykj.workflowcore.model_layer.service.ModelService
;
import
com.tykj.workflowcore.model_layer.service.impl.ModelHelper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -36,6 +37,9 @@ public class ModelController {
@Autowired
private
ModelService
modelService
;
@Autowired
private
ModelHelper
modelHelper
;
/**
* @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
...
...
@@ -90,7 +94,7 @@ public class ModelController {
modelService
.
newTable
(
tableVO
);
long
end
=
System
.
currentTimeMillis
();
log
.
warn
(
"创建总用时为:{}秒"
,
(
end
-
start
)/
1000.0
);
log
.
warn
(
"创建总用时为:{}秒"
,
(
end
-
start
)
/
1000.0
);
return
ResultUtil
.
success
(
""
,
"新建成功!"
);
}
...
...
@@ -107,7 +111,7 @@ public class ModelController {
@PostMapping
(
"/insertValues"
)
public
ResponseEntity
insertValues
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
i
=
modelService
.
putValueByEntityName
(
map
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
return
ResultUtil
.
failed
(
"模型类型不支持插入数据!"
);
...
...
@@ -131,6 +135,7 @@ public class ModelController {
}
return
ResultUtil
.
success
(
null
,
"获取失败!"
);
}
/**
* @param tableName
* @param queryConditions
...
...
@@ -148,26 +153,43 @@ public class ModelController {
}
return
ResultUtil
.
success
(
null
,
"没有数据!"
);
}
@ApiOperation
(
"编辑操作"
)
@PutMapping
(
"/update"
)
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
){
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
)
{
long
start
=
System
.
currentTimeMillis
();
int
i
=
modelService
.
updateTable
(
updateTableInfoVO
);
if
(
i
==
1
)
{
if
(
i
==
1
)
{
long
end
=
System
.
currentTimeMillis
();
log
.
warn
(
"创建总用时为:{}秒"
,
(
end
-
start
)/
1000.0
);
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
log
.
warn
(
"创建总用时为:{}秒"
,
(
end
-
start
)
/
1000.0
);
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
}
return
ResultUtil
.
success
(
"业务类型不支持修改!"
);
}
@ApiOperation
(
"删除操作"
)
@DeleteMapping
(
"/delete"
)
public
ResponseEntity
delTable
(
DelTableVO
delTableVO
)
{
public
ResponseEntity
delTable
(
DelTableVO
delTableVO
)
{
int
i
=
modelService
.
delTable
(
delTableVO
);
if
(
i
==
1
)
{
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"删除成功!"
);
}
return
ResultUtil
.
success
(
"业务类型不支持删除!"
);
}
@ApiOperation
(
"获得获得非聚合对象example"
)
@GetMapping
(
"/example"
)
public
ResponseEntity
getjsonExample
(
Integer
id
)
{
return
ResultUtil
.
success
(
modelHelper
.
getJsonExpample
(
id
),
"获得非聚合对象example成功!"
);
}
@ApiOperation
(
"获得聚合对象example"
)
@GetMapping
(
"/exExample"
)
public
ResponseEntity
getjsonExExample
(
Integer
id
)
{
return
ResultUtil
.
success
(
modelHelper
.
getExJsonExample
(
id
),
"获得聚合对象example成功!"
);
}
}
src/main/java/com/tykj/workflowcore/model_layer/dao/TableInfoExDao.java
浏览文件 @
8f2b67f9
...
...
@@ -13,4 +13,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @Version 1.0
*/
public
interface
TableInfoExDao
extends
JpaRepository
<
TableInfoEx
,
Integer
>,
JpaSpecificationExecutor
<
TableInfoEx
>
{
/**
* 根据表名查询name
* @param name
* @return
*/
TableInfoEx
findByName
(
String
name
);
}
src/main/java/com/tykj/workflowcore/model_layer/service/ModelService.java
浏览文件 @
8f2b67f9
...
...
@@ -4,13 +4,12 @@ package com.tykj.workflowcore.model_layer.service;
import
com.tykj.workflowcore.model_layer.entity.ColumnInfo
;
import
com.tykj.workflowcore.model_layer.entity.TableInfo
;
import
com.tykj.workflowcore.model_layer.entity.vo.*
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.SQLException
;
import
java.util.List
;
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelHelper.java
浏览文件 @
8f2b67f9
...
...
@@ -42,6 +42,7 @@ public class ModelHelper {
* @return json格式的数据示例
*/
public
String
getJsonExpample
(
Integer
tableInfoId
)
{
/* 你要放10个元素,10/0.75+1=14 */
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
//根据表id查出字段信息 并加入Map结果
List
<
ColumnInfo
>
columnInfos
=
columnInfoDao
.
findAllByDbId
(
tableInfoId
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
8f2b67f9
...
...
@@ -39,6 +39,8 @@ import javax.persistence.Entity;
import
javax.persistence.EntityManagerFactory
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
javax.persistence.criteria.*
;
import
java.lang.reflect.Field
;
...
...
@@ -57,7 +59,7 @@ import static java.util.Objects.nonNull;
/**
* @ClassName Mo
e
delImpl
* @ClassName ModelImpl
* @Description TODO
* @Author WWW
* @Date 2021/2/26 13:39
...
...
@@ -127,7 +129,7 @@ public class ModelImpl implements ModelService {
Integer
modelType
=
tableVO
.
getModelType
();
String
parentTable
=
null
;
//扫描新建类型
if
(
modelType
.
equals
(
ModelType
.
BASICS_EXTENSION
))
{
if
(
modelType
.
equals
(
ModelType
.
BASICS_EXTENSION
))
{
parentTable
=
tableVO
.
getParentTable
();
tableVO
.
setModelType
(
ModelType
.
BASICS_EXTENSION
);
}
else
{
...
...
@@ -192,7 +194,7 @@ public class ModelImpl implements ModelService {
tableInfo
=
(
TableInfo
)
one
.
get
();
}
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
)){
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
))
{
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
//插入数据
...
...
@@ -204,8 +206,7 @@ public class ModelImpl implements ModelService {
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
valuesList
.
get
(
i
));
}
}
}
else
{
}
else
{
return
1
;
}
...
...
@@ -221,9 +222,7 @@ public class ModelImpl implements ModelService {
* @Description 新增参数的方法
* @Date 16:17 2021/3/5
**/
public
void
insertValue
(
String
tableName
,
Map
map
)
{
public
void
insertValue
(
String
tableName
,
Map
map
)
{
Session
newSession
=
sessionUtil
.
getSession
();
...
...
@@ -271,14 +270,22 @@ public class ModelImpl implements ModelService {
public
void
swaggerScan
(
List
<
Class
<?>>
classList
)
{
for
(
Class
<?>
aClass
:
classList
)
{
//不扫描自己
TableInfo
tableInfo
=
new
TableInfo
();
TableVO
tableVO
=
new
TableVO
();
//入表真实名称
String
realName
=
""
;
if
(!
aClass
.
isAnnotationPresent
(
WorkFlowCoreNoScan
.
class
))
{
if
(
aClass
.
isAnnotationPresent
(
Entity
.
class
))
{
TableInfo
tableInfo
=
new
TableInfo
();
TableVO
tableVO
=
new
TableVO
();
String
className
=
getClassName
(
aClass
.
toString
());
//入表真实名称
String
realName
=
className
.
toLowerCase
();
tableVO
.
setModelName
(
realName
);
if
(
aClass
.
isAnnotationPresent
(
Table
.
class
))
{
Table
table
=
aClass
.
getAnnotation
(
Table
.
class
);
if
(!
""
.
equals
(
table
.
name
())
&&
table
.
name
()
!=
null
)
{
realName
=
table
.
name
();
}
}
else
{
String
className
=
getClassName
(
aClass
.
toString
());
realName
=
className
;
}
//获得类中文描述
if
(
aClass
.
isAnnotationPresent
(
ApiModel
.
class
))
{
ApiModel
annotation
=
aClass
.
getAnnotation
(
ApiModel
.
class
);
...
...
@@ -286,7 +293,6 @@ public class ModelImpl implements ModelService {
if
(
annotation
.
value
()
!=
null
&&
!
""
.
equals
(
annotation
.
value
()))
{
apiModelDocument
.
append
(
annotation
.
value
()
+
"|"
);
}
if
(
annotation
.
description
()
!=
null
&&
!
""
.
equals
(
annotation
.
description
()))
{
apiModelDocument
.
append
(
annotation
.
description
()
+
"|"
);
}
...
...
@@ -296,9 +302,13 @@ public class ModelImpl implements ModelService {
}
//获得类所有属性
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
java
.
lang
.
reflect
.
Type
genericType
=
null
;
java
.
lang
.
reflect
.
Type
genericType
;
List
<
ColumnVO
>
list
=
new
ArrayList
<>();
for
(
Field
declaredField
:
declaredFields
)
{
if
(
declaredField
.
isAnnotationPresent
(
Transient
.
class
)){
continue
;
}
ColumnVO
columnVO
=
new
ColumnVO
();
//获得类型
genericType
=
declaredField
.
getGenericType
();
...
...
@@ -344,13 +354,12 @@ public class ModelImpl implements ModelService {
columnInfo
.
setFieldTitle
(
columnVO
.
getFieldTitle
());
columnInfo
.
setPrimaryKey
(
columnVO
.
getPrimaryKey
());
columnInfo
.
setDbName
(
class
Name
);
columnInfo
.
setDbName
(
real
Name
);
columnInfo
.
setDbId
(
tableInfo
.
getId
());
columnInfoDao
.
save
(
columnInfo
);
}
}
else
{
log
.
info
(
"{}已存在"
,
class
Name
);
log
.
info
(
"{}已存在"
,
real
Name
);
}
}
}
...
...
@@ -421,7 +430,7 @@ 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
.
BUSINESS
))
{
tableInfo
.
setUpdatedTime
(
new
Date
());
tableInfo
.
setDescription
(
tableVO
.
getDescription
());
...
...
@@ -463,7 +472,7 @@ public class ModelImpl implements ModelService {
List
<
ColumnInfo
>
columnsFordDelete
=
getColumnsFordDelete
(
originalColumnInfos
,
currentColumnInfos
);
for
(
ColumnInfo
originColumnInfo
:
columnsFordDelete
)
{
columnInfoDao
.
delete
(
originColumnInfo
);
}
}
}
return
1
;
...
...
@@ -559,13 +568,13 @@ public class ModelImpl implements ModelService {
@Override
public
int
delTable
(
DelTableVO
delTableVO
)
{
Optional
<
TableInfo
>
byId
=
tableInfoDao
.
findById
(
delTableVO
.
getId
());
Optional
<
TableInfo
>
byId
=
tableInfoDao
.
findById
(
delTableVO
.
getId
());
if
(!
byId
.
isPresent
())
{
throw
new
ApiException
(
"此id已经被删除!"
);
throw
new
ApiException
(
"此id已经被删除!"
);
}
else
{
TableInfo
tableInfo
=
byId
.
get
();
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
)
)
{
if
(
modelType
.
equals
(
ModelType
.
BUSINESS
))
{
tableInfoDao
.
delete
(
tableInfo
);
List
<
ColumnInfo
>
allByDbId
=
columnInfoDao
.
findAllByDbId
(
delTableVO
.
getId
());
columnInfoDao
.
deleteInBatch
(
allByDbId
);
...
...
@@ -580,13 +589,13 @@ public class ModelImpl implements ModelService {
@Override
public
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
)
{
TableAndColumnInfoVO
tableAndColumnInfoVO
=
new
TableAndColumnInfoVO
();
TableAndColumnInfoVO
tableAndColumnInfoVO
=
new
TableAndColumnInfoVO
();
PredicateBuilder
<
TableInfo
>
builder1
=
Specifications
.
and
();
builder1
.
in
(
ids
!=
null
,
"id"
,
ids
);
builder1
.
in
(
ids
!=
null
,
"id"
,
ids
);
List
<
TableInfo
>
allTableInfos
=
tableInfoDao
.
findAll
(
builder1
.
build
());
PredicateBuilder
<
ColumnInfo
>
builder2
=
Specifications
.
and
();
builder2
.
in
(
ids
!=
null
,
"dbId"
,
ids
);
builder2
.
in
(
ids
!=
null
,
"dbId"
,
ids
);
List
<
ColumnInfo
>
allColumnInfos
=
columnInfoDao
.
findAll
(
builder2
.
build
());
tableAndColumnInfoVO
.
setTableInfos
(
allTableInfos
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/utils/AggregationUtil.java
浏览文件 @
8f2b67f9
...
...
@@ -33,35 +33,6 @@ public class AggregationUtil {
return
aClass
.
getDocument
();
}
public
static
Document
addOneToOne
(
String
field
,
String
sideTableName
,
Document
document
)
{
Element
element
=
DocumentHelper
.
createElement
(
"one-to-one"
);
element
.
addAttribute
(
"name"
,
field
);
element
.
addAttribute
(
"class"
,
sideTableName
);
element
.
addAttribute
(
"cascade"
,
"save-update"
);
Element
classElement
=
getNode
(
document
);
classElement
.
add
(
element
);
return
document
;
}
public
static
Document
addOneToMany
(
String
sideTableName
,
String
mainTableConnectionKey
,
String
sideTableConnectionKey
,
Document
document
)
{
//创建ELEMETN
Element
setElement
=
createSetElement
(
mainTableConnectionKey
,
sideTableName
,
""
,
mainTableConnectionKey
,
sideTableConnectionKey
,
AggregationType
.
ONE_TO_MANY
);
//创建结束
Element
classElement
=
getNode
(
document
);
classElement
.
add
(
setElement
);
return
document
;
}
public
static
Document
addManyToMany
(
String
sideTableName
,
String
connectionTableName
,
String
mainTableConnectionKey
,
String
sideTableConnectionKey
,
Document
document
)
{
Element
setElement
=
createSetElement
(
sideTableName
,
sideTableName
,
connectionTableName
,
mainTableConnectionKey
,
sideTableConnectionKey
,
AggregationType
.
MANY_TO_MANY
);
//创建结束
Element
classElement
=
getNode
(
document
);
classElement
.
add
(
setElement
);
return
document
;
}
public
static
Element
createOneToOneElement
(
String
name
,
String
connectionKey
,
String
sideTableName
)
{
Element
element
=
DocumentHelper
.
createElement
(
"one-to-one"
);
element
.
addAttribute
(
"name"
,
name
);
...
...
src/main/test/java/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
浏览文件 @
8f2b67f9
...
...
@@ -38,6 +38,7 @@ import org.springframework.test.web.servlet.MockMvc;
import
org.springframework.test.web.servlet.RequestBuilder
;
import
org.springframework.test.web.servlet.result.HandlerResultMatchers
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.StringUtils
;
import
javax.persistence.CascadeType
;
...
...
@@ -478,14 +479,14 @@ class WorkflowCoreApplicationTests {
// }
@Test
public
void
testJSON
()
{
String
xml
=
tableInfoExDao
.
findById
(
4
).
get
().
getXml
();
String
xml
=
tableInfoExDao
.
findById
(
32
).
get
().
getXml
();
sessionUtil
.
addXml
(
xml
);
Session
session
=
sessionUtil
.
getSession
();
List
list
=
session
.
createQuery
(
"from
student_teacher_ref
"
).
list
();
List
list
=
session
.
createQuery
(
"from
test_obj
"
).
list
();
System
.
out
.
println
(
list
);
// String jsonExample = modelHelper.getJsonExample(2);
// System.out.println(jsonExample);
StringUtils
.
hasLength
(
xml
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论