Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow-core
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow-core
Commits
265a73d1
提交
265a73d1
authored
3月 19, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 去掉hutool工具
上级
d632f671
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
18 行增加
和
37 行删除
+18
-37
ModelService.java
...m/tykj/workflowcore/model_layer/service/ModelService.java
+2
-2
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+15
-34
CreateTableUtil.java
.../tykj/workflowcore/model_layer/utils/CreateTableUtil.java
+1
-1
没有找到文件。
src/main/java/com/tykj/workflowcore/model_layer/service/ModelService.java
浏览文件 @
265a73d1
...
@@ -72,7 +72,7 @@ public interface ModelService {
...
@@ -72,7 +72,7 @@ public interface ModelService {
* @return
* @return
* @throws SQLException
* @throws SQLException
*/
*/
List
findAllByName
(
String
name
)
throws
SQLException
;
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
)
throws
SQLException
;
/**
/**
...
@@ -81,7 +81,7 @@ public interface ModelService {
...
@@ -81,7 +81,7 @@ public interface ModelService {
* @param queryConditions
* @param queryConditions
* @return
* @return
*/
*/
List
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
);
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
);
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
265a73d1
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
.
impl
;
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
.
impl
;
import
cn.hutool.db.Db
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.github.wenhao.jpa.Specifications
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
...
@@ -26,8 +24,8 @@ import org.hibernate.type.Type;
...
@@ -26,8 +24,8 @@ import org.hibernate.type.Type;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.EntityManagerFactory
;
import
javax.persistence.EntityManagerFactory
;
...
@@ -70,6 +68,9 @@ public class ModelImpl implements ModelService {
...
@@ -70,6 +68,9 @@ public class ModelImpl implements ModelService {
@Autowired
@Autowired
private
ColumnInfoDao
columnInfoDao
;
private
ColumnInfoDao
columnInfoDao
;
@Autowired
private
JdbcTemplate
jdbcTemplate
;
/**
/**
* @param
* @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
...
@@ -361,31 +362,22 @@ public class ModelImpl implements ModelService {
...
@@ -361,31 +362,22 @@ public class ModelImpl implements ModelService {
* @Date 10:51 2021/3/11
* @Date 10:51 2021/3/11
**/
**/
@Override
@Override
public
List
findAllByName
(
String
name
)
{
public
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
)
{
if
(
name
!=
null
&&
name
!=
""
)
{
if
(
name
!=
null
&&
name
!=
""
)
{
try
{
String
sql
=
"select * from "
+
name
;
return
Db
.
use
().
findAll
(
name
);
return
jdbcTemplate
.
queryForList
(
sql
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
}
return
null
;
return
null
;
}
}
@Override
@Override
public
List
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
)
{
public
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
QueryCondition
>
queryConditions
)
{
List
<
cn
.
hutool
.
db
.
Entity
>
list
=
null
;
if
(!
""
.
equals
(
tableName
))
{
if
(!
""
.
equals
(
tableName
))
{
String
query
=
createQuery
(
tableName
,
queryConditions
);
String
query
=
createQuery
(
tableName
,
queryConditions
);
try
{
return
jdbcTemplate
.
queryForList
(
query
);
list
=
Db
.
use
().
query
(
query
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
else
{
return
null
;
}
}
return
list
;
return
null
;
}
}
@Override
@Override
public
List
<
TableInfo
>
listAllEntities
()
{
public
List
<
TableInfo
>
listAllEntities
()
{
...
@@ -450,11 +442,8 @@ public class ModelImpl implements ModelService {
...
@@ -450,11 +442,8 @@ public class ModelImpl implements ModelService {
private
void
UpdateColumnName
(
String
tableName
,
String
oldColumnName
,
String
newColumnName
)
{
private
void
UpdateColumnName
(
String
tableName
,
String
oldColumnName
,
String
newColumnName
)
{
// ALTER TABLE stu rename column name to name2;
// ALTER TABLE stu rename column name to name2;
if
(
""
!=
tableName
&&
tableName
!=
null
){
if
(
""
!=
tableName
&&
tableName
!=
null
){
try
{
Db
.
use
().
execute
(
" ALTER TABLE "
+
tableName
+
" rename column "
+
oldColumnName
+
" to "
+
newColumnName
+
";"
);
jdbcTemplate
.
execute
(
" ALTER TABLE "
+
tableName
+
" rename column "
+
oldColumnName
+
" to "
+
newColumnName
+
";"
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
}
else
{
else
{
log
.
info
(
"列名:{}或者新列名:{}不合法!"
,
oldColumnName
,
newColumnName
);
log
.
info
(
"列名:{}或者新列名:{}不合法!"
,
oldColumnName
,
newColumnName
);
...
@@ -469,11 +458,7 @@ public class ModelImpl implements ModelService {
...
@@ -469,11 +458,7 @@ public class ModelImpl implements ModelService {
*/
*/
private
void
delOneColumn
(
String
tableName
,
String
columnName
)
{
private
void
delOneColumn
(
String
tableName
,
String
columnName
)
{
// ALTER TABLE fab2 DROP test1;
// ALTER TABLE fab2 DROP test1;
try
{
jdbcTemplate
.
execute
(
"ALTER TABLE "
+
tableName
+
" DROP "
+
columnName
+
";"
);
Db
.
use
().
execute
(
"ALTER TABLE "
+
tableName
+
" DROP "
+
columnName
+
";"
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
}
/**
/**
...
@@ -484,11 +469,7 @@ public class ModelImpl implements ModelService {
...
@@ -484,11 +469,7 @@ public class ModelImpl implements ModelService {
*/
*/
private
void
addOneColumn
(
String
tableName
,
String
columnName
,
String
type
)
{
private
void
addOneColumn
(
String
tableName
,
String
columnName
,
String
type
)
{
// alter table fab2 add test1 varchar(10) not Null;
// alter table fab2 add test1 varchar(10) not Null;
try
{
jdbcTemplate
.
execute
(
" alter table "
+
tableName
+
" add "
+
columnName
+
" "
+
type
);
Db
.
use
().
execute
(
" alter table "
+
tableName
+
" add "
+
columnName
+
" "
+
type
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
}
}
}
}
src/main/java/com/tykj/workflowcore/model_layer/utils/CreateTableUtil.java
浏览文件 @
265a73d1
...
@@ -50,7 +50,6 @@ public class CreateTableUtil {
...
@@ -50,7 +50,6 @@ public class CreateTableUtil {
public
Session
getSession
(
EntityManagerFactory
entityManagerFactory
,
String
xml
){
public
Session
getSession
(
EntityManagerFactory
entityManagerFactory
,
String
xml
){
SessionFactory
sessionFactory
=
entityManagerFactory
.
unwrap
(
SessionFactory
.
class
);
SessionFactory
sessionFactory
=
entityManagerFactory
.
unwrap
(
SessionFactory
.
class
);
StandardServiceRegistry
serviceRegistry
=
sessionFactory
.
getSessionFactoryOptions
().
getServiceRegistry
();
StandardServiceRegistry
serviceRegistry
=
sessionFactory
.
getSessionFactoryOptions
().
getServiceRegistry
();
MetadataSources
metadataSources
=
new
MetadataSources
(
serviceRegistry
);
MetadataSources
metadataSources
=
new
MetadataSources
(
serviceRegistry
);
...
@@ -68,6 +67,7 @@ public class CreateTableUtil {
...
@@ -68,6 +67,7 @@ public class CreateTableUtil {
Session
newSession
=
newSessionFactory
.
openSession
();
Session
newSession
=
newSessionFactory
.
openSession
();
return
newSession
;
return
newSession
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论