Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
ee4542c1
提交
ee4542c1
编写于
7月 23, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加逆向工程实体结构
上级
842f7825
变更
6
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
2363 行增加
和
8 行删除
+2363
-8
OracleDatabase.java
...src/main/java/liquibase/database/core/OracleDatabase.java
+688
-0
JdbcDatabaseSnapshot.java
...rc/main/java/liquibase/snapshot/JdbcDatabaseSnapshot.java
+1560
-0
DstDataSourceExService.java
...izlab/core/extensions/service/DstDataSourceExService.java
+2
-2
DstLiquibaseService.java
...lab/core/lite/extensions/service/DstLiquibaseService.java
+12
-6
DstLiquibaseConfiguration.java
.../core/lite/extensions/util/DstLiquibaseConfiguration.java
+74
-0
DstCoreResource.java
.../java/cn/ibizlab/api/rest/extensions/DstCoreResource.java
+27
-0
未找到文件。
ibzdst-boot/src/main/java/liquibase/database/core/OracleDatabase.java
0 → 100644
浏览文件 @
ee4542c1
此差异已折叠。
点击以展开。
ibzdst-boot/src/main/java/liquibase/snapshot/JdbcDatabaseSnapshot.java
0 → 100644
浏览文件 @
ee4542c1
此差异已折叠。
点击以展开。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/DstDataSourceExService.java
浏览文件 @
ee4542c1
...
...
@@ -2,7 +2,7 @@ package cn.ibizlab.core.extensions.service;
import
cn.ibizlab.core.lite.extensions.domain.SysModel
;
import
cn.ibizlab.core.lite.extensions.service.LiteCoreService
;
import
cn.ibizlab.core.lite.service.DstLiquibaseService
;
import
cn.ibizlab.core.lite.
extensions.
service.DstLiquibaseService
;
import
cn.ibizlab.core.lite.service.impl.DstDataSourceServiceImpl
;
import
cn.ibizlab.util.domain.LiquibaseProp
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
...
...
@@ -190,7 +190,7 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
lp
.
setDefaultSchema
(
datasourceMap
.
get
(
"defaultSchema"
).
toString
());
// 调用liquibase逆向工程的逻辑,生成一个xml,并返回一个SysModel对象
SysModel
sysModel
=
dstLiquibaseService
.
generateLiquibase
(
lp
,
datasourceMap
.
get
(
"defaultSystemId"
).
toString
());
liteCoreService
.
syncSysModel
(
sysModel
,
1
);
//
liteCoreService.syncSysModel(sysModel,1);
return
et
;
}
}
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/lite/service/DstLiquibaseService.java
→
ibzdst-core/src/main/java/cn/ibizlab/core/lite/
extensions/
service/DstLiquibaseService.java
浏览文件 @
ee4542c1
package
cn
.
ibizlab
.
core
.
lite
.
service
;
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
service
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
cn.ibizlab.core.lite.domain.MetaRelationship
;
import
cn.ibizlab.core.lite.extensions.domain.MetaEntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.SysModel
;
import
cn.ibizlab.core.lite.extensions.util.DstLiquibaseConfiguration
;
import
cn.ibizlab.core.util.config.LiquibaseConfiguration
;
import
cn.ibizlab.util.domain.LiquibaseProp
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.fastjson.JSON
;
import
liquibase.Liquibase
;
import
liquibase.database.Database
;
...
...
@@ -82,20 +84,19 @@ public class DstLiquibaseService{
private
String
dataDir
;
@Resource
public
LiquibaseConfiguration
l
iquibaseConfiguration
;
public
DstLiquibaseConfiguration
dstL
iquibaseConfiguration
;
public
SysModel
generateLiquibase
(
LiquibaseProp
liquibaseProp
,
String
name
)
{
SysModel
sysModel
=
liquibaseGenerateChangeLog
(
liquibaseProp
,
name
);
return
sysModel
;
}
@SneakyThrows
public
SysModel
liquibaseGenerateChangeLog
(
LiquibaseProp
liquibaseProp
,
String
name
){
// 根据指定数据源生成对象
String
liquibaseChangeLogPath
=
getChangeLog
();
SpringLiquibase
springLiquibase
=
liquibaseConfiguration
.
masterliquibase
(
liquibaseProp
);
Liquibase
liquibase
=
createLiquibase
(
springLiquibase
,
liquibaseChangeLogPath
);
Database
database
=
liquibase
.
getDatabase
();
File
file
=
new
File
(
liquibaseChangeLogPath
);
if
(!
file
.
getParentFile
().
exists
()){
file
.
getParentFile
().
mkdirs
();
...
...
@@ -103,6 +104,11 @@ public class DstLiquibaseService{
if
(!
file
.
exists
()){
file
.
createNewFile
();
}
SpringLiquibase
springLiquibase
=
dstLiquibaseConfiguration
.
dstliquibase
(
liquibaseProp
);
Liquibase
liquibase
=
createLiquibase
(
springLiquibase
,
liquibaseChangeLogPath
);
Database
database
=
liquibase
.
getDatabase
();
DiffOutputControl
diffOutputControl
=
new
DiffOutputControl
(
includeCatalog
,
includeSchema
,
includeTablespace
,
null
);
CommandLineUtils
.
doGenerateChangeLog
(
liquibaseChangeLogPath
,
database
,
catalogName
,
liquibaseProp
.
getDefaultSchema
(),
StringUtils
.
trimToNull
(
generateField
),
name
,
context
,
dataDir
,
diffOutputControl
);
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/util/DstLiquibaseConfiguration.java
0 → 100644
浏览文件 @
ee4542c1
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
util
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.sql.DataSource
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
org.apache.ibatis.mapping.VendorDatabaseIdProvider
;
import
org.apache.ibatis.mapping.DatabaseIdProvider
;
import
java.util.Properties
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
cn.ibizlab.util.domain.LiquibaseProp
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
liquibase.integration.spring.SpringLiquibase
;
import
org.springframework.util.StringUtils
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
@Configuration
public
class
DstLiquibaseConfiguration
{
/**
* 主数据源版本管理
* @param
* @return
*/
@Bean
@Lazy
public
SpringLiquibase
dstliquibase
(
LiquibaseProp
masterProperties
)
{
return
LiquibaseInit
(
masterProperties
);
}
/**
* liquibase初始化数据库
* @param properties
* @return
*/
private
SpringLiquibase
LiquibaseInit
(
LiquibaseProp
properties
){
DruidDataSource
druidDataSource
=
new
DruidDataSource
();
druidDataSource
.
setUsername
(
properties
.
getUsername
());
druidDataSource
.
setPassword
(
properties
.
getPassword
());
druidDataSource
.
setUrl
(
properties
.
getUrl
());
SpringLiquibase
liquibase
=
new
SpringLiquibase
();
liquibase
.
setDataSource
(
druidDataSource
);
liquibase
.
setChangeLog
(
getChangelog
(
properties
.
getIsSyncDBSchema
(),
properties
.
getConf
()));
liquibase
.
setContexts
(
"development,test,production"
);
liquibase
.
setShouldRun
(
true
);
liquibase
.
setDefaultSchema
(
properties
.
getDefaultSchema
());
return
liquibase
;
}
/**
* 获取数据库差异文件
* @param isSyncDBSchema 是否同步表结构
* @param conf //liquibase配置文件
* @return
*/
private
String
getChangelog
(
String
isSyncDBSchema
,
String
conf
){
String
defaultChangelog
=
"classpath:liquibase/empty.xml"
;
if
((!
StringUtils
.
isEmpty
(
isSyncDBSchema
))&&(!
StringUtils
.
isEmpty
(
conf
))){
if
(
isSyncDBSchema
.
toLowerCase
().
equals
(
"true"
))
defaultChangelog
=
conf
;
}
return
defaultChangelog
;
}
}
\ No newline at end of file
ibzdst-provider/ibzdst-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/DstCoreResource.java
浏览文件 @
ee4542c1
...
...
@@ -2,6 +2,7 @@ package cn.ibizlab.api.rest.extensions;
import
cn.ibizlab.core.dict.extensions.service.DictDstService
;
import
cn.ibizlab.core.lite.domain.DstSystem
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
cn.ibizlab.core.lite.extensions.domain.*
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
...
...
@@ -9,14 +10,19 @@ import cn.ibizlab.core.lite.extensions.model.Property;
import
cn.ibizlab.core.lite.extensions.service.LiteCoreService
;
import
cn.ibizlab.core.lite.extensions.service.LiteDataService
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.service.IMetaEntityService
;
import
cn.ibizlab.core.lite.service.IMetaFieldService
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.dict.Option
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
...
...
@@ -162,11 +168,32 @@ public class DstCoreResource {
return
ResponseEntity
.
ok
(
list
);
}
@Autowired
IMetaEntityService
metaEntityService
;
@Autowired
@Lazy
private
IMetaFieldService
fieldService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/dst/{system}/entitys"
,
"/lite/{system}/entitys"
})
public
ResponseEntity
<
List
<
EntityModel
>>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteModelService
.
getEntityModel
(
system
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{system}/metaentitys"
)
public
ResponseEntity
<
List
<
MetaEntity
>>
getMetaEntitys
(
@PathVariable
(
"system"
)
String
system
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
metaEntityService
.
list
(
Wrappers
.<
MetaEntity
>
lambdaQuery
().
eq
(
MetaEntity:
:
getSystemId
,
system
)));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{system}/metafieles"
)
public
ResponseEntity
<
List
<
MetaField
>>
getFields
(
@PathVariable
(
"system"
)
String
system
)
{
MetaFieldSearchContext
context
=
new
MetaFieldSearchContext
();
context
.
setSize
(
Integer
.
MAX_VALUE
);
context
.
setN_systemid_eq
(
system
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
fieldService
.
searchDefault
(
context
).
getContent
());
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/dst/{system}/entitys/{entity}"
,
"/lite/{system}/entitys/{entity}"
})
public
ResponseEntity
<
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteModelService
.
getEntityModel
(
system
,
entity
));
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录