Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
b059a384
提交
b059a384
编写于
8月 25, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
2cc4ed8f
变更
17
展开全部
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
655 行增加
和
173 行删除
+655
-173
pom.xml
ibzdata-boot/pom.xml
+0
-5
DevBootApplication.java
...ata-boot/src/main/java/cn/ibizlab/DevBootApplication.java
+1
-0
pom.xml
ibzdata-core/pom.xml
+62
-6
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+20
-4
DSSetting.java
.../src/main/java/cn/ibizlab/core/data/domain/DSSetting.java
+6
-16
DSSettingSearchContext.java
...a/cn/ibizlab/core/data/filter/DSSettingSearchContext.java
+2
-1
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+8
-8
DbDataMapper.java
...c/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
+196
-2
DSLink.java
...core/src/main/java/cn/ibizlab/core/data/model/DSLink.java
+22
-4
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+3
-1
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+1
-2
IDSSettingService.java
.../java/cn/ibizlab/core/data/service/IDSSettingService.java
+2
-11
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+70
-31
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+19
-6
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+29
-8
DSSettingServiceImpl.java
.../ibizlab/core/data/service/impl/DSSettingServiceImpl.java
+120
-27
DbDataServiceImpl.java
.../cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
+94
-41
未找到文件。
ibzdata-boot/pom.xml
浏览文件 @
b059a384
...
...
@@ -14,11 +14,6 @@
<description>
Ibzdata Boot
</description>
<dependencies>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-util
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-core
</artifactId>
...
...
ibzdata-boot/src/main/java/cn/ibizlab/DevBootApplication.java
浏览文件 @
b059a384
...
...
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
@EnableTransactionManagement
@EnableFeignClients
(
basePackages
=
{
"cn.ibizlab"
})
@SpringBootApplication
(
exclude
=
{
com
.
alibaba
.
druid
.
spring
.
boot
.
autoconfigure
.
DruidDataSourceAutoConfigure
.
class
})
@ComponentScan
(
basePackages
=
{
"cn.ibizlab"
}
// ,excludeFilters = {
...
...
ibzdata-core/pom.xml
浏览文件 @
b059a384
...
...
@@ -14,6 +14,7 @@
<description>
Ibzdata Core
</description>
<dependencies>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-commons
</artifactId>
...
...
@@ -29,7 +30,15 @@
<artifactId>
logstash-logback-encoder
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
...
...
@@ -42,6 +51,22 @@
</dependency>
<dependency>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
</dependency>
<dependency>
<groupId>
com.esotericsoftware
</groupId>
<artifactId>
kryo-shaded
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-pool2
</artifactId>
</dependency>
<!-- Swagger2 -->
<dependency>
<groupId>
io.springfox
</groupId>
...
...
@@ -58,6 +83,23 @@
</dependency>
<dependency>
<groupId>
org.flowable
</groupId>
<artifactId>
flowable-json-converter
</artifactId>
</dependency>
<dependency>
<groupId>
org.flowable
</groupId>
<artifactId>
flowable-ui-modeler-conf
</artifactId>
<exclusions>
<exclusion>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-slf4j-impl
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JBPM -->
<dependency>
...
...
@@ -86,7 +128,6 @@
<groupId>
org.kie
</groupId>
<artifactId>
kie-api
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
...
...
@@ -104,6 +145,15 @@
<artifactId>
druid
</artifactId>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-jdk8
</artifactId>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
</dependency>
<!--MongoDB-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -126,6 +176,12 @@
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.2.7
</version>
<exclusions>
<exclusion>
<artifactId>
slf4j-simple
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
b059a384
...
...
@@ -6,6 +6,7 @@ import cn.ibizlab.core.data.dto.BaseData;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
...
...
@@ -123,6 +124,13 @@ public class DOModel implements Serializable {
@ApiModelProperty
(
"存储"
)
private
String
poModels
;
public
String
getPoModels
()
{
if
(
StringUtils
.
isEmpty
(
poModels
)&&
this
.
poSchemas
!=
null
)
poModels
=
JSON
.
toJSONString
(
poSchemas
);
return
poModels
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getKeyPropertyName
()
...
...
@@ -278,9 +286,11 @@ public class DOModel implements Serializable {
}
public
POSchema
getPOSchema
(
String
name
)
{
name
=
"mysql5"
;
if
(
StringUtils
.
isEmpty
(
name
)&&
this
.
getSchema
()!=
null
)
if
(
StringUtils
.
isEmpty
(
name
)&&
this
.
getSchema
()!=
null
&&(!
StringUtils
.
isEmpty
(
this
.
getSchema
().
getDefaultDataSoruce
()))
)
name
=
this
.
getSchema
().
getDefaultDataSoruce
();
if
(
StringUtils
.
isEmpty
(
name
))
name
=
"mysql"
;
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
...
...
@@ -288,12 +298,18 @@ public class DOModel implements Serializable {
{
return
poSchemas
.
get
(
name
);
}
else
if
(
this
.
getSchema
()!=
null
&&(
"default"
.
equals
(
name
)||
this
.
getSchema
().
getDefaultDataSoruce
().
equals
(
name
)))
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
);
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equals
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
return
poSchemas
.
get
(
vendorProvider
);
if
(
this
.
getSchema
()!=
null
&&(
"default"
.
equals
(
name
)||
this
.
getSchema
().
getDefaultDataSoruce
().
equalsIgnoreCase
(
name
)))
{
POSchema
defaultPOSchema
=
TransUtils
.
PojoSchema2PO
(
this
.
getSchema
());
if
(
defaultPOSchema
!=
null
)
{
poSchemas
.
put
(
"default"
,
defaultPOSchema
);
poSchemas
.
put
(
this
.
getSchema
().
getDefaultDataSoruce
(),
defaultPOSchema
);
if
(!
StringUtils
.
isEmpty
(
this
.
getSchema
().
getDefaultDataSoruce
()))
poSchemas
.
put
(
this
.
getSchema
().
getDefaultDataSoruce
().
toLowerCase
(),
defaultPOSchema
);
return
defaultPOSchema
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DSSetting.java
浏览文件 @
b059a384
package
cn
.
ibizlab
.
core
.
data
.
domain
;
import
java.sql.Timestamp
;
import
java.util.*
;
import
java.math.BigInteger
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
cn.ibizlab.core.data.dto.DataObj
;
import
cn.ibizlab.core.data.lite.MetaEntityModel
;
import
cn.ibizlab.core.data.lite.Setting
;
import
cn.ibizlab.core.data.model.DSLink
Config
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.dynamic.datasource.DynamicRoutingDataSource
;
import
com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.DigestUtils
;
import
java.io.Serializable
;
import
lombok.*
;
import
org.springframework.data.annotation.Transient
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.util.StringUtils
;
...
...
@@ -170,14 +160,14 @@ public class DSSetting implements Serializable {
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
DSLink
Config
dsLinkConfig
;
private
DSLink
dsLinkConfig
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
DSLink
Config
getDSLinkConfig
()
public
DSLink
getDSLinkConfig
()
{
if
(
dsLinkConfig
==
null
)
{
dsLinkConfig
=
new
DSLink
Config
().
setName
(
this
.
getDsId
()).
setDescription
(
this
.
getDsName
()).
setDriverClassName
(
this
.
getStringValue
(
"driver-class-name"
))
dsLinkConfig
=
new
DSLink
().
setName
(
this
.
getDsId
()).
setDescription
(
this
.
getDsName
()).
setDriverClassName
(
this
.
getStringValue
(
"driver-class-name"
))
.
setUrl
(
this
.
getStringValue
(
"url"
,
this
.
getStringValue
(
"uri"
)))
.
setUsername
(
this
.
getStringValue
(
"username"
)).
setPassword
(
this
.
getStringValue
(
"password"
))
.
setSchema
(
this
.
getStringValue
(
"defaultSchema"
,
this
.
getStringValue
(
"schema"
)));
...
...
@@ -193,7 +183,7 @@ public class DSSetting implements Serializable {
}
return
dsLinkConfig
;
}
public
DSSetting
setDSLinkConfig
(
DSLink
Config
dsLinkConfig
)
public
DSSetting
setDSLinkConfig
(
DSLink
dsLinkConfig
)
{
if
(
dsLinkConfig
!=
null
)
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/DSSettingSearchContext.java
浏览文件 @
b059a384
...
...
@@ -24,7 +24,8 @@ import org.springframework.util.StringUtils;
@Data
public
class
DSSettingSearchContext
extends
SearchContextBase
{
private
String
n_dsname_like
;
//[数据源名称]
private
String
n_dstype_like
;
//[数据源名称]
private
String
n_dsid_like
;
//[数据源名称]
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
b059a384
...
...
@@ -206,9 +206,9 @@ public class DynamicModelService {
if
(
dataEntity
.
getAllPSDEDBConfigs
()!=
null
)
{
dataEntity
.
getAllPSDEDBConfigs
().
forEach
(
item
->{
dsTypes
.
add
(
item
.
getDBType
().
toLowerCase
());
dsTypes
.
add
(
item
.
getDBType
().
toLowerCase
()
.
replace
(
"mysql5"
,
"mysql"
)
);
if
(!
entityModel
.
getTableName
().
equalsIgnoreCase
(
item
.
getTableName
()))
entityModel
.
getEntity
().
set
(
"table-"
+
item
.
getDBType
().
toLowerCase
(),
item
.
getTableName
());
entityModel
.
getEntity
().
set
(
"table-"
+
item
.
getDBType
().
toLowerCase
()
.
replace
(
"mysql5"
,
"mysql"
)
,
item
.
getTableName
());
});
}
...
...
@@ -233,7 +233,7 @@ public class DynamicModelService {
{
defield
.
getAllPSDEFDTColumns
().
forEach
(
col
->{
if
(!
metaFieldModel
.
getFieldName
().
equalsIgnoreCase
(
col
.
getColumnName
()))
metaFieldModel
.
set
(
"column-"
+
col
.
getDBType
().
toLowerCase
(),
col
.
getColumnName
());
metaFieldModel
.
set
(
"column-"
+
col
.
getDBType
().
toLowerCase
()
.
replace
(
"mysql5"
,
"mysql"
)
,
col
.
getColumnName
());
if
(
StringUtils
.
isEmpty
(
metaFieldModel
)&&
defield
.
isFormulaDEField
()&&(!
StringUtils
.
isEmpty
(
col
.
getQueryCodeExp
())))
metaFieldModel
.
setExpression
(
col
.
getQueryCodeExp
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
));
});
...
...
@@ -331,7 +331,7 @@ public class DynamicModelService {
String
code
=
getQueryCode
(
dq
);
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
())
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
()
.
replace
(
"mysql5"
,
"mysql"
)
)
.
setDatasetName
(
dataQuery
.
getLogicName
()).
setCodeName
(
dataQuery
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
code
);
entityModel
.
addDataSet
(
dsModel
);
...
...
@@ -442,14 +442,14 @@ public class DynamicModelService {
if
(
dataSet
.
getMajorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
column
=
dataSet
.
getMajorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
(),
false
);
IPSDEFDTColumn
column
=
dataSet
.
getMajorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
()
.
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
)
,
false
);
sql
=
sql
.
concat
(
" order by "
).
concat
(
column
==
null
?
dataSet
.
getMajorSortPSDEField
().
getName
():
column
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMajorSortDir
()))
sql
=
sql
.
concat
(
" "
).
concat
(
dataSet
.
getMajorSortDir
());
if
(
dataSet
.
getMinorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
subCol
=
dataSet
.
getMinorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
(),
false
);
IPSDEFDTColumn
subCol
=
dataSet
.
getMinorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
()
.
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
)
,
false
);
sql
=
sql
.
concat
(
","
).
concat
(
subCol
==
null
?
dataSet
.
getMinorSortPSDEField
().
getName
():
subCol
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMinorSortDir
()))
...
...
@@ -458,9 +458,9 @@ public class DynamicModelService {
}
}
}
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
())
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
()
.
replace
(
"mysql5"
,
"mysql"
)
)
.
setDatasetName
(
dataSet
.
getLogicName
()).
setCodeName
(
dataSet
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
entry
.
getValue
()).
setDsModel
(
sql
);
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
entry
.
getValue
()
.
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
)
).
setDsModel
(
sql
);
entityModel
.
addDataSet
(
dsModel
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
浏览文件 @
b059a384
...
...
@@ -3,11 +3,10 @@ package cn.ibizlab.core.data.mapper;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.model.POSchema
;
import
com.baomidou.
mybatisplus.core.conditions.Wrapp
er
;
import
com.baomidou.
dynamic.datasource.toolkit.DynamicDataSourceContextHold
er
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Update
;
...
...
@@ -52,4 +51,199 @@ public interface DbDataMapper {
@Select
(
"${sql}"
)
Page
<
BaseData
>
queryData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"srf"
)
FilterData
context
,
@Param
(
"ew"
)
QueryWrapper
wrapper
,
IPage
page
);
default
int
insertData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
insertData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
insertBathData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
insertBathData
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
updateData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
updateData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
updateBathData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
updateBathData
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
removeData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
removeData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
removeBathData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
removeBathData
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
save
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
save
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
saveBatch
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
saveBatch
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
int
countData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
countData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
List
<
BaseData
>
getData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
getData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
List
<
BaseData
>
getBatchData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
getBatchData
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
List
<
BaseData
>
getBatchKey
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
getBatchKey
(
schema
,
list
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
List
<
BaseData
>
selectData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
selectData
(
schema
,
data
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
default
Page
<
BaseData
>
selectData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
,
IPage
page
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
selectData
(
schema
,
data
,
page
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
@Update
(
"${sql}"
)
default
boolean
executeRaw
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"param"
)
BaseData
param
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
executeRaw
(
schema
,
sql
,
param
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
@Select
(
"${sql}"
)
default
List
<
BaseData
>
queryData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"srf"
)
FilterData
context
,
@Param
(
"ew"
)
QueryWrapper
wrapper
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
queryData
(
schema
,
sql
,
context
,
wrapper
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
@Select
(
"${sql}"
)
default
Page
<
BaseData
>
queryData
(
String
ds
,
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"srf"
)
FilterData
context
,
@Param
(
"ew"
)
QueryWrapper
wrapper
,
IPage
page
){
try
{
DynamicDataSourceContextHolder
.
push
(
ds
);
return
queryData
(
schema
,
sql
,
context
,
wrapper
,
page
);
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/DSLink
Config
.java
→
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/DSLink.java
浏览文件 @
b059a384
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
...
...
@@ -12,15 +11,18 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.Set
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DSLinkConfig
{
public
class
DSLink
{
private
String
name
;
private
String
description
;
private
String
type
;
...
...
@@ -59,4 +61,20 @@ public class DSLinkConfig {
return
"cassandra"
.
equalsIgnoreCase
(
this
.
getType
());
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
DSLink
push
()
{
if
(
this
.
isDatabase
()&&(!
StringUtils
.
isEmpty
(
name
)))
DynamicDataSourceContextHolder
.
push
(
name
);
return
this
;
}
private
static
DSLink
defaultLink
;
public
static
DSLink
getDefaultLink
()
{
if
(
defaultLink
==
null
)
defaultLink
=
new
DSLink
().
setName
(
"master"
).
setType
(
"mysql"
);
return
defaultLink
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
b059a384
...
...
@@ -585,7 +585,7 @@ public class POSchema {
return
this
;
}
p
rivate
static
Map
<
String
,
String
>
provider
=
new
HashMap
<
String
,
String
>(){{
p
ublic
static
Map
<
String
,
String
>
provider
=
new
HashMap
<
String
,
String
>(){{
put
(
"oracle"
,
"oracle"
);
put
(
"mysql"
,
"mysql"
);
put
(
"mysql5"
,
"mysql"
);
...
...
@@ -603,6 +603,8 @@ public class POSchema {
{
if
(
segments
!=
null
)
{
if
(
StringUtils
.
isEmpty
(
type
))
type
=
this
.
getDsType
();
String
vendorProvider
=
StringUtils
.
isEmpty
(
type
)?
""
:
provider
.
get
(
type
.
toLowerCase
());
for
(
Segment
script:
segments
)
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
b059a384
...
...
@@ -310,7 +310,7 @@ public class TransUtils {
public
static
POSchema
EntityModelModel2PO
(
EntityModel
entityModel
,
String
dsType
)
{
final
String
dataSourceType
=
dsType
.
toLowerCase
();
POSchema
poSchema
=
new
POSchema
().
setDsType
(
d
sType
).
setName
(
entityModel
.
getTableName
(
ds
Type
)).
setDefaultDataSource
(
entityModel
.
getDsName
())
POSchema
poSchema
=
new
POSchema
().
setDsType
(
d
ataSourceType
).
setName
(
entityModel
.
getTableName
(
dataSource
Type
)).
setDefaultDataSource
(
entityModel
.
getDsName
())
.
setRemarks
(
entityModel
.
getLogicName
()).
setLogicVal
(
entityModel
.
getLogicVal
()).
setLogicDelVal
(
entityModel
.
getLogicDelVal
());
...
...
@@ -325,7 +325,6 @@ public class TransUtils {
String
colName
=
fieldModel
.
getColumnName
(
dataSourceType
);
String
dataType
=
sub
.
getDataType
();
Integer
length
=
sub
.
getDataLength
();
Integer
precision
=
sub
.
getDataPreci
();
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDSSettingService.java
浏览文件 @
b059a384
package
cn
.
ibizlab
.
core
.
data
.
service
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.HashMap
;
import
java.util.Collection
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.model.DSLink
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.scheduling.annotation.Async
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.cache.annotation.CacheEvict
;
import
cn.ibizlab.core.data.domain.DSSetting
;
import
cn.ibizlab.core.data.filter.DSSettingSearchContext
;
...
...
@@ -36,7 +27,7 @@ public interface IDSSettingService {
boolean
save
(
DSSetting
et
);
void
saveBatch
(
List
<
DSSetting
>
list
);
Page
<
DSSetting
>
searchDefault
(
DSSettingSearchContext
context
);
DS
Setting
ini
tDataSource
(
String
tag
);
DS
Link
ge
tDataSource
(
String
tag
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
b059a384
...
...
@@ -67,6 +67,8 @@ public class ModelService {
{
Map
<
String
,
DstSystemModel
>
models
=
dynamicService
.
findAllDynamicModel
();
try
{
List
<
DstSystemModel
>
liteSystems
=
liteService
.
getSysApps
();
if
(!
ObjectUtils
.
isEmpty
(
liteSystems
))
{
...
...
@@ -78,6 +80,12 @@ public class ModelService {
models
.
put
(
system
.
toLowerCase
(),
dstSystemModel
);
});
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"dst接口访问异常"
,
ex
);
}
File
modelDir
=
new
File
(
getModelPath
());
if
(
modelDir
.
exists
())
...
...
@@ -115,6 +123,7 @@ public class ModelService {
entities
.
put
(
entity
.
getKey
(),
id
);
});
try
{
List
<
MetaEntityModel
>
liteEntities
=
liteService
.
getEntityModel
(
system
);
if
(!
ObjectUtils
.
isEmpty
(
liteEntities
))
{
...
...
@@ -138,6 +147,12 @@ public class ModelService {
});
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"dst接口访问异常"
,
ex
);
}
File
dir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
,
"domain"
).
toFile
();
if
(
dir
.
exists
())
...
...
@@ -154,7 +169,31 @@ public class ModelService {
}
}
return
null
;
return
entities
;
}
public
EntityModel
getEntityModel
(
String
system
,
String
entity
)
{
EntityModel
entityModel
=
null
;
try
{
entityModel
=
dynamicService
.
getDynamicEntity
(
system
,
entity
);
}
catch
(
Exception
exception
)
{
}
try
{
if
(
entityModel
==
null
)
entityModel
=
liteService
.
getProxyEntityModel
(
system
,
entity
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"dst接口访问异常"
,
ex
);
}
return
entityModel
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
b059a384
...
...
@@ -2,6 +2,8 @@ package cn.ibizlab.core.data.service.impl;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.dto.*
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -39,9 +41,17 @@ public class BaseDataService implements IDataService {
@Autowired
private
ModelService
modelService
;
@Autowired
private
IDSSettingService
dsSettingService
;
public
IDataService
getProxyService
(
String
datasource
)
{
if
(
datasource
.
indexOf
(
"mongo"
)>
0
)
DSLink
dsLink
=
dsSettingService
.
getDataSource
(
datasource
);
if
(
dsLink
.
isMongodb
())
return
mongoProxyService
;
else
if
(
dsLink
.
isElasticSearch
())
return
mongoProxyService
;
else
if
(
dsLink
.
isCassandra
())
return
mongoProxyService
;
else
return
dbProxyService
;
...
...
@@ -171,7 +181,8 @@ public class BaseDataService implements IDataService {
@Override
public
boolean
removeByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
removeByMap
(
model
,
scope
,
datasource
,
et
);
}
@Override
...
...
@@ -184,13 +195,15 @@ public class BaseDataService implements IDataService {
@Override
public
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
)
{
return
null
;
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
getBatch
(
model
,
scope
,
datasource
,
idList
);
}
@Override
public
BaseData
getByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
null
;
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
getByMap
(
model
,
scope
,
datasource
,
et
);
}
@Override
...
...
@@ -239,14 +252,14 @@ public class BaseDataService implements IDataService {
public
List
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataQuery
,
context
);
return
getProxyService
(
datasource
).
query
(
model
,
scope
,
datasource
,
dataQuery
,
context
);
}
@Override
public
Page
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataQuery
,
context
,
pageable
);
return
getProxyService
(
datasource
).
query
(
model
,
scope
,
datasource
,
dataQuery
,
context
,
pageable
);
}
@Override
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
b059a384
...
...
@@ -11,25 +11,26 @@ import java.util.*;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.DSLinkConfig
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
cn.ibizlab.core.data.service.ModelService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.beans.factory.annotation.Value
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Lazy
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.filter.DOModelSearchContext
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -39,8 +40,8 @@ import cn.ibizlab.core.data.service.IDOModelService;
@Service
public
class
DOModelServiceImpl
implements
IDOModelService
{
@
Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
@
Autowired
private
ModelService
modelService
;
@Override
public
boolean
create
(
DOModel
et
)
{
...
...
@@ -68,6 +69,7 @@ public class DOModelServiceImpl implements IDOModelService {
public
void
removeBatch
(
Collection
<
String
>
idList
){
}
@Cacheable
(
value
=
"domodel"
,
key
=
"'row:'+#p0"
)
@Override
public
DOModel
get
(
String
key
)
{
DOModel
doModel
=
new
DOModel
();
...
...
@@ -80,7 +82,26 @@ public class DOModelServiceImpl implements IDOModelService {
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
try
{
String
entityId
=
modelService
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
if
(
StringUtils
.
isEmpty
(
entityId
))
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
if
(!
key
.
equals
(
entityId
))
{
args
=
entityId
.
split
(
"[.]"
);
system
=
args
[
0
];
entity
=
args
[
2
];
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
}
}
catch
(
Exception
exception
)
{
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
}
}
if
(!
Files
.
exists
(
storePath
))
{
EntityModel
entityModel
=
modelService
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
if
(
schema
!=
null
)
...
...
@@ -95,7 +116,7 @@ public class DOModelServiceImpl implements IDOModelService {
}
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"repository"
,
entity
+
".json"
);
Path
poPath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
entityModel
.
getSystemId
(),
"repo"
,
entityModel
.
getEntityName
(),
"repository"
,
entityModel
.
getEntityName
()
+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
...
...
@@ -105,7 +126,7 @@ public class DOModelServiceImpl implements IDOModelService {
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
}
schema
.
writeTo
(
storePath
);
schema
.
writeTo
(
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
entityModel
.
getSystemId
(),
"repo"
,
entityModel
.
getEntityName
(),
"domain"
,
entityModel
.
getEntityName
()+
".json"
)
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DSSettingServiceImpl.java
浏览文件 @
b059a384
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
b059a384
此差异已折叠。
点击以展开。
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录