Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
a39061a2
提交
a39061a2
authored
4月 07, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 扫描时length为null。
上级
c8ac74d4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
25 行增加
和
60 行删除
+25
-60
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+7
-8
ClassTypeLength.java
.../tykj/workflowcore/model_layer/utils/ClassTypeLength.java
+12
-15
CreateTableUtil.java
.../tykj/workflowcore/model_layer/utils/CreateTableUtil.java
+2
-33
WorkflowCoreApplicationTests.java
...a/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
+4
-4
没有找到文件。
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
a39061a2
...
...
@@ -11,6 +11,7 @@ import com.tykj.workflowcore.model_layer.entity.vo.*;
import
com.tykj.workflowcore.model_layer.entity.*
;
import
com.tykj.workflowcore.model_layer.myEnum.ModelType
;
import
com.tykj.workflowcore.model_layer.service.ModelService
;
import
com.tykj.workflowcore.model_layer.utils.CreateTableUtil
;
import
com.tykj.workflowcore.model_layer.utils.SessionUtil
;
import
com.tykj.workflowcore.model_layer.utils.SqlUtil
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -136,8 +137,7 @@ public class ModelImpl implements ModelService {
sessionUtil
.
addXml
(
xmlMapping
);
Session
session
=
sessionUtil
.
getSession
();
// CreateTableUtil creatTableUtil = new CreateTableUtil();
// Session session = creatTableUtil.getSession(entityManagerFactory, xmlMapping);
List
<
ColumnVO
>
dataList
=
tableVO
.
getDataList
();
TableInfo
tableInfo
=
new
TableInfo
();
...
...
@@ -222,10 +222,9 @@ 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);
*/
Session
newSession
=
sessionUtil
.
getSession
();
...
...
@@ -341,10 +340,10 @@ public class ModelImpl implements ModelService {
ColumnInfo
columnInfo
=
new
ColumnInfo
();
columnInfo
.
setFieldName
(
columnVO
.
getFieldName
());
columnInfo
.
setFieldType
(
columnVO
.
getFieldType
());
columnInfo
.
setFieldLength
(
columnVO
.
getFieldLength
(
));
columnInfo
.
setFieldLength
(
setLength
(
genericType
.
toString
()
));
columnInfo
.
setFieldTitle
(
columnVO
.
getFieldTitle
());
columnInfo
.
setPrimaryKey
(
columnVO
.
getPrimaryKey
());
setLength
(
columnInfo
,
genericType
.
toString
());
columnInfo
.
setDbName
(
className
);
columnInfo
.
setDbId
(
tableInfo
.
getId
());
columnInfoDao
.
save
(
columnInfo
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/utils/ClassTypeLength.java
浏览文件 @
a39061a2
package
com
.
tykj
.
workflowcore
.
model_layer
.
utils
;
import
com.tykj.workflowcore.model_layer.entity.ColumnInfo
;
/**
* @ClassName ClassTypeLength
* @Description TODO
...
...
@@ -11,23 +9,22 @@ import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
* @Version 1.0
*/
public
class
ClassTypeLength
{
public
static
String
STRING
=
"class java.lang.String"
;
public
static
String
Integer
=
"class java.lang.Integer"
;
public
static
String
Double
=
"class java.lang.Double"
;
public
static
void
setLength
(
ColumnInfo
columnInfo
,
String
genericType
){
public
static
String
STRING
=
"class java.lang.String"
;
public
static
String
Integer
=
"class java.lang.Integer"
;
public
static
String
Double
=
"class java.lang.Double"
;
public
static
int
setLength
(
String
genericType
)
{
int
length
;
if
(
STRING
.
equals
(
genericType
)){
columnInfo
.
setFieldLength
(
255
)
;
if
(
STRING
.
equals
(
genericType
))
{
length
=
255
;
}
else
if
(
Integer
.
equals
(
genericType
))
{
columnInfo
.
setFieldLength
(
11
);
length
=
11
;
}
else
if
(
Double
.
equals
(
genericType
))
{
columnInfo
.
setFieldLength
(
10
);
}
else
{
columnInfo
.
setFieldLength
(
0
);
length
=
10
;
}
else
{
length
=
0
;
}
return
length
;
}
}
src/main/java/com/tykj/workflowcore/model_layer/utils/CreateTableUtil.java
浏览文件 @
a39061a2
package
com
.
tykj
.
workflowcore
.
model_layer
.
utils
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.model_layer.entity.vo.ColumnVO
;
import
com.tykj.workflowcore.model_layer.entity.vo.TableVO
;
import
org.hibernate.Session
;
import
org.hibernate.SessionFactory
;
import
org.hibernate.boot.Metadata
;
import
org.hibernate.boot.MetadataSources
;
import
org.hibernate.boot.registry.StandardServiceRegistry
;
import
org.hibernate.tool.hbm2ddl.SchemaUpdate
;
import
org.hibernate.tool.schema.TargetType
;
import
sun.rmi.runtime.NewThreadAction
;
import
javax.persistence.EntityManagerFactory
;
import
java.io.ByteArrayInputStream
;
import
java.util.EnumSet
;
import
java.util.List
;
/**
...
...
@@ -55,26 +44,6 @@ public class CreateTableUtil {
}
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
()));
Metadata
metadata
=
metadataSources
.
buildMetadata
();
//更新数据库Schema,如果不存在就创建表,存在就更新字段,不会影响已有数据
SchemaUpdate
schemaUpdate
=
new
SchemaUpdate
();
schemaUpdate
.
execute
(
EnumSet
.
of
(
TargetType
.
DATABASE
),
metadata
,
serviceRegistry
);
metadata
=
metadataSources
.
buildMetadata
();
//创建会话工厂
SessionFactory
newSessionFactory
=
metadata
.
buildSessionFactory
();
//保存对象
Session
newSession
=
newSessionFactory
.
openSession
();
return
newSession
;
}
public
static
String
getClassName
(
String
aClass
)
{
...
...
src/main/test/java/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
浏览文件 @
a39061a2
...
...
@@ -478,14 +478,14 @@ class WorkflowCoreApplicationTests {
// }
@Test
public
void
testJSON
()
{
String
xml
=
tableInfoExDao
.
findById
(
3
).
get
().
getXml
();
String
xml
=
tableInfoExDao
.
findById
(
4
).
get
().
getXml
();
sessionUtil
.
addXml
(
xml
);
Session
session
=
sessionUtil
.
getSession
();
List
list
=
session
.
createQuery
(
"from
people_car
"
).
list
();
List
list
=
session
.
createQuery
(
"from
student_teacher_ref
"
).
list
();
System
.
out
.
println
(
list
);
String
jsonExample
=
modelHelper
.
getJsonExample
(
2
);
System
.
out
.
println
(
jsonExample
);
//
String jsonExample = modelHelper.getJsonExample(2);
//
System.out.println(jsonExample);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论