Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
3fdab763
提交
3fdab763
编写于
9月 07, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
异常接管,底层框架升级
上级
36744792
变更
24
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
452 行增加
和
273 行删除
+452
-273
pom.xml
ibzdata-core/pom.xml
+6
-0
BaseData.java
...core/src/main/java/cn/ibizlab/core/data/dto/BaseData.java
+2
-0
FilterData.java
...re/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
+3
-4
DynamicEsContextHolder.java
...izlab/core/data/elasticsearch/DynamicEsContextHolder.java
+68
-0
DynamicEsTemplate.java
...cn/ibizlab/core/data/elasticsearch/DynamicEsTemplate.java
+23
-0
DstSystemModel.java
...c/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
+2
-2
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+6
-10
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+7
-3
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+7
-3
MongoDataRepository.java
.../cn/ibizlab/core/data/repository/MongoDataRepository.java
+5
-9
DataResource.java
...src/main/java/cn/ibizlab/core/data/rest/DataResource.java
+18
-8
PersistentResource.java
...in/java/cn/ibizlab/core/data/rest/PersistentResource.java
+6
-6
IDataService.java
.../main/java/cn/ibizlab/core/data/service/IDataService.java
+24
-0
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+20
-33
BaseDataServiceImpl.java
...n/ibizlab/core/data/service/impl/BaseDataServiceImpl.java
+33
-24
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+2
-2
DSSettingServiceImpl.java
.../ibizlab/core/data/service/impl/DSSettingServiceImpl.java
+3
-3
DTOModelServiceImpl.java
...n/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
+3
-4
DbPersistentServiceImpl.java
...izlab/core/data/service/impl/DbPersistentServiceImpl.java
+7
-10
MongoPersistentServiceImpl.java
...ab/core/data/service/impl/MongoPersistentServiceImpl.java
+8
-11
EsDBConfig.java
...src/main/java/cn/ibizlab/core/util/config/EsDBConfig.java
+45
-0
MongoDBConfig.java
.../main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
+1
-137
JSR310DateConverters.java
...ain/java/cn/ibizlab/util/helper/JSR310DateConverters.java
+149
-0
pom.xml
ibzdata-dependencies/pom.xml
+4
-4
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
3fdab763
...
@@ -160,6 +160,12 @@
...
@@ -160,6 +160,12 @@
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-elasticsearch
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<groupId>
com.baomidou
</groupId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/BaseData.java
浏览文件 @
3fdab763
...
@@ -205,6 +205,8 @@ public class BaseData extends DataObj
...
@@ -205,6 +205,8 @@ public class BaseData extends DataObj
public
BaseData
setKey
(
Object
key
)
public
BaseData
setKey
(
Object
key
)
{
{
if
(
ObjectUtils
.
isEmpty
(
key
))
return
this
;
return
this
.
set
(
"_id"
,
key
);
return
this
.
set
(
"_id"
,
key
);
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
浏览文件 @
3fdab763
...
@@ -17,6 +17,7 @@ import com.mongodb.QueryBuilder;
...
@@ -17,6 +17,7 @@ import com.mongodb.QueryBuilder;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -385,11 +386,9 @@ public class FilterData<T> extends BaseData
...
@@ -385,11 +386,9 @@ public class FilterData<T> extends BaseData
public
String
getSql
(
String
codename
)
public
String
getSql
(
String
codename
)
{
{
if
(
getPOSchema
()==
null
)
Assert
.
notNull
(
getPOSchema
(),
"未找到查询片段"
);
throw
new
BadRequestAlertException
(
"未找到存储配置"
,
"FilterData"
,
codename
);
POSchema
.
Segment
segment
=
getPOSchema
().
getSegment
(
codename
,
""
);
POSchema
.
Segment
segment
=
getPOSchema
().
getSegment
(
codename
,
""
);
if
(
segment
==
null
)
Assert
.
notNull
(
segment
,
"未找到查询片段"
+
codename
);
throw
new
BadRequestAlertException
(
"未找到查询方法配置"
,
"FilterData"
,
codename
);
String
sql
=
segment
.
getBody
();
String
sql
=
segment
.
getBody
();
QueryWrapper
qw
=
this
.
getSearchCond
();
QueryWrapper
qw
=
this
.
getSearchCond
();
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/elasticsearch/DynamicEsContextHolder.java
0 → 100644
浏览文件 @
3fdab763
package
cn
.
ibizlab
.
core
.
data
.
elasticsearch
;
import
cn.ibizlab.core.data.model.DSLink
;
import
org.springframework.data.elasticsearch.client.ClientConfiguration
;
import
org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient
;
import
org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients
;
import
org.springframework.http.HttpHeaders
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
DynamicEsContextHolder
{
public
static
final
Map
<
String
,
ReactiveElasticsearchClient
>
ES_CLIENT_DB_FACTORY_MAP
=
new
HashMap
<>();
public
static
final
ThreadLocal
<
ReactiveElasticsearchClient
>
ES_DB_FACTORY_THREAD_LOCAL
=
new
ThreadLocal
<>();
public
static
ReactiveElasticsearchClient
getReactiveElasticsearchClient
()
{
return
ES_DB_FACTORY_THREAD_LOCAL
.
get
();
}
public
static
void
push
(
String
name
)
{
ES_DB_FACTORY_THREAD_LOCAL
.
set
(
ES_CLIENT_DB_FACTORY_MAP
.
get
(
name
));
}
public
static
void
poll
()
{
ES_DB_FACTORY_THREAD_LOCAL
.
remove
();
}
public
static
synchronized
void
addFactory
(
String
ds
,
DSLink
link
)
{
addFactory
(
ds
,
link
.
getUrl
());
}
public
static
synchronized
void
addFactory
(
String
ds
,
String
uri
)
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
add
(
"some-header"
,
"on every request"
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"currentTime"
,
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE_TIME
));
ClientConfiguration
clientConfiguration
=
ClientConfiguration
.
builder
()
.
connectedTo
(
"localhost:9200"
/*, "localhost:9291"*/
)
//.useSsl()
//.withProxy("localhost:8888")
//.withPathPrefix("ela")
.
withConnectTimeout
(
Duration
.
ofSeconds
(
5
))
.
withSocketTimeout
(
Duration
.
ofSeconds
(
3
))
//.withDefaultHeaders(defaultHeaders)
//.withBasicAuth(username, password)
.
withDefaultHeaders
(
headers
)
.
build
();
ES_CLIENT_DB_FACTORY_MAP
.
put
(
ds
,
ReactiveRestClients
.
create
(
clientConfiguration
));
}
public
static
synchronized
void
removeFactory
(
String
ds
)
{
ES_CLIENT_DB_FACTORY_MAP
.
remove
(
ds
);
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/elasticsearch/DynamicEsTemplate.java
0 → 100644
浏览文件 @
3fdab763
package
cn
.
ibizlab
.
core
.
data
.
elasticsearch
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
com.mongodb.client.MongoDatabase
;
import
lombok.extern.slf4j.Slf4j
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient
;
import
org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
;
@Slf4j
public
class
DynamicEsTemplate
extends
ReactiveElasticsearchTemplate
{
public
DynamicEsTemplate
(
ReactiveElasticsearchClient
client
)
{
super
(
client
);
}
@Override
protected
ReactiveElasticsearchClient
getClient
()
{
ReactiveElasticsearchClient
client
=
DynamicEsContextHolder
.
getReactiveElasticsearchClient
();
return
client
==
null
?
super
.
getClient
()
:
client
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
浏览文件 @
3fdab763
...
@@ -142,7 +142,7 @@ public class DstSystemModel {
...
@@ -142,7 +142,7 @@ public class DstSystemModel {
{
{
try
{
try
{
if
(!
Files
.
exists
(
path
))
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"DstSystem"
,
path
.
toString
());
throw
new
IllegalArgumentException
(
"读取文件失败DstSystem:"
+
path
.
toString
());
JSONObject
jo
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
path
),
StandardCharsets
.
UTF_8
));
JSONObject
jo
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
path
),
StandardCharsets
.
UTF_8
));
this
.
setPssystemid
(
jo
.
getString
(
"codeName"
));
this
.
setPssystemid
(
jo
.
getString
(
"codeName"
));
this
.
setPssystemname
(
jo
.
getString
(
"logicName"
));
this
.
setPssystemname
(
jo
.
getString
(
"logicName"
));
...
@@ -166,7 +166,7 @@ public class DstSystemModel {
...
@@ -166,7 +166,7 @@ public class DstSystemModel {
}
}
this
.
setDynamicModelPath
(
path
.
getParent
().
toAbsolutePath
().
toString
());
this
.
setDynamicModelPath
(
path
.
getParent
().
toAbsolutePath
().
toString
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"DstSystem"
,
path
.
toString
());
throw
new
IllegalArgumentException
(
"读取文件失败DstSystem:"
+
path
.
toString
());
}
}
return
this
;
return
this
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
3fdab763
...
@@ -23,6 +23,7 @@ import org.springframework.cache.annotation.Cacheable;
...
@@ -23,6 +23,7 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -81,16 +82,13 @@ public class DynamicModelService {
...
@@ -81,16 +82,13 @@ public class DynamicModelService {
dynamicSystems
=
new
HashMap
<>();
dynamicSystems
=
new
HashMap
<>();
IPSSystem
iPSSystem
=
null
;
IPSSystem
iPSSystem
=
null
;
if
(
StringUtils
.
isEmpty
(
strPSModelFolderPath
))
Assert
.
hasLength
(
strPSModelFolderPath
,
"加载系统模型错误,未找到对应模型目录:"
+
system
);
throw
new
BadRequestAlertException
(
"加载系统模型错误,未找到对应模型目录"
,
"DynamicSystem"
,
system
);
PSModelServiceImpl
psModelService
=
new
PSModelServiceImpl
();
PSModelServiceImpl
psModelService
=
new
PSModelServiceImpl
();
psModelService
.
setPSModelFolderPath
(
strPSModelFolderPath
);
psModelService
.
setPSModelFolderPath
(
strPSModelFolderPath
);
try
{
try
{
iPSSystem
=
psModelService
.
getPSSystem
();
iPSSystem
=
psModelService
.
getPSSystem
();
Assert
.
notNull
(
iPSSystem
,
"加载系统模型错误:"
+
system
);
if
(
iPSSystem
==
null
)
throw
new
BadRequestAlertException
(
"加载系统模型错误"
,
"DynamicSystem"
,
system
);
dynamicSystems
.
put
(
system
,
iPSSystem
);
dynamicSystems
.
put
(
system
,
iPSSystem
);
if
(!
system
.
equals
(
iPSSystem
.
getCodeName
()))
if
(!
system
.
equals
(
iPSSystem
.
getCodeName
()))
dynamicSystems
.
put
(
iPSSystem
.
getCodeName
(),
iPSSystem
);
dynamicSystems
.
put
(
iPSSystem
.
getCodeName
(),
iPSSystem
);
...
@@ -98,7 +96,7 @@ public class DynamicModelService {
...
@@ -98,7 +96,7 @@ public class DynamicModelService {
dynamicSystems
.
put
(
iPSSystem
.
getCodeName
().
toLowerCase
(),
iPSSystem
);
dynamicSystems
.
put
(
iPSSystem
.
getCodeName
().
toLowerCase
(),
iPSSystem
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
String
.
format
(
"加载系统模型错误:%s"
,
e
.
getMessage
()),
"DynamicSystem"
,
system
);
throw
new
RuntimeException
(
"加载系统模型错误"
+
system
,
e
);
}
}
return
iPSSystem
;
return
iPSSystem
;
}
}
...
@@ -188,12 +186,10 @@ public class DynamicModelService {
...
@@ -188,12 +186,10 @@ public class DynamicModelService {
public
EntityModel
getDynamicEntity
(
String
system
,
String
entity
)
throws
Exception
public
EntityModel
getDynamicEntity
(
String
system
,
String
entity
)
throws
Exception
{
{
MetaEntityModel
metaEntityModel
=
getProxy
().
getEntities
(
system
).
get
(
entity
);
MetaEntityModel
metaEntityModel
=
getProxy
().
getEntities
(
system
).
get
(
entity
);
if
(
metaEntityModel
==
null
)
Assert
.
notNull
(
metaEntityModel
,
"未找到对应的实体模型:"
+
entity
);
throw
new
BadRequestAlertException
(
"未找到对应的实体模型"
,
"DynamicEntity"
,
entity
);
IPSSystem
iPSSystem
=
getProxy
().
getDynamicSystem
(
system
);
IPSSystem
iPSSystem
=
getProxy
().
getDynamicSystem
(
system
);
IPSDataEntity
dataEntity
=
iPSSystem
.
getPSDataEntity
(
metaEntityModel
.
getEntityId
(),
true
);
IPSDataEntity
dataEntity
=
iPSSystem
.
getPSDataEntity
(
metaEntityModel
.
getEntityId
(),
true
);
if
(
dataEntity
==
null
)
Assert
.
notNull
(
dataEntity
,
"未找到对应的实体模型:"
+
entity
);
throw
new
BadRequestAlertException
(
"未找到对应的实体模型"
,
"DynamicEntity"
,
entity
);
EntityModel
entityModel
=
new
EntityModel
();
EntityModel
entityModel
=
new
EntityModel
();
if
(
dataEntity
.
isLogicValid
())
if
(
dataEntity
.
isLogicValid
())
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
3fdab763
...
@@ -832,11 +832,11 @@ public class POSchema {
...
@@ -832,11 +832,11 @@ public class POSchema {
{
{
try
{
try
{
if
(!
Files
.
exists
(
path
))
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"POSchema"
,
path
.
toString
());
throw
new
IllegalArgumentException
(
"读取文件失败POSchema:"
+
path
.
toString
());
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
POSchema
.
class
);
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
POSchema
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"解析文件失败"
,
"POSchema"
,
path
.
toString
());
throw
new
RuntimeException
(
"解析文件失败POSchema:"
+
path
.
toString
());
}
}
}
}
...
@@ -848,7 +848,7 @@ public class POSchema {
...
@@ -848,7 +848,7 @@ public class POSchema {
dir
.
mkdirs
();
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
));
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchema"
,
path
.
toString
());
throw
new
RuntimeException
(
"保存文件失败POSchema:"
+
path
.
toString
());
}
}
return
poSchema
;
return
poSchema
;
}
}
...
@@ -896,6 +896,8 @@ public class POSchema {
...
@@ -896,6 +896,8 @@ public class POSchema {
setKeyValue
(
data
,
key
);
setKeyValue
(
data
,
key
);
}
}
if
(
ObjectUtils
.
isEmpty
(
key
))
return
null
;
return
(
Serializable
)
key
;
return
(
Serializable
)
key
;
}
}
...
@@ -906,6 +908,8 @@ public class POSchema {
...
@@ -906,6 +908,8 @@ public class POSchema {
public
BaseData
setKeyValue
(
BaseData
data
,
Object
keyValue
)
public
BaseData
setKeyValue
(
BaseData
data
,
Object
keyValue
)
{
{
if
(
ObjectUtils
.
isEmpty
(
keyValue
))
return
null
;
Map
<
String
,
String
>
keyMap
=
this
.
getKeyMap
();
Map
<
String
,
String
>
keyMap
=
this
.
getKeyMap
();
data
.
setKey
(
keyValue
);
data
.
setKey
(
keyValue
);
if
(
keyMap
!=
null
)
if
(
keyMap
!=
null
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
3fdab763
...
@@ -499,11 +499,11 @@ public class PojoSchema {
...
@@ -499,11 +499,11 @@ public class PojoSchema {
{
{
try
{
try
{
if
(!
Files
.
exists
(
path
))
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"PojoSchema"
,
path
.
toString
());
throw
new
IllegalArgumentException
(
"读取文件失败PojoSchema:"
+
path
.
toString
());
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
PojoSchema
.
class
);
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
PojoSchema
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"解析文件失败"
,
"PojoSchema"
,
path
.
toString
());
throw
new
RuntimeException
(
"解析文件失败PojoSchema:"
+
path
.
toString
());
}
}
}
}
...
@@ -516,7 +516,7 @@ public class PojoSchema {
...
@@ -516,7 +516,7 @@ public class PojoSchema {
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
));
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"PojoSchema"
,
path
.
toString
());
throw
new
RuntimeException
(
"保存文件失败PojoSchema:"
+
path
.
toString
());
}
}
return
pojoSchema
;
return
pojoSchema
;
}
}
...
@@ -596,6 +596,8 @@ public class PojoSchema {
...
@@ -596,6 +596,8 @@ public class PojoSchema {
setKeyValue
(
data
,
key
);
setKeyValue
(
data
,
key
);
}
}
if
(
ObjectUtils
.
isEmpty
(
key
))
return
null
;
return
(
Serializable
)
key
;
return
(
Serializable
)
key
;
}
}
...
@@ -606,6 +608,8 @@ public class PojoSchema {
...
@@ -606,6 +608,8 @@ public class PojoSchema {
public
BaseData
setKeyValue
(
BaseData
data
,
Object
keyValue
)
public
BaseData
setKeyValue
(
BaseData
data
,
Object
keyValue
)
{
{
if
(
ObjectUtils
.
isEmpty
(
keyValue
))
return
null
;
Map
<
String
,
PojoSchema
>
keyMap
=
this
.
getKeyMap
();
Map
<
String
,
PojoSchema
>
keyMap
=
this
.
getKeyMap
();
data
.
setKey
(
keyValue
);
data
.
setKey
(
keyValue
);
if
(
keyMap
!=
null
)
if
(
keyMap
!=
null
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/repository/MongoDataRepository.java
浏览文件 @
3fdab763
...
@@ -12,6 +12,7 @@ import com.mongodb.BasicDBObject;
...
@@ -12,6 +12,7 @@ import com.mongodb.BasicDBObject;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
org.castor.core.util.Assert
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -91,10 +92,8 @@ public class MongoDataRepository {
...
@@ -91,10 +92,8 @@ public class MongoDataRepository {
public
Query
getKeyQuery
(
BaseData
data
)
public
Query
getKeyQuery
(
BaseData
data
)
{
{
Query
query
=
new
Query
();
Query
query
=
new
Query
();
if
(!
ObjectUtils
.
isEmpty
(
data
.
getKey
()))
Assert
.
notNull
(
data
.
getKey
(),
"未找到主键"
);
return
query
.
addCriteria
(
new
Criteria
().
and
(
"_id"
).
is
(
data
.
getKey
()));
return
query
.
addCriteria
(
new
Criteria
().
and
(
"_id"
).
is
(
data
.
getKey
()));
else
throw
new
BadRequestAlertException
(
"未找到主键"
,
"mongo"
,
null
);
}
}
public
Query
getKeyQuery
(
List
list
)
public
Query
getKeyQuery
(
List
list
)
...
@@ -108,9 +107,7 @@ public class MongoDataRepository {
...
@@ -108,9 +107,7 @@ public class MongoDataRepository {
list
.
forEach
(
item
->
{
list
.
forEach
(
item
->
{
BaseData
data
=
(
BaseData
)
item
;
BaseData
data
=
(
BaseData
)
item
;
Serializable
key
=
data
.
getKey
();
Serializable
key
=
data
.
getKey
();
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
"mongo"
,
null
);
ids
.
add
(
key
.
toString
());
ids
.
add
(
key
.
toString
());
});
});
}
}
...
@@ -265,8 +262,7 @@ public class MongoDataRepository {
...
@@ -265,8 +262,7 @@ public class MongoDataRepository {
BasicDBList
values
=
new
BasicDBList
();
BasicDBList
values
=
new
BasicDBList
();
list
.
forEach
(
item
->{
list
.
forEach
(
item
->{
Serializable
key
=
item
.
getKey
();
Serializable
key
=
item
.
getKey
();
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
"mongo"
,
null
);
values
.
add
(
key
);
values
.
add
(
key
);
});
});
BasicDBObject
in
=
new
BasicDBObject
(
"$in"
,
values
);
BasicDBObject
in
=
new
BasicDBObject
(
"$in"
,
values
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/DataResource.java
浏览文件 @
3fdab763
...
@@ -19,10 +19,12 @@ import org.springframework.data.domain.PageImpl;
...
@@ -19,10 +19,12 @@ import org.springframework.data.domain.PageImpl;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.Serializable
;
import
java.util.*
;
import
java.util.*
;
@Slf4j
@Slf4j
...
@@ -178,9 +180,13 @@ public class DataResource
...
@@ -178,9 +180,13 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
ids
)
{
@RequestBody
List
<
Object
>
datas
)
{
List
<
BaseData
>
list
=
dataService
.
getBatch
(
system
,
scope
,
entity
,
datasource
,
ids
);
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
list
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ArrayList
<>());
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
getByMapBatch
(
system
,
scope
,
entity
,
datasource
,(
List
)
datas
));
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
getBatch
(
system
,
scope
,
entity
,
datasource
,(
List
)
datas
));
}
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
...
@@ -231,8 +237,8 @@ public class DataResource
...
@@ -231,8 +237,8 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
id
s
)
{
@RequestBody
List
<
Object
>
data
s
)
{
return
doRemoveBatch
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
id
s
);
return
doRemoveBatch
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
data
s
);
}
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
...
@@ -245,9 +251,13 @@ public class DataResource
...
@@ -245,9 +251,13 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
ids
)
{
@RequestBody
List
<
Object
>
datas
)
{
dataService
.
removeBatch
(
system
,
scope
,
entity
,
datasource
,
ids
);
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
removeByMapBatch
(
system
,
scope
,
entity
,
datasource
,(
List
)
datas
));
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
removeBatch
(
system
,
scope
,
entity
,
datasource
,(
List
)
datas
));
}
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/PersistentResource.java
浏览文件 @
3fdab763
...
@@ -77,13 +77,13 @@ public class PersistentResource
...
@@ -77,13 +77,13 @@ public class PersistentResource
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/getbatch"
})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/getbatch"
})
public
ResponseEntity
<
List
<
BaseData
>>
getBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
public
ResponseEntity
<
List
<
BaseData
>>
getBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
List
datas
)
{
@RequestBody
List
<
Object
>
datas
)
{
if
(
ObjectUtils
.
isEmpty
(
datas
))
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ArrayList
<>());
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ArrayList
<>());
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getByMapBatch
(
system
,
table
,
datasource
,
datas
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getByMapBatch
(
system
,
table
,
datasource
,
(
List
)
datas
));
else
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getBatch
(
system
,
table
,
datasource
,
datas
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getBatch
(
system
,
table
,
datasource
,
(
List
)
datas
));
}
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
...
@@ -123,13 +123,13 @@ public class PersistentResource
...
@@ -123,13 +123,13 @@ public class PersistentResource
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/removebatch"
})
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/removebatch"
})
public
ResponseEntity
<
Boolean
>
doRemoveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
public
ResponseEntity
<
Boolean
>
doRemoveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
List
datas
)
{
@RequestBody
List
<
Object
>
datas
)
{
if
(
ObjectUtils
.
isEmpty
(
datas
))
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeByMapBatch
(
system
,
table
,
datasource
,
datas
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeByMapBatch
(
system
,
table
,
datasource
,
(
List
)
datas
));
else
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeBatch
(
system
,
table
,
datasource
,
datas
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeBatch
(
system
,
table
,
datasource
,
(
List
)
datas
));
}
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDataService.java
浏览文件 @
3fdab763
...
@@ -27,10 +27,12 @@ public interface IDataService
...
@@ -27,10 +27,12 @@ public interface IDataService
boolean
remove
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
Serializable
key
);
boolean
remove
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
Serializable
key
);
boolean
removeBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
Serializable
>
idList
);
boolean
removeBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
Serializable
>
idList
);
boolean
removeByMap
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
boolean
removeByMap
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
boolean
removeByMapBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
BaseData
>
list
);
BaseData
get
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
Serializable
key
);
BaseData
get
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
Serializable
key
);
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
Serializable
>
idList
);
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
Serializable
>
idList
);
BaseData
getByMap
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
BaseData
getByMap
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
List
<
BaseData
>
getByMapBatch
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
List
<
BaseData
>
list
);
BaseData
getDraft
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
BaseData
getDraft
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
boolean
checkKey
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
boolean
checkKey
(
DOModel
model
,
String
scope
,
DSLink
dsLink
,
BaseData
et
);
...
@@ -90,6 +92,10 @@ public interface IDataService
...
@@ -90,6 +92,10 @@ public interface IDataService
{
{
return
removeByMap
(
system
,
""
,
entity
,
""
,
et
);
return
removeByMap
(
system
,
""
,
entity
,
""
,
et
);
}
}
default
boolean
removeByMapBatch
(
String
system
,
String
entity
,
List
<
BaseData
>
list
)
{
return
removeByMapBatch
(
system
,
""
,
entity
,
""
,
list
);
}
default
BaseData
get
(
String
system
,
String
entity
,
Serializable
key
)
default
BaseData
get
(
String
system
,
String
entity
,
Serializable
key
)
{
{
return
get
(
system
,
""
,
entity
,
""
,
key
);
return
get
(
system
,
""
,
entity
,
""
,
key
);
...
@@ -102,6 +108,10 @@ public interface IDataService
...
@@ -102,6 +108,10 @@ public interface IDataService
{
{
return
getByMap
(
system
,
""
,
entity
,
""
,
et
);
return
getByMap
(
system
,
""
,
entity
,
""
,
et
);
}
}
default
List
<
BaseData
>
getByMapBatch
(
String
system
,
String
entity
,
List
<
BaseData
>
list
)
{
return
getByMapBatch
(
system
,
""
,
entity
,
""
,
list
);
}
default
BaseData
getDraft
(
String
system
,
String
entity
,
BaseData
et
)
default
BaseData
getDraft
(
String
system
,
String
entity
,
BaseData
et
)
{
{
return
getDraft
(
system
,
""
,
entity
,
""
,
et
);
return
getDraft
(
system
,
""
,
entity
,
""
,
et
);
...
@@ -204,6 +214,13 @@ public interface IDataService
...
@@ -204,6 +214,13 @@ public interface IDataService
DSLink
dsLink
=
getDSLink
(
datasource
);
DSLink
dsLink
=
getDSLink
(
datasource
);
return
removeByMap
(
model
,
scope
,
dsLink
,
et
);
return
removeByMap
(
model
,
scope
,
dsLink
,
et
);
}
}
default
boolean
removeByMapBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
{
DOModel
model
=
getDOModel
(
system
,
entity
);
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
dsLink
=
getDSLink
(
datasource
);
return
removeByMapBatch
(
model
,
scope
,
dsLink
,
list
);
}
default
BaseData
get
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
Serializable
key
)
default
BaseData
get
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
Serializable
key
)
{
{
DOModel
model
=
getDOModel
(
system
,
entity
);
DOModel
model
=
getDOModel
(
system
,
entity
);
...
@@ -225,6 +242,13 @@ public interface IDataService
...
@@ -225,6 +242,13 @@ public interface IDataService
DSLink
dsLink
=
getDSLink
(
datasource
);
DSLink
dsLink
=
getDSLink
(
datasource
);
return
getByMap
(
model
,
scope
,
dsLink
,
et
);
return
getByMap
(
model
,
scope
,
dsLink
,
et
);
}
}
default
List
<
BaseData
>
getByMapBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
{
DOModel
model
=
getDOModel
(
system
,
entity
);
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
dsLink
=
getDSLink
(
datasource
);
return
getByMapBatch
(
model
,
scope
,
dsLink
,
list
);
}
default
BaseData
getDraft
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
default
BaseData
getDraft
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
{
{
DOModel
model
=
getDOModel
(
system
,
entity
);
DOModel
model
=
getDOModel
(
system
,
entity
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
3fdab763
...
@@ -21,6 +21,7 @@ import org.springframework.cache.annotation.Caching;
...
@@ -21,6 +21,7 @@ import org.springframework.cache.annotation.Caching;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -80,7 +81,7 @@ public class ModelService {
...
@@ -80,7 +81,7 @@ public class ModelService {
models
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
systemJSON
),
StandardCharsets
.
UTF_8
),
new
TypeReference
<
LinkedHashMap
<
String
,
DstSystemModel
>>(){});;
models
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
systemJSON
),
StandardCharsets
.
UTF_8
),
new
TypeReference
<
LinkedHashMap
<
String
,
DstSystemModel
>>(){});;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
BadRequestAlertException
(
"解析文件失败"
,
"DstSystemModel"
,
"SYSTEM.json"
);
throw
new
RuntimeException
(
"解析文件失败SYSTEM.json"
,
e
);
}
}
return
models
;
return
models
;
}
}
...
@@ -157,9 +158,7 @@ public class ModelService {
...
@@ -157,9 +158,7 @@ public class ModelService {
else
else
{
{
dstSystemModel
=
proxy
.
getLocalSystemModels
().
get
(
system
);
dstSystemModel
=
proxy
.
getLocalSystemModels
().
get
(
system
);
if
(
dstSystemModel
==
null
)
Assert
.
notNull
(
dstSystemModel
,
"未找到对应的系统模型"
+
system
);
throw
new
BadRequestAlertException
(
"未找到对应的系统模型"
,
"DstSystem"
,
system
);
system
=
dstSystemModel
.
getPssystemid
();
system
=
dstSystemModel
.
getPssystemid
();
File
repoDir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
).
toFile
();
File
repoDir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
).
toFile
();
...
@@ -203,32 +202,25 @@ public class ModelService {
...
@@ -203,32 +202,25 @@ public class ModelService {
try
{
try
{
return
dynamicService
.
getDynamicEntity
(
system
,
entity
);
return
dynamicService
.
getDynamicEntity
(
system
,
entity
);
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
(
);
throw
new
RuntimeException
(
"getEntityModel未找到实体"
+
system
+
"."
+
entity
,
exception
);
}
}
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"getEntityModel"
,
""
);
}
}
public
DOModel
loadDOModel
(
String
system
,
String
entity
)
public
DOModel
loadDOModel
(
String
system
,
String
entity
)
{
{
EntityModel
entityModel
=
proxy
.
getEntityModel
(
system
,
entity
);
EntityModel
entityModel
=
proxy
.
getEntityModel
(
system
,
entity
);
Assert
.
notNull
(
entityModel
,
"loadDOModel未找到实体"
+
system
+
"."
+
entity
);
if
(
entityModel
!=
null
)
{
PojoSchema
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
PojoSchema
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
Assert
.
notNull
(
schema
,
"loadDOModel未找到实体"
+
system
+
"."
+
entity
);
if
(
schema
!=
null
)
{
DOModel
doModel
=
new
DOModel
();
DOModel
doModel
=
new
DOModel
();
doModel
.
setSchema
(
schema
);
doModel
.
setSchema
(
schema
);
for
(
String
dsType
:
entityModel
.
getDsTypes
())
{
for
(
String
dsType
:
entityModel
.
getDsTypes
())
{
POSchema
poSchema
=
TransUtils
.
EntityModelModel2PO
(
entityModel
,
dsType
);
POSchema
poSchema
=
TransUtils
.
EntityModelModel2PO
(
entityModel
,
dsType
);
if
(
poSchema
!=
null
)
{
if
(
poSchema
!=
null
)
{
doModel
.
addPOSchema
(
dsType
,
poSchema
);
doModel
.
addPOSchema
(
dsType
,
poSchema
);
}
}
return
doModel
;
}
}
}
}
return
doModel
;
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"loadDOModel"
,
""
);
}
}
...
@@ -243,8 +235,7 @@ public class ModelService {
...
@@ -243,8 +235,7 @@ public class ModelService {
{
{
try
{
try
{
String
entityTag
=
proxy
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
String
entityTag
=
proxy
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
if
(
StringUtils
.
isEmpty
(
entityTag
))
Assert
.
hasLength
(
entityTag
,
"获取模型失败"
+
key
);
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
if
(!
key
.
equals
(
entityTag
))
if
(!
key
.
equals
(
entityTag
))
{
{
String
[]
args
=
entityTag
.
split
(
"[.]"
);
String
[]
args
=
entityTag
.
split
(
"[.]"
);
...
@@ -253,7 +244,7 @@ public class ModelService {
...
@@ -253,7 +244,7 @@ public class ModelService {
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
throw
new
RuntimeException
(
"获取模型失败"
+
key
,
exception
);
}
}
}
}
...
@@ -272,7 +263,7 @@ public class ModelService {
...
@@ -272,7 +263,7 @@ public class ModelService {
dir
.
mkdirs
();
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
throw
new
RuntimeException
(
"保存文件失败POSchemas:"
+
poPath
.
toString
());
}
}
}
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
...
@@ -294,11 +285,7 @@ public class ModelService {
...
@@ -294,11 +285,7 @@ public class ModelService {
}
}
}
}
}
}
Assert
.
notNull
(
schema
,
"未找到对应的模型"
+
key
);
if
(
schema
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
return
doModel
;
return
doModel
;
}
}
...
@@ -330,7 +317,7 @@ public class ModelService {
...
@@ -330,7 +317,7 @@ public class ModelService {
}
}
}
}
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
throw
new
IllegalArgumentException
(
"未找到对应的模型"
+
key
);
}
}
...
@@ -419,7 +406,7 @@ public class ModelService {
...
@@ -419,7 +406,7 @@ public class ModelService {
dir
.
mkdirs
();
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
throw
new
RuntimeException
(
"保存文件失败POSchemas:"
+
poPath
.
toString
());
}
}
doModel
.
getPoSchemas
().
values
().
forEach
(
poSchema
->{
doModel
.
getPoSchemas
().
values
().
forEach
(
poSchema
->{
mergeTableSchema
(
doModel
.
getSystemId
(),
poSchema
,
systemModify
);
mergeTableSchema
(
doModel
.
getSystemId
(),
poSchema
,
systemModify
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataServiceImpl.java
浏览文件 @
3fdab763
...
@@ -14,6 +14,7 @@ import org.springframework.context.annotation.Primary;
...
@@ -14,6 +14,7 @@ import org.springframework.context.annotation.Primary;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -81,8 +82,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -81,8 +82,7 @@ public class BaseDataServiceImpl implements IDataService {
{
{
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
true
);
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
true
);
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
poSchema
.
trans
(
getProxyService
(
link
).
create
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
),
true
));
return
poSchema
.
trans
(
getProxyService
(
link
).
create
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
),
true
));
}
}
...
@@ -94,8 +94,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -94,8 +94,7 @@ public class BaseDataServiceImpl implements IDataService {
list
.
forEach
(
et
->
{
list
.
forEach
(
et
->
{
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
true
);
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
true
);
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
});
});
return
getProxyService
(
link
).
createBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
),
false
);
return
getProxyService
(
link
).
createBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
),
false
);
}
}
...
@@ -105,8 +104,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -105,8 +104,7 @@ public class BaseDataServiceImpl implements IDataService {
{
{
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
false
);
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
poSchema
.
trans
(
getProxyService
(
link
).
update
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
),
true
));
return
poSchema
.
trans
(
getProxyService
(
link
).
update
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
),
true
));
}
}
...
@@ -118,8 +116,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -118,8 +116,7 @@ public class BaseDataServiceImpl implements IDataService {
list
.
forEach
(
et
->
{
list
.
forEach
(
et
->
{
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
false
);
model
.
fillParentKey
(
et
).
fillDefaultValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
});
});
return
getProxyService
(
link
).
updateBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
),
false
);
return
getProxyService
(
link
).
updateBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
),
false
);
}
}
...
@@ -127,11 +124,9 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -127,11 +124,9 @@ public class BaseDataServiceImpl implements IDataService {
@Override
@Override
public
boolean
remove
(
DOModel
model
,
String
scope
,
DSLink
link
,
Serializable
key
)
public
boolean
remove
(
DOModel
model
,
String
scope
,
DSLink
link
,
Serializable
key
)
{
{
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
BaseData
et
=
model
.
newData
(
key
);
BaseData
et
=
model
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
getProxyService
(
link
).
removeByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
));
return
getProxyService
(
link
).
removeByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
));
}
}
...
@@ -143,8 +138,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -143,8 +138,7 @@ public class BaseDataServiceImpl implements IDataService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
});
});
return
getProxyService
(
link
).
removeByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
batch
));
return
getProxyService
(
link
).
removeByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
batch
));
...
@@ -154,20 +148,27 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -154,20 +148,27 @@ public class BaseDataServiceImpl implements IDataService {
public
boolean
removeByMap
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
public
boolean
removeByMap
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
{
{
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
getProxyService
(
link
).
removeByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
));
return
getProxyService
(
link
).
removeByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
));
}
}
@Override
public
boolean
removeByMapBatch
(
DOModel
model
,
String
scope
,
DSLink
link
,
List
<
BaseData
>
list
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
list
.
forEach
(
et
->{
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
Assert
.
notNull
(
key
,
"未找到主键"
);
});
return
getProxyService
(
link
).
removeByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
));
}
@Override
@Override
public
BaseData
get
(
DOModel
model
,
String
scope
,
DSLink
link
,
Serializable
key
)
public
BaseData
get
(
DOModel
model
,
String
scope
,
DSLink
link
,
Serializable
key
)
{
{
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
BaseData
et
=
model
.
newData
(
key
);
BaseData
et
=
model
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
)));
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
)));
}
}
...
@@ -179,8 +180,7 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -179,8 +180,7 @@ public class BaseDataServiceImpl implements IDataService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
});
});
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
batch
)));
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
batch
)));
...
@@ -190,12 +190,21 @@ public class BaseDataServiceImpl implements IDataService {
...
@@ -190,12 +190,21 @@ public class BaseDataServiceImpl implements IDataService {
public
BaseData
getByMap
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
public
BaseData
getByMap
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
{
{
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
Assert
.
notNull
(
key
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
)));
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMap
(
link
,
poSchema
,
poSchema
.
trans2PO
(
et
)));
}
}
@Override
public
List
<
BaseData
>
getByMapBatch
(
DOModel
model
,
String
scope
,
DSLink
link
,
List
<
BaseData
>
list
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
list
.
forEach
(
et
->{
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
Assert
.
notNull
(
key
,
"未找到主键"
);
});
return
poSchema
.
trans
(
getProxyService
(
link
).
getByMapBatch
(
link
,
poSchema
,
poSchema
.
trans2PO
(
list
)));
}
@Override
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
DSLink
link
,
BaseData
et
)
{
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
3fdab763
...
@@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.filter.DOModelSearchContext
;
import
cn.ibizlab.core.data.filter.DOModelSearchContext
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -92,8 +93,7 @@ public class DOModelServiceImpl implements IDOModelService {
...
@@ -92,8 +93,7 @@ public class DOModelServiceImpl implements IDOModelService {
}
}
}
}
}
}
if
(
schema
==
null
)
Assert
.
notNull
(
schema
,
"未找到对应的模型:"
+
key
);
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
return
doModel
;
return
doModel
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DSSettingServiceImpl.java
浏览文件 @
3fdab763
...
@@ -81,7 +81,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
...
@@ -81,7 +81,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
}
}
return
all
;
return
all
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"读写文件失败"
,
"DSLinkConfig"
,
path
.
toString
());
throw
new
RuntimeException
(
"读写文件失败DSLinkConfig:"
+
path
.
toString
());
}
}
}
}
...
@@ -158,7 +158,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
...
@@ -158,7 +158,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
try
{
try
{
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
newConfigs
));
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
newConfigs
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"读写文件失败"
,
"DSLinkConfig"
,
path
.
toString
());
throw
new
RuntimeException
(
"读写文件失败DSLinkConfig:"
+
path
.
toString
());
}
}
if
(!
StringUtils
.
isEmpty
(
et
.
getDsId
()))
if
(!
StringUtils
.
isEmpty
(
et
.
getDsId
()))
...
@@ -236,7 +236,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
...
@@ -236,7 +236,7 @@ public class DSSettingServiceImpl implements IDSSettingService {
try
{
try
{
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
newConfigs
));
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
newConfigs
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"读写文件失败"
,
"DSLinkConfig"
,
path
.
toString
());
throw
new
RuntimeException
(
"读写文件失败DSLinkConfig:"
+
path
.
toString
());
}
}
}
}
return
true
;
return
true
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
浏览文件 @
3fdab763
...
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import
cn.ibizlab.core.data.domain.DTOModel
;
import
cn.ibizlab.core.data.domain.DTOModel
;
import
cn.ibizlab.core.data.filter.DTOModelSearchContext
;
import
cn.ibizlab.core.data.filter.DTOModelSearchContext
;
import
cn.ibizlab.core.data.service.IDTOModelService
;
import
cn.ibizlab.core.data.service.IDTOModelService
;
import
org.springframework.util.Assert
;
/**
/**
...
@@ -98,10 +99,8 @@ public class DTOModelServiceImpl implements IDTOModelService {
...
@@ -98,10 +99,8 @@ public class DTOModelServiceImpl implements IDTOModelService {
else
else
schema
=
PojoSchema
.
fromPath
(
storePath
);
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
Assert
.
notNull
(
schema
,
"未找到对应的模型:"
+
key
);
dtoModel
.
setSchema
(
schema
);
dtoModel
.
setSchema
(
schema
);
else
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DTOModel"
,
key
);
return
dtoModel
;
return
dtoModel
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbPersistentServiceImpl.java
浏览文件 @
3fdab763
...
@@ -17,6 +17,7 @@ import org.springframework.data.domain.Page;
...
@@ -17,6 +17,7 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -95,8 +96,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
...
@@ -95,8 +96,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Override
@Override
public
boolean
remove
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
public
boolean
remove
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
repository
.
removeData
(
link
.
getName
(),
poSchema
,
et
);
repository
.
removeData
(
link
.
getName
(),
poSchema
,
et
);
return
true
;
return
true
;
}
}
...
@@ -106,8 +106,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
...
@@ -106,8 +106,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
if
(
batch
.
size
()>=
BATCH_SIZE
)
if
(
batch
.
size
()>=
BATCH_SIZE
)
{
{
...
@@ -151,11 +150,10 @@ public class DbPersistentServiceImpl implements IPersistentService {
...
@@ -151,11 +150,10 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Override
@Override
public
BaseData
get
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
public
BaseData
get
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
poSchema
.
getName
(),
key
.
toString
()
);
throw
new
IllegalArgumentException
(
"未找到数据"
+
poSchema
.
getName
()+
":"
+
key
);
return
list
.
get
(
0
);
return
list
.
get
(
0
);
}
}
...
@@ -165,8 +163,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
...
@@ -165,8 +163,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
if
(
batch
.
size
()>=
BATCH_SIZE
)
if
(
batch
.
size
()>=
BATCH_SIZE
)
{
{
...
@@ -186,7 +183,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
...
@@ -186,7 +183,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
public
BaseData
getByMap
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
)
{
public
BaseData
getByMap
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
)
{
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
poSchema
.
getName
(),
""
);
throw
new
IllegalArgumentException
(
"未找到数据"
+
poSchema
.
getName
()+
":"
+
et
.
getKey
()
);
return
list
.
get
(
0
);
return
list
.
get
(
0
);
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoPersistentServiceImpl.java
浏览文件 @
3fdab763
...
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -63,8 +64,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -63,8 +64,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Override
@Override
public
boolean
remove
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
public
boolean
remove
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
repository
.
removeData
(
link
.
getName
(),
poSchema
,
et
);
repository
.
removeData
(
link
.
getName
(),
poSchema
,
et
);
return
true
;
return
true
;
}
}
...
@@ -74,8 +74,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -74,8 +74,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
});
});
if
(
batch
.
size
()>
0
)
if
(
batch
.
size
()>
0
)
...
@@ -101,11 +100,10 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -101,11 +100,10 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Override
@Override
public
BaseData
get
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
public
BaseData
get
(
DSLink
link
,
POSchema
poSchema
,
Serializable
key
)
{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
poSchema
.
getName
(),
key
.
toString
()
);
throw
new
IllegalArgumentException
(
"未找到数据"
+
poSchema
.
getName
()+
":"
+
key
);
return
list
.
get
(
0
);
return
list
.
get
(
0
);
}
}
...
@@ -114,8 +112,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -114,8 +112,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
List
<
BaseData
>
batch
=
new
ArrayList
<>();
List
<
BaseData
>
batch
=
new
ArrayList
<>();
idList
.
forEach
(
key
->{
idList
.
forEach
(
key
->{
BaseData
et
=
poSchema
.
newData
(
key
);
BaseData
et
=
poSchema
.
newData
(
key
);
if
(
et
==
null
)
Assert
.
notNull
(
et
,
"未找到主键"
);
throw
new
BadRequestAlertException
(
"未找到主键"
,
poSchema
.
getName
(),
null
);
batch
.
add
(
et
);
batch
.
add
(
et
);
});
});
...
@@ -126,7 +123,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -126,7 +123,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
public
BaseData
getByMap
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
)
{
public
BaseData
getByMap
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
)
{
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
List
<
BaseData
>
list
=
repository
.
getData
(
link
.
getName
(),
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
poSchema
.
getName
(),
""
);
throw
new
IllegalArgumentException
(
"未找到数据"
+
poSchema
.
getName
()+
":"
+
et
.
getKey
()
);
return
list
.
get
(
0
);
return
list
.
get
(
0
);
}
}
...
@@ -225,7 +222,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
...
@@ -225,7 +222,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Override
@Override
public
boolean
execRaw
(
DSLink
link
,
POSchema
poSchema
,
String
sql
,
BaseData
param
)
{
public
boolean
execRaw
(
DSLink
link
,
POSchema
poSchema
,
String
sql
,
BaseData
param
)
{
throw
new
BadRequestAlertException
(
"没有实现方法execRaw"
,
poSchema
.
getName
(),
sql
);
throw
new
IllegalArgumentException
(
String
.
format
(
"没有实现方法execRaw,%1$s,%2$s"
,
poSchema
.
getName
(),
sql
)
);
}
}
@Override
@Override
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/EsDBConfig.java
0 → 100644
浏览文件 @
3fdab763
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
cn.ibizlab.core.data.elasticsearch.DynamicEsContextHolder
;
import
cn.ibizlab.core.data.elasticsearch.DynamicEsTemplate
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoTemplate
;
import
cn.ibizlab.util.helper.JSR310DateConverters
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient
;
import
org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.core.convert.MongoCustomConversions
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
@Configuration
public
class
EsDBConfig
{
@Value
(
"${spring.data.mongodb.uri:mongodb://localhost:27017/admin}"
)
private
String
uri
;
@Bean
(
name
=
"reactiveElasticsearchTemplate"
)
@Lazy
public
ReactiveElasticsearchTemplate
reactiveElasticsearchTemplate
()
{
if
(
DynamicEsContextHolder
.
ES_CLIENT_DB_FACTORY_MAP
.
size
()==
0
)
DynamicEsContextHolder
.
addFactory
(
"master"
,
uri
);
Iterator
<
ReactiveElasticsearchClient
>
iterator
=
DynamicEsContextHolder
.
ES_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
new
DynamicEsTemplate
(
iterator
.
next
());
}
@Bean
(
name
=
"reactiveElasticsearchClient"
)
@Lazy
public
ReactiveElasticsearchClient
reactiveElasticsearchClient
()
{
Iterator
<
ReactiveElasticsearchClient
>
iterator
=
DynamicEsContextHolder
.
ES_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
iterator
.
next
();
}
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
浏览文件 @
3fdab763
...
@@ -2,6 +2,7 @@ package cn.ibizlab.core.util.config;
...
@@ -2,6 +2,7 @@ package cn.ibizlab.core.util.config;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoTemplate
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoTemplate
;
import
cn.ibizlab.util.helper.JSR310DateConverters
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -54,141 +55,4 @@ public class MongoDBConfig {
...
@@ -54,141 +55,4 @@ public class MongoDBConfig {
return
iterator
.
next
();
return
iterator
.
next
();
}
}
public
static
class
JSR310DateConverters
{
private
JSR310DateConverters
()
{
}
public
static
class
TimestampToDateConverter
implements
Converter
<
Timestamp
,
Date
>
{
public
static
final
TimestampToDateConverter
INSTANCE
=
new
TimestampToDateConverter
();
private
TimestampToDateConverter
()
{
}
@Override
public
Date
convert
(
Timestamp
source
)
{
return
source
==
null
?
null
:
new
Date
(
source
.
getTime
());
}
}
public
static
class
DateToTimestampConverter
implements
Converter
<
Date
,
Timestamp
>
{
public
static
final
DateToTimestampConverter
INSTANCE
=
new
DateToTimestampConverter
();
private
DateToTimestampConverter
()
{
}
@Override
public
Timestamp
convert
(
Date
source
)
{
return
source
==
null
?
null
:
new
Timestamp
(
source
.
getTime
());
}
}
public
static
class
LocalDateToDateConverter
implements
Converter
<
LocalDate
,
Date
>
{
public
static
final
LocalDateToDateConverter
INSTANCE
=
new
LocalDateToDateConverter
();
private
LocalDateToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDate
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateConverter
implements
Converter
<
Date
,
LocalDate
>
{
public
static
final
DateToLocalDateConverter
INSTANCE
=
new
DateToLocalDateConverter
();
private
DateToLocalDateConverter
()
{
}
@Override
public
LocalDate
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
())
.
toLocalDate
();
}
}
public
static
class
ZonedDateTimeToDateConverter
implements
Converter
<
ZonedDateTime
,
Date
>
{
public
static
final
ZonedDateTimeToDateConverter
INSTANCE
=
new
ZonedDateTimeToDateConverter
();
private
ZonedDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
ZonedDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
toInstant
());
}
}
public
static
class
DateToZonedDateTimeConverter
implements
Converter
<
Date
,
ZonedDateTime
>
{
public
static
final
DateToZonedDateTimeConverter
INSTANCE
=
new
DateToZonedDateTimeConverter
();
private
DateToZonedDateTimeConverter
()
{
}
@Override
public
ZonedDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
LocalDateTimeToDateConverter
implements
Converter
<
LocalDateTime
,
Date
>
{
public
static
final
LocalDateTimeToDateConverter
INSTANCE
=
new
LocalDateTimeToDateConverter
();
private
LocalDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateTimeConverter
implements
Converter
<
Date
,
LocalDateTime
>
{
public
static
final
DateToLocalDateTimeConverter
INSTANCE
=
new
DateToLocalDateTimeConverter
();
private
DateToLocalDateTimeConverter
()
{
}
@Override
public
LocalDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
LocalDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
DurationToLongConverter
implements
Converter
<
Duration
,
Long
>
{
public
static
final
DurationToLongConverter
INSTANCE
=
new
DurationToLongConverter
();
private
DurationToLongConverter
()
{
}
@Override
public
Long
convert
(
Duration
source
)
{
return
source
==
null
?
null
:
source
.
toNanos
();
}
}
public
static
class
LongToDurationConverter
implements
Converter
<
Long
,
Duration
>
{
public
static
final
LongToDurationConverter
INSTANCE
=
new
LongToDurationConverter
();
private
LongToDurationConverter
()
{
}
@Override
public
Duration
convert
(
Long
source
)
{
return
source
==
null
?
null
:
Duration
.
ofNanos
(
source
);
}
}
}
}
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/util/helper/JSR310DateConverters.java
0 → 100644
浏览文件 @
3fdab763
package
cn
.
ibizlab
.
util
.
helper
;
import
org.springframework.core.convert.converter.Converter
;
import
java.sql.Timestamp
;
import
java.time.*
;
import
java.util.Date
;
/**
* <p>JSR310DateConverters class.</p>
*/
public
final
class
JSR310DateConverters
{
private
JSR310DateConverters
()
{
}
public
static
class
TimestampToDateConverter
implements
Converter
<
Timestamp
,
Date
>
{
public
static
final
TimestampToDateConverter
INSTANCE
=
new
TimestampToDateConverter
();
private
TimestampToDateConverter
()
{
}
@Override
public
Date
convert
(
Timestamp
source
)
{
return
source
==
null
?
null
:
new
Date
(
source
.
getTime
());
}
}
public
static
class
DateToTimestampConverter
implements
Converter
<
Date
,
Timestamp
>
{
public
static
final
DateToTimestampConverter
INSTANCE
=
new
DateToTimestampConverter
();
private
DateToTimestampConverter
()
{
}
@Override
public
Timestamp
convert
(
Date
source
)
{
return
source
==
null
?
null
:
new
Timestamp
(
source
.
getTime
());
}
}
public
static
class
LocalDateToDateConverter
implements
Converter
<
LocalDate
,
Date
>
{
public
static
final
LocalDateToDateConverter
INSTANCE
=
new
LocalDateToDateConverter
();
private
LocalDateToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDate
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateConverter
implements
Converter
<
Date
,
LocalDate
>
{
public
static
final
DateToLocalDateConverter
INSTANCE
=
new
DateToLocalDateConverter
();
private
DateToLocalDateConverter
()
{
}
@Override
public
LocalDate
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
())
.
toLocalDate
();
}
}
public
static
class
ZonedDateTimeToDateConverter
implements
Converter
<
ZonedDateTime
,
Date
>
{
public
static
final
ZonedDateTimeToDateConverter
INSTANCE
=
new
ZonedDateTimeToDateConverter
();
private
ZonedDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
ZonedDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
toInstant
());
}
}
public
static
class
DateToZonedDateTimeConverter
implements
Converter
<
Date
,
ZonedDateTime
>
{
public
static
final
DateToZonedDateTimeConverter
INSTANCE
=
new
DateToZonedDateTimeConverter
();
private
DateToZonedDateTimeConverter
()
{
}
@Override
public
ZonedDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
LocalDateTimeToDateConverter
implements
Converter
<
LocalDateTime
,
Date
>
{
public
static
final
LocalDateTimeToDateConverter
INSTANCE
=
new
LocalDateTimeToDateConverter
();
private
LocalDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateTimeConverter
implements
Converter
<
Date
,
LocalDateTime
>
{
public
static
final
DateToLocalDateTimeConverter
INSTANCE
=
new
DateToLocalDateTimeConverter
();
private
DateToLocalDateTimeConverter
()
{
}
@Override
public
LocalDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
LocalDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
DurationToLongConverter
implements
Converter
<
Duration
,
Long
>
{
public
static
final
DurationToLongConverter
INSTANCE
=
new
DurationToLongConverter
();
private
DurationToLongConverter
()
{
}
@Override
public
Long
convert
(
Duration
source
)
{
return
source
==
null
?
null
:
source
.
toNanos
();
}
}
public
static
class
LongToDurationConverter
implements
Converter
<
Long
,
Duration
>
{
public
static
final
LongToDurationConverter
INSTANCE
=
new
LongToDurationConverter
();
private
LongToDurationConverter
()
{
}
@Override
public
Duration
convert
(
Long
source
)
{
return
source
==
null
?
null
:
Duration
.
ofNanos
(
source
);
}
}
}
\ No newline at end of file
ibzdata-dependencies/pom.xml
浏览文件 @
3fdab763
...
@@ -15,14 +15,14 @@
...
@@ -15,14 +15,14 @@
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.2.
1
.RELEASE
</version>
<version>
2.2.
5
.RELEASE
</version>
</parent>
</parent>
<properties>
<properties>
<!-- Spring Cloud Alibaba(2.2.x.RELEASE) & Spring Cloud(Spring Cloud Greenwich) & Spring Boot(2.2.x.RELEASE) compatibility -->
<!-- Spring Cloud Alibaba(2.2.x.RELEASE) & Spring Cloud(Spring Cloud Greenwich) & Spring Boot(2.2.x.RELEASE) compatibility -->
<spring-cloud-alibaba.version>
2.2.1.RELEASE
</spring-cloud-alibaba.version>
<spring-cloud-alibaba.version>
2.2.1.RELEASE
</spring-cloud-alibaba.version>
<spring-cloud-openfeign.version>
2.2.
1
.RELEASE
</spring-cloud-openfeign.version>
<spring-cloud-openfeign.version>
2.2.
5
.RELEASE
</spring-cloud-openfeign.version>
<!-- Alibaba Druid -->
<!-- Alibaba Druid -->
<alibaba-druid.version>
1.1.21
</alibaba-druid.version>
<alibaba-druid.version>
1.1.21
</alibaba-druid.version>
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
<logstash.version>
5.2
</logstash.version>
<logstash.version>
5.2
</logstash.version>
<!--Zuul网关-->
<!--Zuul网关-->
<spring-cloud-starter-netflix-zuul.version>
2.2.
1
.RELEASE
</spring-cloud-starter-netflix-zuul.version>
<spring-cloud-starter-netflix-zuul.version>
2.2.
5
.RELEASE
</spring-cloud-starter-netflix-zuul.version>
<!--MapStruct高性能属性映射工具-->
<!--MapStruct高性能属性映射工具-->
<mapstruct.version>
1.3.0.Final
</mapstruct.version>
<mapstruct.version>
1.3.0.Final
</mapstruct.version>
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
<baomidou-jobs.version>
1.0.3
</baomidou-jobs.version>
<baomidou-jobs.version>
1.0.3
</baomidou-jobs.version>
<!-- eureka微服务注册中心 -->
<!-- eureka微服务注册中心 -->
<eureka-client.version>
2.2.
1
.RELEASE
</eureka-client.version>
<eureka-client.version>
2.2.
5
.RELEASE
</eureka-client.version>
<!-- 阿里sentinel熔断器 -->
<!-- 阿里sentinel熔断器 -->
<alibaba-sentinel.version>
2.1.1.RELEASE
</alibaba-sentinel.version>
<alibaba-sentinel.version>
2.1.1.RELEASE
</alibaba-sentinel.version>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录