Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow-core
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow-core
Commits
722775bf
提交
722775bf
authored
3月 12, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model layer 代码规约检查
上级
b237fd37
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
151 行增加
和
86 行删除
+151
-86
EnableWorkFlowCore.java
.../com/tykj/workflowcore/annotation/EnableWorkFlowCore.java
+3
-0
WorkFlowCoreNoScan.java
...kflowcore/model_layer/annotatiion/WorkFlowCoreNoScan.java
+0
-1
ModelController.java
.../workflowcore/model_layer/controller/ModelController.java
+7
-8
ColumnInfo.java
...a/com/tykj/workflowcore/model_layer/model/ColumnInfo.java
+4
-1
ColumnVO.java
...ava/com/tykj/workflowcore/model_layer/model/ColumnVO.java
+1
-1
QueryCondition.java
...m/tykj/workflowcore/model_layer/model/QueryCondition.java
+3
-0
SearchTableInfoVo.java
...ykj/workflowcore/model_layer/model/SearchTableInfoVo.java
+20
-0
TableInfo.java
...va/com/tykj/workflowcore/model_layer/model/TableInfo.java
+5
-2
ModelService.java
...m/tykj/workflowcore/model_layer/service/ModelService.java
+50
-9
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+44
-54
CreatTableUtil.java
...m/tykj/workflowcore/model_layer/utils/CreatTableUtil.java
+11
-10
HqlUtil.java
...java/com/tykj/workflowcore/model_layer/utils/HqlUtil.java
+3
-0
没有找到文件。
src/main/java/com/tykj/workflowcore/annotation/EnableWorkFlowCore.java
浏览文件 @
722775bf
...
...
@@ -5,6 +5,9 @@ import org.springframework.context.annotation.Import;
import
java.lang.annotation.*
;
/**
* @author HASEE
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
})
@Documented
...
...
src/main/java/com/tykj/workflowcore/model_layer/annotatiion/WorkFlowCoreNoScan.java
浏览文件 @
722775bf
...
...
@@ -15,5 +15,4 @@ import java.lang.annotation.Target;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
TYPE
)
public
@interface
WorkFlowCoreNoScan
{
String
desc
=
"工作流核心不扫描!"
;
}
src/main/java/com/tykj/workflowcore/model_layer/controller/ModelController.java
浏览文件 @
722775bf
...
...
@@ -4,6 +4,7 @@ package com.tykj.workflowcore.model_layer.controller;
import
com.tykj.workflowcore.base.result.ResultUtil
;
import
com.tykj.workflowcore.model_layer.model.QueryCondition
;
import
com.tykj.workflowcore.model_layer.model.SearchTableInfoVo
;
import
com.tykj.workflowcore.model_layer.model.TableInfo
;
import
com.tykj.workflowcore.model_layer.model.TableVO
;
import
com.tykj.workflowcore.model_layer.service.ModelService
;
...
...
@@ -11,6 +12,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -43,11 +45,10 @@ public class ModelController {
**/
@ApiOperation
(
"得到所有数据表信息"
)
@RequestMapping
(
"/getAllEntity"
)
public
ResponseEntity
getAllEntity
()
{
List
<
TableInfo
>
tableInfos
=
null
;
public
ResponseEntity
getAllEntity
(
SearchTableInfoVo
searchTableInfoVo
)
{
Page
<
TableInfo
>
tableInfos
=
null
;
try
{
tableInfos
=
modelService
.
ListAllEntities
(
);
tableInfos
=
modelService
.
listAllEntities
(
searchTableInfoVo
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
...
...
@@ -80,16 +81,14 @@ public class ModelController {
**/
@ApiOperation
(
"新增数据模型"
)
@PostMapping
(
"/addModel"
)
//入参使用VO直接接收即可
//jsonStr -> TableVo
public
ResponseEntity
addModel
(
@RequestBody
TableVO
tableVO
)
throws
Exception
{
List
<
TableInfo
>
tableInfos
=
modelService
.
L
istAllEntities
();
List
<
TableInfo
>
tableInfos
=
modelService
.
l
istAllEntities
();
for
(
TableInfo
tableInfo
:
tableInfos
)
{
if
(
tableVO
.
getModelName
().
equals
(
tableInfo
.
getName
()))
{
return
ResultUtil
.
failed
(
"表已经存在!"
);
}
}
modelService
.
N
ewTable
(
tableVO
);
modelService
.
n
ewTable
(
tableVO
);
return
ResultUtil
.
success
(
""
,
"新建成功"
);
}
...
...
src/main/java/com/tykj/workflowcore/model_layer/model/ColumnInfo.java
浏览文件 @
722775bf
...
...
@@ -24,7 +24,10 @@ public class ColumnInfo {
@Column
(
name
=
"id"
)
private
long
id
;
//0是,1否
/**
* 0是,1否
*/
@Column
(
name
=
"primary_key"
)
private
Integer
primarykey
;
@Column
(
name
=
"name"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/model/ColumnVO.java
浏览文件 @
722775bf
...
...
@@ -18,7 +18,7 @@ public class ColumnVO {
private
String
filedType
;
private
String
fieldName
;
private
String
filedDescription
;
private
int
filedLength
;
private
Integer
filedLength
;
private
Integer
primarykey
=
1
;
}
src/main/java/com/tykj/workflowcore/model_layer/model/QueryCondition.java
浏览文件 @
722775bf
...
...
@@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author HASEE
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
src/main/java/com/tykj/workflowcore/model_layer/model/SearchTableInfoVo.java
0 → 100644
浏览文件 @
722775bf
package
com
.
tykj
.
workflowcore
.
model_layer
.
model
;
import
com.tykj.workflowcore.base.page.JpaCustomPage
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @ClassName SearchTableInfoVo
* @Description TODO
* @Author WWW
* @Date 2021/3/11 16:06
* @Version 1.0
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
SearchTableInfoVo
extends
JpaCustomPage
{
private
String
tableName
;
}
src/main/java/com/tykj/workflowcore/model_layer/model/TableInfo.java
浏览文件 @
722775bf
...
...
@@ -42,7 +42,10 @@ public class TableInfo implements Serializable {
@Column
(
name
=
"description"
)
private
String
desc
;
//0是扫描,1是自建
/**
*0是扫描,1是自建
*/
@Column
(
name
=
"type"
)
private
Integer
type
;
...
...
@@ -51,7 +54,7 @@ public class TableInfo implements Serializable {
@Lob
@Column
(
name
=
"xml"
)
private
String
XML
;
private
String
xml
;
@Column
(
name
=
"update_time"
)
private
Date
updateTime
;
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/ModelService.java
浏览文件 @
722775bf
...
...
@@ -3,10 +3,8 @@ package com.tykj.workflowcore.model_layer.service;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.tykj.workflowcore.model_layer.model.ColumnInfo
;
import
com.tykj.workflowcore.model_layer.model.QueryCondition
;
import
com.tykj.workflowcore.model_layer.model.TableInfo
;
import
com.tykj.workflowcore.model_layer.model.TableVO
;
import
com.tykj.workflowcore.model_layer.model.*
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -22,24 +20,67 @@ import java.util.Map;
* @Date 2021/2/26 13:36
* @Version 1.0
*/
@Transactional
@Service
public
interface
ModelService
{
List
<
TableInfo
>
ListAllEntities
()
throws
SQLException
;
/**
* 分页查询
* @param searchTableInfoVo
* @return
* @throws SQLException
*/
Page
<
TableInfo
>
listAllEntities
(
SearchTableInfoVo
searchTableInfoVo
)
throws
SQLException
;
/**
* 方法重载不分页查询
* @return
* @throws SQLException
*/
List
<
TableInfo
>
listAllEntities
()
throws
SQLException
;
List
<
ColumnInfo
>
showModelFields
(
String
ModelName
);
TableVO
addModel
(
String
tableVO
)
throws
JsonProcessingException
;
/**
* 根据表名查询所有字段信息
* @param modelName
* @return
*/
List
<
ColumnInfo
>
showModelFields
(
String
modelName
);
TableVO
NewTable
(
TableVO
tableVO
);
/**
* 新建模型
* @param tableVO
* @return
*/
TableVO
newTable
(
TableVO
tableVO
);
/**
* 根据表名插入数据
* @param map
* @return
*/
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
);
/**
* 扫描
* @param classList
*/
void
swaggerScan
(
List
<
Class
<?>>
classList
);
/**
* 根据表名查询所有
* @param name
* @return
* @throws SQLException
*/
List
findAllByName
(
String
name
)
throws
SQLException
;
/**
* 复杂查询
* @param tableName
* @param queryConditions
* @return
*/
List
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
);
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
722775bf
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
.
impl
;
import
cn.hutool.db.Db
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.tykj.workflowcore.model_layer.annotatiion.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.model_layer.dao.ColumnInfoDao
;
import
com.tykj.workflowcore.model_layer.dao.TableInfoDao
;
...
...
@@ -23,6 +22,7 @@ import org.hibernate.type.StringType;
import
org.hibernate.type.TimestampType
;
import
org.hibernate.type.Type
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -51,7 +51,7 @@ import static com.tykj.workflowcore.model_layer.utils.HqlUtil.createQuery;
* @Date 2021/2/26 13:39
* @Version 1.0
*/
@Transactional
@Service
@Slf4j
public
class
ModelImpl
implements
ModelService
{
...
...
@@ -74,48 +74,34 @@ public class ModelImpl implements ModelService {
* @Date 16:14 2021/3/5
**/
@Override
public
List
<
TableInfo
>
ListAllEntities
()
{
List
<
TableInfo
>
all
=
tableInfoDao
.
findAll
();
return
all
;
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
());
}
/**
* @param
T
ableName
* @param
t
ableName
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
* @Author WWW
* @Description 根据表名得到所有字段名
* @Date 16:15 2021/3/5
**/
@Override
public
List
<
ColumnInfo
>
showModelFields
(
String
T
ableName
)
{
public
List
<
ColumnInfo
>
showModelFields
(
String
t
ableName
)
{
Specification
specification
=
(
Specification
)
(
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
Path
db
_n
ame
=
root
.
get
(
"dbName"
);
Predicate
equal
=
criteriaBuilder
.
equal
(
db
_name
,
T
ableName
);
Path
db
N
ame
=
root
.
get
(
"dbName"
);
Predicate
equal
=
criteriaBuilder
.
equal
(
db
Name
,
t
ableName
);
return
equal
;
};
List
<
ColumnInfo
>
all
=
columnInfoDao
.
findAll
(
specification
);
return
all
;
}
/**
* @param jsonStr
* @return com.tykj.workflowcore.model_layer.model.TableVO
* @Author WWW
* @Description 将json字符串转换实体类
* @Date 16:15 2021/3/5
**/
@Override
public
TableVO
addModel
(
String
jsonStr
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
TableVO
tableVO
=
null
;
try
{
tableVO
=
mapper
.
readValue
(
jsonStr
,
TableVO
.
class
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
return
tableVO
;
}
/**
* @param tableVO
...
...
@@ -125,17 +111,17 @@ public class ModelImpl implements ModelService {
* @Date 16:16 2021/3/5
**/
@Override
public
TableVO
N
ewTable
(
TableVO
tableVO
)
{
public
TableVO
n
ewTable
(
TableVO
tableVO
)
{
String
XML_MAPPING
=
C
reatTable
(
tableVO
);
String
xmlMapping
=
c
reatTable
(
tableVO
);
CreatTableUtil
creatTableUtil
=
new
CreatTableUtil
();
Session
session
=
creatTableUtil
.
getSession
(
entityManagerFactory
,
XML_MAPPING
);
Session
session
=
creatTableUtil
.
getSession
(
entityManagerFactory
,
xmlMapping
);
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
TableInfo
tableInfo
=
new
TableInfo
();
tableInfo
.
setName
(
tableVO
.
getModelName
()+
"_"
);
tableInfo
.
setCnName
(
tableVO
.
getModelTitle
());
tableInfo
.
setX
ML
(
XML_MAPPING
);
tableInfo
.
setX
ml
(
xmlMapping
);
tableInfo
.
setType
(
2
);
tableInfoDao
.
save
(
tableInfo
);
...
...
@@ -181,12 +167,12 @@ public class ModelImpl implements ModelService {
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
//插入数据
insertValue
(
tableInfo
.
getName
(),
tableInfo
.
getX
ML
(),
(
Map
)
values
);
insertValue
(
tableInfo
.
getName
(),
tableInfo
.
getX
ml
(),
(
Map
)
values
);
}
else
{
//循环插入数据
List
valuesList
=
(
List
)
values
;
for
(
int
i
=
0
;
i
<
valuesList
.
size
();
i
++)
{
insertValue
(
tableInfo
.
getName
(),
tableInfo
.
getX
ML
(),
(
Map
)
valuesList
.
get
(
i
));
insertValue
(
tableInfo
.
getName
(),
tableInfo
.
getX
ml
(),
(
Map
)
valuesList
.
get
(
i
));
}
}
}
...
...
@@ -230,7 +216,7 @@ public class ModelImpl implements ModelService {
}
if
(
propertyType
instanceof
StringType
)
{
//然后调用强转方法
propertyNames
[
i
]
=
propertyNames
[
i
]
+
""
;
propertyNames
[
i
]
=
propertyNames
[
i
];
map
.
put
(
propertyNames
[
i
],
propertyNames
[
i
]);
}
}
...
...
@@ -253,16 +239,16 @@ public class ModelImpl implements ModelService {
//获得类中文描述
if
(
aClass
.
isAnnotationPresent
(
ApiModel
.
class
))
{
ApiModel
annotation
=
aClass
.
getAnnotation
(
ApiModel
.
class
);
StringBuilder
AP
iModelDocument
=
new
StringBuilder
();
if
(
annotation
.
value
()
!=
null
&&
!
annotation
.
value
().
equals
(
""
))
{
AP
iModelDocument
.
append
(
annotation
.
value
()
+
"|"
);
StringBuilder
ap
iModelDocument
=
new
StringBuilder
();
if
(
annotation
.
value
()
!=
null
&&
!
""
.
equals
(
annotation
.
value
()
))
{
ap
iModelDocument
.
append
(
annotation
.
value
()
+
"|"
);
}
if
(
annotation
.
description
()
!=
null
&&
!
annotation
.
description
().
equals
(
""
))
{
AP
iModelDocument
.
append
(
annotation
.
description
()
+
"|"
);
if
(
annotation
.
description
()
!=
null
&&
!
""
.
equals
(
annotation
.
description
()
))
{
ap
iModelDocument
.
append
(
annotation
.
description
()
+
"|"
);
}
tableVO
.
setModelTitle
(
AP
iModelDocument
.
toString
());
tableVO
.
setModelTitle
(
ap
iModelDocument
.
toString
());
}
else
{
tableVO
.
setModelTitle
(
""
);
}
...
...
@@ -284,25 +270,25 @@ public class ModelImpl implements ModelService {
//获得属性中文描述
if
(
declaredField
.
isAnnotationPresent
(
ApiModelProperty
.
class
))
{
ApiModelProperty
annotation
=
declaredField
.
getAnnotation
(
ApiModelProperty
.
class
);
StringBuilder
A
piModelPropertyDocument
=
new
StringBuilder
();
if
(
annotation
.
value
()
!=
null
&&
!
annotation
.
value
().
equals
(
""
))
{
A
piModelPropertyDocument
.
append
(
annotation
.
value
()
+
"|"
);
StringBuilder
a
piModelPropertyDocument
=
new
StringBuilder
();
if
(
annotation
.
value
()
!=
null
&&
!
""
.
equals
(
annotation
.
value
()
))
{
a
piModelPropertyDocument
.
append
(
annotation
.
value
()
+
"|"
);
}
if
(
annotation
.
example
()
!=
null
&&
!
annotation
.
example
().
equals
(
""
))
{
if
(
annotation
.
example
()
!=
null
&&
!
""
.
equals
(
annotation
.
example
()
))
{
A
piModelPropertyDocument
.
append
(
annotation
.
example
()
+
"|"
);
a
piModelPropertyDocument
.
append
(
annotation
.
example
()
+
"|"
);
}
columnVO
.
setFiledDescription
(
A
piModelPropertyDocument
.
toString
());
columnVO
.
setFiledDescription
(
a
piModelPropertyDocument
.
toString
());
}
else
{
columnVO
.
setFiledDescription
(
"无描述"
);
}
list
.
add
(
columnVO
);
}
tableVO
.
setDataList
(
list
);
String
xml
=
C
reatTable
(
tableVO
);
String
xml
=
c
reatTable
(
tableVO
);
tableInfo
.
setName
(
tableVO
.
getModelName
());
tableInfo
.
setCnName
(
tableVO
.
getModelTitle
());
tableInfo
.
setX
ML
(
xml
);
tableInfo
.
setX
ml
(
xml
);
tableInfo
.
setType
(
0
);
//判断是否存在
if
(
checkRepeat
(
realName
)){
...
...
@@ -316,12 +302,12 @@ public class ModelImpl implements ModelService {
columnInfo
.
setCnName
(
columnVO
.
getFiledDescription
());
columnInfo
.
setPrimarykey
(
columnVO
.
getPrimarykey
());
//暂定 简单类型
if
(
genericType
.
toString
().
equals
(
"class java.lang.String"
))
{
if
(
"class java.lang.String"
.
equals
(
genericType
.
toString
()))
{
columnInfo
.
setLength
(
255
);
}
else
if
(
genericType
.
toString
().
equals
(
"class java.lang.Integer"
)&&
genericType
.
toString
().
equals
(
"int"
))
{
}
else
if
(
"class java.lang.Integer"
.
equals
(
genericType
.
toString
()
))
{
columnInfo
.
setLength
(
11
);
}
else
if
(
genericType
.
toString
().
equals
(
"class java.lang.Double"
))
{
}
else
if
(
"class java.lang.Double"
.
equals
(
genericType
.
toString
()
))
{
columnInfo
.
setLength
(
10
);
}
else
{
...
...
@@ -386,7 +372,7 @@ public class ModelImpl implements ModelService {
@Override
public
List
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
)
{
List
<
cn
.
hutool
.
db
.
Entity
>
list
=
null
;
if
(!
tableName
.
equals
(
""
)){
if
(!
""
.
equals
(
tableName
)){
String
query
=
createQuery
(
tableName
,
queryConditions
);
try
{
list
=
Db
.
use
().
query
(
query
);
...
...
@@ -400,4 +386,8 @@ public class ModelImpl implements ModelService {
return
list
;
}
@Override
public
List
<
TableInfo
>
listAllEntities
()
{
return
tableInfoDao
.
findAll
();
}
}
src/main/java/com/tykj/workflowcore/model_layer/utils/CreatTableUtil.java
浏览文件 @
722775bf
package
com
.
tykj
.
workflowcore
.
model_layer
.
utils
;
import
cn.hutool.json.XML
;
import
com.tykj.workflowcore.model_layer.annotatiion.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.model_layer.model.ColumnVO
;
import
com.tykj.workflowcore.model_layer.model.TableInfo
;
...
...
@@ -32,38 +33,38 @@ import java.util.List;
* @Version 1.0
*/
public
class
CreatTableUtil
{
public
static
String
C
reatTable
(
TableVO
tableVO
){
public
static
String
c
reatTable
(
TableVO
tableVO
){
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
String
XML_MAPPING
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+
String
xmlMapping
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+
"<!DOCTYPE hibernate-mapping PUBLIC\n"
+
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
+
" \"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd\">\n"
+
"<hibernate-mapping>\n"
+
" <class entity-name=\""
+
tableVO
.
getModelName
()
+
"\" table=\""
+
tableVO
.
getModelName
()
+
"\">\n"
;
XML_MAPPING
+=
" <id name=\"id\" type=\"java.lang.Long\" length=\"64\" unsaved-value=\"null\">\n"
+
xmlMapping
+=
" <id name=\"id\" type=\"java.lang.Long\" length=\"64\" unsaved-value=\"null\">\n"
+
" <generator class=\"identity\" />\n"
+
" </id>"
;
for
(
ColumnVO
columnVO
:
dataList
)
{
XML_MAPPING
+=
xmlMapping
+=
" <property type=\""
+
columnVO
.
getFiledType
()
+
"\" name=\""
+
columnVO
.
getFieldName
()
+
"\" column=\""
+
columnVO
.
getFieldName
()
+
"\"/>\n"
;
}
XML_MAPPING
+=
" </class>"
+
xmlMapping
+=
" </class>"
+
"</hibernate-mapping>"
;
return
XML_MAPPING
;
return
xmlMapping
;
}
public
Session
getSession
(
EntityManagerFactory
entityManagerFactory
,
String
XML
){
public
Session
getSession
(
EntityManagerFactory
entityManagerFactory
,
String
xml
){
SessionFactory
sessionFactory
=
entityManagerFactory
.
unwrap
(
SessionFactory
.
class
);
StandardServiceRegistry
serviceRegistry
=
sessionFactory
.
getSessionFactoryOptions
().
getServiceRegistry
();
MetadataSources
metadataSources
=
new
MetadataSources
(
serviceRegistry
);
sessionFactory
.
getSessionFactoryOptions
();
metadataSources
.
addInputStream
(
new
ByteArrayInputStream
(
XML
.
getBytes
()));
metadataSources
.
addInputStream
(
new
ByteArrayInputStream
(
xml
.
getBytes
()));
Metadata
metadata
=
metadataSources
.
buildMetadata
();
//更新数据库Schema,如果不存在就创建表,存在就更新字段,不会影响已有数据
SchemaUpdate
schemaUpdate
=
new
SchemaUpdate
();
...
...
@@ -79,13 +80,13 @@ public class CreatTableUtil {
}
//处理.
public
static
String
getClassName
(
String
aClass
){
int
i
=
aClass
.
lastIndexOf
(
"."
);
String
substring
=
aClass
.
substring
(
i
+
1
);
return
substring
;
}
// 处理带空格的class
public
static
String
getTypeName
(
String
aClass
){
return
aClass
.
replace
(
"class "
,
""
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/utils/HqlUtil.java
浏览文件 @
722775bf
...
...
@@ -5,6 +5,9 @@ import com.tykj.workflowcore.model_layer.model.QueryCondition;
import
java.util.List
;
import
java.util.Objects
;
/**
* @author HASEE
*/
public
class
HqlUtil
{
public
static
String
createQuery
(
String
tableName
,
List
<
QueryCondition
>
conditions
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论