Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow-core
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow-core
Commits
bf11cfa9
提交
bf11cfa9
authored
3月 15, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model layer
上级
84ac5a5c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
105 行增加
和
52 行删除
+105
-52
SearchTableInfoVo.java
...ykj/workflowcore/model_layer/model/SearchTableInfoVo.java
+3
-0
TableInfo.java
...va/com/tykj/workflowcore/model_layer/model/TableInfo.java
+1
-1
TableVO.java
...java/com/tykj/workflowcore/model_layer/model/TableVO.java
+3
-0
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+66
-51
ClassTypeLength.java
.../tykj/workflowcore/model_layer/utils/ClassTypeLength.java
+32
-0
没有找到文件。
src/main/java/com/tykj/workflowcore/model_layer/model/SearchTableInfoVo.java
浏览文件 @
bf11cfa9
...
...
@@ -16,5 +16,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public
class
SearchTableInfoVo
extends
JpaCustomPage
{
private
String
tableName
;
private
String
tableCnName
;
}
src/main/java/com/tykj/workflowcore/model_layer/model/TableInfo.java
浏览文件 @
bf11cfa9
...
...
@@ -46,7 +46,7 @@ public class TableInfo extends BaseEntity implements Serializable {
*0是扫描,1是自建
*/
@ApiModelProperty
(
"建表类型"
)
private
Integer
t
ype
;
private
Integer
modelT
ype
;
@ApiModelProperty
(
"执行人(保留字段)"
)
private
String
reviser
;
...
...
src/main/java/com/tykj/workflowcore/model_layer/model/TableVO.java
浏览文件 @
bf11cfa9
...
...
@@ -23,6 +23,9 @@ public class TableVO {
private
String
modelTitle
;
@ApiModelProperty
(
"表名"
)
private
String
modelName
;
/**
* 0扫描,1自建,2扫描后自选
*/
@ApiModelProperty
(
"模型类型"
)
private
Integer
modelType
;
@ApiModelProperty
(
"父表名称"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
bf11cfa9
...
...
@@ -40,6 +40,7 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
ClassTypeLength
.
setLength
;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
CreatTableUtil
.*;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
HqlUtil
.
createQuery
;
...
...
@@ -74,11 +75,11 @@ public class ModelImpl implements ModelService {
* @Date 16:14 2021/3/5
**/
@Override
public
Page
<
TableInfo
>
listAllEntities
(
SearchTableInfoVo
searchTableInfoVo
)
{
public
Page
<
TableInfo
>
listAllEntities
(
SearchTableInfoVo
searchTableInfoVo
)
{
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
and
.
eq
(
searchTableInfoVo
.
getTableName
()!=
null
,
"name"
,
searchTableInfoVo
.
getTableName
()
);
return
tableInfoDao
.
findAll
(
and
.
build
(),
searchTableInfoVo
.
getPageable
());
and
.
like
(
searchTableInfoVo
.
getTableName
()
!=
null
,
"name"
,
"%"
+
searchTableInfoVo
.
getTableName
()
+
"%"
);
and
.
like
(
searchTableInfoVo
.
getTableCnName
()
!=
null
,
"cnName"
,
"%"
+
searchTableInfoVo
.
getTableCnName
()
+
"%"
);
return
tableInfoDao
.
findAll
(
and
.
build
(),
searchTableInfoVo
.
getPageable
());
}
...
...
@@ -102,27 +103,36 @@ public class ModelImpl implements ModelService {
}
/**
* @param tableVO
* @return com.tykj.workflowcore.model_layer.model.TableVO
* @Author WWW
* @Description 新建一张表
* @Description
完全
新建一张表
* @Date 16:16 2021/3/5
**/
@Override
public
TableVO
newTable
(
TableVO
tableVO
)
{
String
xmlMapping
=
creatTable
(
tableVO
);
Integer
modelType
=
tableVO
.
getModelType
();
String
parentTable
=
null
;
//扫描新建类型
if
(
modelType
==
2
)
{
parentTable
=
tableVO
.
getParentTable
();
tableVO
.
setModelType
(
2
);
}
else
{
tableVO
.
setModelType
(
1
);
}
CreatTableUtil
creatTableUtil
=
new
CreatTableUtil
();
Session
session
=
creatTableUtil
.
getSession
(
entityManagerFactory
,
xmlMapping
);
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
TableInfo
tableInfo
=
new
TableInfo
();
tableInfo
.
setName
(
tableVO
.
getModelName
()
+
"_"
);
tableInfo
.
setName
(
tableVO
.
getModelName
()
+
"_"
);
tableInfo
.
setCnName
(
tableVO
.
getModelTitle
());
tableInfo
.
setXml
(
xmlMapping
);
tableInfo
.
setType
(
2
);
tableInfo
.
setModelType
(
tableVO
.
getModelType
());
tableInfo
.
setParentTable
(
parentTable
);
tableInfoDao
.
save
(
tableInfo
);
for
(
ColumnVO
columnVO
:
dataList
)
{
...
...
@@ -224,6 +234,11 @@ public class ModelImpl implements ModelService {
newSession
.
close
();
}
/**
* 扫描表
*
* @param classList
*/
@Override
public
void
swaggerScan
(
List
<
Class
<?>>
classList
)
{
for
(
Class
<?>
aClass
:
classList
)
{
...
...
@@ -234,7 +249,7 @@ public class ModelImpl implements ModelService {
TableVO
tableVO
=
new
TableVO
();
String
className
=
getClassName
(
aClass
.
toString
());
//入表真实名称
String
realName
=
className
.
toLowerCase
()
+
"_model_test"
;
String
realName
=
className
.
toLowerCase
()
+
"_model_test"
;
tableVO
.
setModelName
(
realName
);
//获得类中文描述
if
(
aClass
.
isAnnotationPresent
(
ApiModel
.
class
))
{
...
...
@@ -260,8 +275,8 @@ public class ModelImpl implements ModelService {
ColumnVO
columnVO
=
new
ColumnVO
();
//获得类型
genericType
=
declaredField
.
getGenericType
();
//是否主键
if
(
declaredField
.
isAnnotationPresent
(
javax
.
persistence
.
Id
.
class
)){
//是否主键
if
(
declaredField
.
isAnnotationPresent
(
javax
.
persistence
.
Id
.
class
))
{
columnVO
.
setPrimaryKey
(
0
);
}
columnVO
.
setFieldType
(
getTypeName
(
genericType
.
toString
()));
...
...
@@ -289,9 +304,9 @@ public class ModelImpl implements ModelService {
tableInfo
.
setName
(
tableVO
.
getModelName
());
tableInfo
.
setCnName
(
tableVO
.
getModelTitle
());
tableInfo
.
setXml
(
xml
);
tableInfo
.
setType
(
0
);
tableInfo
.
set
Model
Type
(
0
);
//判断是否存在
if
(
checkRepeat
(
realName
)){
if
(
checkRepeat
(
realName
))
{
tableInfo
=
tableInfoDao
.
save
(
tableInfo
);
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
for
(
ColumnVO
columnVO
:
dataList
)
{
...
...
@@ -302,37 +317,38 @@ public class ModelImpl implements ModelService {
columnInfo
.
setCnName
(
columnVO
.
getFieldDescription
());
columnInfo
.
setPrimaryKey
(
columnVO
.
getPrimaryKey
());
//暂定 简单类型
if
(
"class java.lang.String"
.
equals
(
genericType
.
toString
())){
columnInfo
.
setLength
(
255
);
}
else
if
(
"class java.lang.Integer"
.
equals
(
genericType
.
toString
()))
{
columnInfo
.
setLength
(
11
);
}
else
if
(
"class java.lang.Double"
.
equals
(
genericType
.
toString
()))
{
columnInfo
.
setLength
(
10
);
}
else
{
columnInfo
.
setLength
(
0
);
}
// if ("class java.lang.String".equals(genericType.toString())){
// columnInfo.setLength(255);
// } else if ("class java.lang.Integer".equals(genericType.toString())) {
// columnInfo.setLength(11);
//
// } else if ("class java.lang.Double".equals(genericType.toString())) {
// columnInfo.setLength(10);
// }
// else {
// columnInfo.setLength(0);
// }
setLength
(
columnInfo
,
genericType
);
columnInfo
.
setDbName
(
className
);
columnInfo
.
setDbId
(
tableInfo
.
getId
());
columnInfoDao
.
save
(
columnInfo
);
}
}
else
{
log
.
info
(
"{}已存在"
,
className
);
}
else
{
log
.
info
(
"{}已存在"
,
className
);
}
}
}
}
}
/**
* @Author WWW
* @Description 判重
* @Date 10:50 2021/3/11
* @param tableName
* @return boolean
**/
/**
* @param tableName
* @return boolean
* @Author WWW
* @Description 判重
* @Date 10:50 2021/3/11
**/
public
boolean
checkRepeat
(
String
tableName
)
{
Specification
spec
=
(
Specification
)
(
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
Path
name
=
root
.
get
(
"name"
);
...
...
@@ -342,7 +358,7 @@ public class ModelImpl implements ModelService {
List
<
TableInfo
>
all
=
tableInfoDao
.
findAll
(
spec
);
for
(
TableInfo
tableInfo
:
all
)
{
String
name
=
tableInfo
.
getName
();
String
name
=
tableInfo
.
getName
();
if
(
tableName
.
equals
(
name
))
{
return
false
;
}
...
...
@@ -350,40 +366,39 @@ public class ModelImpl implements ModelService {
return
true
;
}
/**
* @Author WWW
* @Description 通过表名查询所有信息
* @Date 10:51 2021/3/11
* @param name
* @return java.util.List
**/
/**
* @param name
* @return java.util.List
* @Author WWW
* @Description 通过表名查询所有信息
* @Date 10:51 2021/3/11
**/
@Override
public
List
findAllByName
(
String
name
)
{
if
(
name
!=
null
&&
name
!=
""
)
{
if
(
name
!=
null
&&
name
!=
""
)
{
try
{
return
Db
.
use
().
findAll
(
name
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
return
null
;
return
null
;
}
@Override
public
List
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
)
{
List
<
cn
.
hutool
.
db
.
Entity
>
list
=
null
;
if
(!
""
.
equals
(
tableName
)){
List
<
cn
.
hutool
.
db
.
Entity
>
list
=
null
;
if
(!
""
.
equals
(
tableName
))
{
String
query
=
createQuery
(
tableName
,
queryConditions
);
try
{
list
=
Db
.
use
().
query
(
query
);
list
=
Db
.
use
().
query
(
query
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
else
{
}
else
{
return
null
;
}
return
list
;
return
list
;
}
@Override
...
...
src/main/java/com/tykj/workflowcore/model_layer/utils/ClassTypeLength.java
0 → 100644
浏览文件 @
bf11cfa9
package
com
.
tykj
.
workflowcore
.
model_layer
.
utils
;
import
com.tykj.workflowcore.model_layer.model.ColumnInfo
;
/**
* @ClassName ClassTypeLength
* @Description TODO
* @Author WWW
* @Date 2021/3/15 9:53
* @Version 1.0
*/
public
class
ClassTypeLength
{
private
static
String
STRING
=
"class java.lang.String"
;
private
static
String
Integer
=
"class java.lang.Integer"
;
private
static
String
Double
=
"class java.lang.Double"
;
public
static
void
setLength
(
ColumnInfo
columnInfo
,
java
.
lang
.
reflect
.
Type
genericType
){
if
(
STRING
.
equals
(
genericType
.
toString
())){
columnInfo
.
setLength
(
255
);
}
else
if
(
Integer
.
equals
(
genericType
.
toString
()))
{
columnInfo
.
setLength
(
11
);
}
else
if
(
Double
.
equals
(
genericType
.
toString
()))
{
columnInfo
.
setLength
(
10
);
}
else
{
columnInfo
.
setLength
(
0
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论