Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
823d1523
提交
823d1523
编写于
8月 24, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
30459151
变更
43
展开全部
显示空白字符变更
内嵌
并排
正在显示
43 个修改的文件
包含
2217 行增加
和
254 行删除
+2217
-254
pom.xml
ibzdata-boot/pom.xml
+5
-0
pom.xml
ibzdata-core/pom.xml
+110
-6
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+2
-16
DTOModel.java
...e/src/main/java/cn/ibizlab/core/data/domain/DTOModel.java
+1
-9
POModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/POModel.java
+3
-22
DataObj.java
...-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
+1
-20
DataObject.java
...re/src/main/java/cn/ibizlab/core/data/dto/DataObject.java
+627
-0
DbDataQuery.java
...e/src/main/java/cn/ibizlab/core/data/dto/DbDataQuery.java
+1
-1
FilterData.java
...re/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
+2
-9
DOModelSearchContext.java
...ava/cn/ibizlab/core/data/filter/DOModelSearchContext.java
+0
-16
DTOModelSearchContext.java
...va/cn/ibizlab/core/data/filter/DTOModelSearchContext.java
+0
-16
POModelSearchContext.java
...ava/cn/ibizlab/core/data/filter/POModelSearchContext.java
+0
-16
QueryBuildContext.java
...n/java/cn/ibizlab/core/data/filter/QueryBuildContext.java
+182
-0
QueryFilter.java
...rc/main/java/cn/ibizlab/core/data/filter/QueryFilter.java
+255
-0
QueryWrapperContext.java
...java/cn/ibizlab/core/data/filter/QueryWrapperContext.java
+222
-0
SearchContextBase.java
...n/java/cn/ibizlab/core/data/filter/SearchContextBase.java
+172
-0
DstSystemModel.java
...c/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
+1
-1
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+1
-1
FieldModel.java
...e/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
+1
-1
LiteModelFeignClient.java
.../java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
+1
-1
LiteStorage.java
.../src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
+1
-1
MetaEntityModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
+1
-1
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+1
-1
Setting.java
...core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
+3
-13
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+0
-1
PojoProperty.java
...rc/main/java/cn/ibizlab/core/data/model/PojoProperty.java
+1
-2
DataResource.java
...src/main/java/cn/ibizlab/core/data/rest/DataResource.java
+1
-3
IDataService.java
.../main/java/cn/ibizlab/core/data/service/IDataService.java
+0
-3
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+69
-2
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+0
-2
DbDataServiceImpl.java
.../cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
+0
-8
MongoDataServiceImpl.java
.../ibizlab/core/data/service/impl/MongoDataServiceImpl.java
+0
-1
POModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/POModelServiceImpl.java
+0
-2
FilterDataResolver.java
.../java/cn/ibizlab/core/util/config/FilterDataResolver.java
+2
-4
LiquibaseConfiguration.java
...a/cn/ibizlab/core/util/config/LiquibaseConfiguration.java
+0
-64
MongoDBConfig.java
.../main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
+141
-1
MybatisConfiguration.java
...ava/cn/ibizlab/core/util/config/MybatisConfiguration.java
+1
-5
UniqueNameGenerator.java
...java/cn/ibizlab/core/util/config/UniqueNameGenerator.java
+18
-0
XxlJobConfig.java
...c/main/java/cn/ibizlab/core/util/config/XxlJobConfig.java
+0
-5
BadRequestAlertException.java
...java/cn/ibizlab/util/errors/BadRequestAlertException.java
+44
-0
AuthenticationUser.java
...ain/java/cn/ibizlab/util/security/AuthenticationUser.java
+325
-0
application.yml
ibzdata-core/src/main/resources/application.yml
+17
-0
pom.xml
ibzdata-provider/ibzdata-provider-api/pom.xml
+5
-0
未找到文件。
ibzdata-boot/pom.xml
浏览文件 @
823d1523
...
...
@@ -14,6 +14,11 @@
<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-core/pom.xml
浏览文件 @
823d1523
...
...
@@ -15,9 +15,113 @@
<dependencies>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-util
</artifactId>
<version>
${project.version}
</version>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-commons
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-core
</artifactId>
</dependency>
<dependency>
<groupId>
net.logstash.logback
</groupId>
<artifactId>
logstash-logback-encoder
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
</dependency>
<dependency>
<groupId>
org.zalando
</groupId>
<artifactId>
problem-spring-web
</artifactId>
</dependency>
<dependency>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</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>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-httpclient
</artifactId>
</dependency>
<!-- drools -->
<dependency>
<groupId>
org.drools
</groupId>
<artifactId>
drools-compiler
</artifactId>
</dependency>
<dependency>
<groupId>
org.drools
</groupId>
<artifactId>
drools-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.kie
</groupId>
<artifactId>
kie-spring
</artifactId>
</dependency>
<dependency>
<groupId>
org.kie
</groupId>
<artifactId>
kie-api
</artifactId>
</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>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
823d1523
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.BaseData
;
import
cn.ibizlab.core.data.model.POSchema
;
...
...
@@ -14,19 +10,10 @@ import com.alibaba.fastjson.annotation.JSONField;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
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
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.enums.DupCheck
;
import
cn.ibizlab.core.data.dto.DataObject
;
import
java.io.Serializable
;
import
lombok.*
;
import
org.springframework.data.annotation.Transient
;
import
cn.ibizlab.util.annotation.Audit
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.util.StringUtils
;
...
...
@@ -41,12 +28,11 @@ import org.springframework.util.StringUtils;
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
"业务实体"
)
public
class
DOModel
extends
EntityBase
implements
Serializable
{
public
class
DOModel
implements
Serializable
{
/**
* 标识
*/
@DEField
(
isKeyField
=
true
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"标识"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DTOModel.java
浏览文件 @
823d1523
...
...
@@ -16,16 +16,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.DigestUtils
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.enums.DupCheck
;
import
java.io.Serializable
;
import
lombok.*
;
import
org.springframework.data.annotation.Transient
;
import
cn.ibizlab.util.annotation.Audit
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.util.StringUtils
;
...
...
@@ -40,12 +33,11 @@ import org.springframework.util.StringUtils;
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
"数据传输对象"
)
public
class
DTOModel
extends
EntityBase
implements
Serializable
{
public
class
DTOModel
implements
Serializable
{
/**
* 标识
*/
@DEField
(
isKeyField
=
true
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"标识"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/POModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
domain
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.math.BigInteger
;
import
java.util.HashMap
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
com.alibaba.fastjson.annotation.JSONField
;
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
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.enums.DupCheck
;
import
java.io.Serializable
;
import
lombok.*
;
import
org.springframework.data.annotation.Transient
;
import
cn.ibizlab.util.annotation.Audit
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -37,12 +18,12 @@ import io.swagger.annotations.ApiModelProperty;
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
"持久化对象"
)
public
class
POModel
extends
EntityBase
implements
Serializable
{
public
class
POModel
implements
Serializable
{
/**
* 标识
*/
@DEField
(
isKeyField
=
true
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"标识"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
dto
;
import
cn.ibizlab.util.domain.DTOBase
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -163,23 +160,7 @@ public class DataObj<K,V> extends HashMap<K,V> {
public
<
T
>
T
copyTo
(
T
targetEntity
,
boolean
bIncEmpty
){
if
(
targetEntity
instanceof
EntityBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
EntityBase
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
DTOBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
DTOBase
)
targetEntity
).
set
(((
String
)
field
).
toLowerCase
(),
value
);
}
}
}
else
if
(
targetEntity
instanceof
DataObj
){
if
(
targetEntity
instanceof
DataObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/DataObject.java
0 → 100644
浏览文件 @
823d1523
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/DbDataQuery.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
dto
;
import
cn.ibizlab.
util
.filter.QueryWrapperContext
;
import
cn.ibizlab.
core.data
.filter.QueryWrapperContext
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
浏览文件 @
823d1523
...
...
@@ -2,27 +2,20 @@ package cn.ibizlab.core.data.dto;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
cn.ibizlab.util.filter.QueryWrapperContext
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.core.data.filter.QueryFilter
;
import
cn.ibizlab.core.data.filter.QueryWrapperContext
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.annotation.JsonAnyGetter
;
import
com.fasterxml.jackson.annotation.JsonAnySetter
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.ParameterizedType
;
import
java.util.*
;
public
class
FilterData
<
T
>
extends
BaseData
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/DOModelSearchContext.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.HashMap
;
import
lombok.*
;
import
lombok.extern.slf4j.Slf4j
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
cn.ibizlab.util.filter.SearchContextBase
;
/**
* ServiceApi数据实体[DOModel] 查询条件对象
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/DTOModelSearchContext.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.HashMap
;
import
lombok.*
;
import
lombok.extern.slf4j.Slf4j
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
cn.ibizlab.util.filter.SearchContextBase
;
/**
* ServiceApi数据实体[DTOModel] 查询条件对象
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/POModelSearchContext.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.HashMap
;
import
lombok.*
;
import
lombok.extern.slf4j.Slf4j
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
cn.ibizlab.util.filter.SearchContextBase
;
/**
* ServiceApi数据实体[POModel] 查询条件对象
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/QueryBuildContext.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.mongodb.QueryBuilder
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Pattern
;
@Slf4j
@Data
public
class
QueryBuildContext
extends
SearchContextBase
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
QueryBuilder
selectCond
=
new
QueryBuilder
();
public
QueryBuilder
getSearchCond
(){
return
this
.
selectCond
;
}
/**
* 填充自定义查询条件
* @return
*/
public
QueryBuilder
getSelectCond
()
{
if
(!
ObjectUtils
.
isEmpty
(
filter
)){
QueryBuilder
queryBuilder
=
parseQueryFilter
(
filter
);
if
(!
ObjectUtils
.
isEmpty
(
queryBuilder
)){
selectCond
.
and
(
queryBuilder
.
get
());
}
}
return
selectCond
;
}
/**
* 解析自定义查询条件
* @param queryFilter
* @return
*/
private
QueryBuilder
parseQueryFilter
(
QueryFilter
queryFilter
){
if
(
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$and
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$or
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
any
()))
{
return
null
;
}
QueryBuilder
rsBuilder
=
QueryBuilder
.
start
();
QueryBuilder
fieldBuilder
=
parseFieldMap
(
queryFilter
.
any
());
QueryBuilder
orBuilder
=
parseOrQueryFilter
(
queryFilter
.
get
$or
());
QueryBuilder
andBuilder
=
parseAndQueryFilter
(
queryFilter
.
get
$and
());
if
(!
ObjectUtils
.
isEmpty
(
fieldBuilder
)){
rsBuilder
.
and
(
fieldBuilder
.
get
());
}
if
(!
ObjectUtils
.
isEmpty
(
orBuilder
)){
rsBuilder
.
and
(
orBuilder
.
get
());
}
if
(!
ObjectUtils
.
isEmpty
(
andBuilder
)){
rsBuilder
.
and
(
andBuilder
.
get
());
}
return
rsBuilder
;
}
/**
* 解析自定义条件[or]
* @param queryFilters
* @return
*/
private
QueryBuilder
parseOrQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
QueryBuilder
orBuilder
=
new
QueryBuilder
();
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
){
return
null
;
}
for
(
QueryFilter
queryFilter:
queryFilters
){
QueryBuilder
queryBuilder
=
parseQueryFilter
(
queryFilter
);
if
(!
ObjectUtils
.
isEmpty
(
queryBuilder
)){
orBuilder
.
or
(
queryBuilder
.
get
());
}
}
return
orBuilder
;
}
/**
* 解析自定义条件[and]
* @param queryFilters
* @return
*/
private
QueryBuilder
parseAndQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
QueryBuilder
orBuilder
=
new
QueryBuilder
();
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
){
return
null
;
}
for
(
QueryFilter
queryFilter:
queryFilters
){
QueryBuilder
queryBuilder
=
parseQueryFilter
(
queryFilter
);
if
(!
ObjectUtils
.
isEmpty
(
queryBuilder
)){
orBuilder
.
and
(
queryBuilder
.
get
());
}
}
return
orBuilder
;
}
/**
* 解析自定义条件[字段条件]
* @param fieldMap
* @return
*/
private
QueryBuilder
parseFieldMap
(
Map
<
String
,
QueryFilter
.
SegmentCond
>
fieldMap
)
{
if
(
fieldMap
.
size
()==
0
)
{
return
null
;
}
QueryBuilder
fieldBuilders
=
QueryBuilder
.
start
();
for
(
Map
.
Entry
<
String
,
QueryFilter
.
SegmentCond
>
entry:
fieldMap
.
entrySet
()){
getSegmentCondSql
(
entry
.
getKey
(),
entry
.
getValue
(),
fieldBuilders
);
}
return
fieldBuilders
;
}
/**
* 解析自定义条件[字段条件]
* @param fieldName
* @param segmentCond
* @param fieldBuilder
*/
private
void
getSegmentCondSql
(
String
fieldName
,
QueryFilter
.
SegmentCond
segmentCond
,
QueryBuilder
fieldBuilder
)
{
Map
<
String
,
Object
>
segmentCondMap
=
segmentCond
.
any
();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
segmentCondMap
.
entrySet
()){
Object
value
=
entry
.
getValue
();
switch
(
entry
.
getKey
()){
case
"$eq"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
is
(
value
).
get
());
break
;
case
"$ne"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
not
().
and
(
fieldName
).
is
(
value
).
get
());
break
;
case
"$gt"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
greaterThan
(
value
).
get
());
break
;
case
"$gte"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
greaterThanEquals
(
value
).
get
());
break
;
case
"$lt"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
lessThan
(
value
).
get
());
break
;
case
"$lte"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
lessThanEquals
(
value
).
get
());
break
;
case
"$null"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
exists
(
null
).
get
());
break
;
case
"$notNull"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
exists
(
true
).
and
(
fieldName
).
notEquals
(
""
).
and
(
fieldName
).
notEquals
(
null
).
get
());
break
;
case
"$in"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
in
(
value
).
get
());
break
;
case
"$notIn"
:
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
not
().
in
(
value
).
get
());
break
;
case
"$like"
:
Pattern
likePattern
=
Pattern
.
compile
(
"^.*"
+
value
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
regex
(
likePattern
).
get
());
break
;
case
"$startsWith"
:
Pattern
startsWithPattern
=
Pattern
.
compile
(
value
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
regex
(
startsWithPattern
).
get
());
break
;
case
"$endsWith"
:
Pattern
endsWithPattern
=
Pattern
.
compile
(
"^.*"
+
value
+
"$"
,
Pattern
.
CASE_INSENSITIVE
);
fieldBuilder
.
and
(
QueryBuilder
.
start
().
and
(
fieldName
).
regex
(
endsWithPattern
).
get
());
break
;
case
"$exists"
:
break
;
case
"$notExists"
:
break
;
}
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/QueryFilter.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
com.fasterxml.jackson.annotation.*
;
import
org.springframework.data.annotation.Transient
;
import
java.util.*
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
public
class
QueryFilter
{
public
static
QueryFilter
createQuery
()
{
QueryFilter
queryFilter
=
new
QueryFilter
();
return
queryFilter
;
}
public
QueryFilter
eq
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
eq
(
value
));
}
public
QueryFilter
ne
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
ne
(
value
));
}
public
QueryFilter
gt
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
gt
(
value
));
}
public
QueryFilter
ge
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
ge
(
value
));
}
public
QueryFilter
lt
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
lt
(
value
));
}
public
QueryFilter
le
(
String
column
,
Object
value
)
{
return
op
(
column
,
SegmentCond
.
le
(
value
));
}
public
QueryFilter
isnull
(
String
column
)
{
return
op
(
column
,
SegmentCond
.
isnull
());
}
public
QueryFilter
isnotnull
(
String
column
)
{
return
op
(
column
,
SegmentCond
.
isnotnull
());
}
public
QueryFilter
in
(
String
column
,
Collection
value
)
{
return
op
(
column
,
SegmentCond
.
in
(
value
));
}
public
QueryFilter
notin
(
String
column
,
Collection
value
)
{
return
op
(
column
,
SegmentCond
.
notin
(
value
));
}
public
QueryFilter
like
(
String
column
,
String
value
)
{
return
op
(
column
,
SegmentCond
.
like
(
value
));
}
public
QueryFilter
startsWith
(
String
column
,
String
value
)
{
return
op
(
column
,
SegmentCond
.
startsWith
(
value
));
}
public
QueryFilter
endsWith
(
String
column
,
String
value
)
{
return
op
(
column
,
SegmentCond
.
endsWith
(
value
));
}
public
QueryFilter
between
(
String
column
,
Object
from
,
Object
to
)
{
return
op
(
column
,
SegmentCond
.
between
(
from
,
to
));
}
@JsonIgnore
@Transient
private
Map
<
String
,
SegmentCond
>
map
;
private
Map
<
String
,
SegmentCond
>
getMap
()
{
if
(
map
==
null
)
{
map
=
new
LinkedHashMap
<>();
}
return
map
;
}
@JsonAnyGetter
public
Map
<
String
,
SegmentCond
>
any
()
{
return
getMap
();
}
@JsonAnySetter
public
void
set
(
String
column
,
SegmentCond
value
)
{
getMap
().
put
(
column
,
value
);
}
@JsonProperty
(
index
=
999
)
private
List
<
QueryFilter
>
$or
;
public
List
<
QueryFilter
>
get$or
()
{
return
$or
;
}
public
void
set$or
(
List
<
QueryFilter
>
$or
)
{
this
.
$or
=
$or
;
}
public
QueryFilter
or
(
QueryFilter
...
ors
)
{
if
(
$or
==
null
)
{
$or
=
new
ArrayList
();
}
Collections
.
addAll
(
$or
,
ors
);
return
this
;
}
@JsonProperty
(
index
=
999
)
private
List
<
QueryFilter
>
$and
;
public
List
<
QueryFilter
>
get$and
()
{
return
$and
;
}
public
void
set$and
(
List
<
QueryFilter
>
$and
)
{
this
.
$and
=
$and
;
}
public
QueryFilter
and
(
QueryFilter
...
ands
)
{
if
(
$and
==
null
)
{
$and
=
new
ArrayList
();
}
Collections
.
addAll
(
$and
,
ands
);
return
this
;
}
@Override
public
String
toString
()
{
return
"QueryFilter{"
+
"map="
+
map
+
", $or="
+
$or
+
'}'
;
}
private
QueryFilter
op
(
String
column
,
SegmentCond
segmentCond
)
{
if
(
this
.
getMap
().
containsKey
(
column
))
{
((
SegmentCond
)
this
.
getMap
().
get
(
column
)).
getMap
().
putAll
(
segmentCond
.
getMap
());
}
else
{
this
.
getMap
().
put
(
column
,
segmentCond
);
}
return
this
;
}
public
static
class
SegmentCond
{
@JsonIgnore
@Transient
private
Map
<
String
,
Object
>
map
;
@Override
public
String
toString
()
{
return
"SegmentCond{"
+
"map="
+
map
+
'}'
;
}
private
Map
<
String
,
Object
>
getMap
()
{
if
(
map
==
null
)
{
map
=
new
LinkedHashMap
<>();
}
return
map
;
}
@JsonAnyGetter
public
Map
<
String
,
Object
>
any
()
{
return
getMap
();
}
@JsonAnySetter
public
void
set
(
String
column
,
Object
value
)
{
getMap
().
put
(
column
,
value
);
}
public
static
SegmentCond
eq
(
Object
value
)
{
return
op
(
Segment
.
EQ
,
value
);
}
public
static
SegmentCond
ne
(
Object
value
)
{
return
op
(
Segment
.
NE
,
value
);
}
public
static
SegmentCond
gt
(
Object
value
)
{
return
op
(
Segment
.
GT
,
value
);
}
public
static
SegmentCond
ge
(
Object
value
)
{
return
op
(
Segment
.
GE
,
value
);
}
public
static
SegmentCond
lt
(
Object
value
)
{
return
op
(
Segment
.
LT
,
value
);
}
public
static
SegmentCond
le
(
Object
value
)
{
return
op
(
Segment
.
LE
,
value
);
}
public
static
SegmentCond
isnull
()
{
return
op
(
Segment
.
IS_NULL
,
true
);
}
public
static
SegmentCond
isnotnull
()
{
return
op
(
Segment
.
IS_NOT_NULL
,
true
);
}
public
static
SegmentCond
in
(
Collection
value
)
{
return
op
(
Segment
.
IN
,
value
);
}
public
static
SegmentCond
notin
(
Collection
value
)
{
return
op
(
Segment
.
NOTIN
,
value
);
}
public
static
SegmentCond
like
(
String
value
)
{
return
op
(
Segment
.
LIKE
,
value
);
}
public
static
SegmentCond
startsWith
(
String
value
)
{
return
op
(
Segment
.
LEFTLIKE
,
value
);
}
public
static
SegmentCond
endsWith
(
String
value
)
{
return
op
(
Segment
.
RIGHTLIKE
,
value
);
}
public
static
SegmentCond
between
(
Object
from
,
Object
to
)
{
return
op
(
Segment
.
GE
,
from
).
op
(
Segment
.
LT
,
to
);
}
private
static
SegmentCond
op
(
Segment
segment
,
Object
value
)
{
SegmentCond
segmentCond
=
new
SegmentCond
();
segmentCond
.
getMap
().
put
(
segment
.
keyword
,
value
);
return
segmentCond
;
}
}
public
enum
Segment
{
AND
(
"$and"
),
OR
(
"$or"
),
EQ
(
"$eq"
),
NE
(
"$ne"
),
GT
(
"$gt"
),
GE
(
"$gte"
),
LT
(
"$lt"
),
LE
(
"$lte"
),
IS_NULL
(
"$null"
),
IS_NOT_NULL
(
"$notNull"
),
IN
(
"$in"
),
NOTIN
(
"$notIn"
),
LIKE
(
"$like"
),
LEFTLIKE
(
"$startsWith"
),
RIGHTLIKE
(
"$endsWith"
),
EXISTS
(
"$exists"
),
NOTEXISTS
(
"$notExists"
);
private
final
String
keyword
;
Segment
(
final
String
keyword
)
{
this
.
keyword
=
keyword
;
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/QueryWrapperContext.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.ParameterizedType
;
import
java.util.*
;
import
java.util.function.Consumer
;
@Slf4j
@Data
public
class
QueryWrapperContext
<
T
>
extends
SearchContextBase
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
QueryWrapper
<
T
>
selectCond
=
new
QueryWrapper
<
T
>();
/**
* 解析查询上下文中的参数,构建mybatis-plus分页对象
* @return
*/
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Page
getPages
(){
Page
page
;
List
<
String
>
asc_fieldList
=
new
ArrayList
<>();
List
<
String
>
desc_fieldList
=
new
ArrayList
<>();
int
currentPage
=
getPageable
().
getPageNumber
();
int
pageSize
=
getPageable
().
getPageSize
();
//构造mybatis-plus分页
if
(
StringUtils
.
isEmpty
(
currentPage
)
||
StringUtils
.
isEmpty
(
pageSize
))
{
page
=
new
Page
(
1
,
Short
.
MAX_VALUE
);
}
else
{
page
=
new
Page
(
currentPage
+
1
,
pageSize
);
}
//构造mybatis-plus排序
Sort
sort
=
getPageable
().
getSort
();
Iterator
<
Sort
.
Order
>
it_sort
=
sort
.
iterator
();
if
(
ObjectUtils
.
isEmpty
(
it_sort
))
{
return
page
;
}
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
getClass
().
getGenericSuperclass
();
Class
<
T
>
type
=
(
Class
<
T
>)
parameterizedType
.
getActualTypeArguments
()[
0
];
while
(
it_sort
.
hasNext
())
{
Sort
.
Order
sort_order
=
it_sort
.
next
();
if
(
sort_order
.
getDirection
()==
Sort
.
Direction
.
ASC
){
asc_fieldList
.
add
(
sort_order
.
getProperty
());
}
else
if
(
sort_order
.
getDirection
()==
Sort
.
Direction
.
DESC
){
desc_fieldList
.
add
(
sort_order
.
getProperty
());
}
}
if
(
asc_fieldList
.
size
()>
0
){
page
.
setAscs
(
asc_fieldList
);
}
if
(
desc_fieldList
.
size
()>
0
){
page
.
setDescs
(
desc_fieldList
);
}
return
page
;
}
public
QueryWrapper
<
T
>
getSearchCond
(){
return
this
.
selectCond
;
}
/**
* 填充自定义查询条件
* @return
*/
public
QueryWrapper
<
T
>
getSelectCond
()
{
if
(!
ObjectUtils
.
isEmpty
(
filter
)){
Consumer
queryWrapper
=
parseQueryFilter
(
filter
);
if
(!
ObjectUtils
.
isEmpty
(
queryWrapper
)){
selectCond
.
and
(
queryWrapper
);
}
}
return
selectCond
;
}
/**
* 解析自定义查询条件
* @param queryFilter
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseQueryFilter
(
QueryFilter
queryFilter
){
if
(
queryFilter
.
any
().
size
()==
0
&&
queryFilter
.
get
$or
()==
null
&&
queryFilter
.
get
$and
()==
null
)
{
return
null
;
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
Consumer
fieldConsumer
=
parseFieldMap
(
queryFilter
.
any
());
Consumer
orConsumer
=
parseOrQueryFilter
(
queryFilter
.
get
$or
());
Consumer
andConsumer
=
parseAndQueryFilter
(
queryFilter
.
get
$and
());
if
(!
ObjectUtils
.
isEmpty
(
fieldConsumer
)){
queryWrapper
.
and
(
fieldConsumer
);
}
if
(!
ObjectUtils
.
isEmpty
(
orConsumer
)){
queryWrapper
.
and
(
orConsumer
);
}
if
(!
ObjectUtils
.
isEmpty
(
andConsumer
)){
queryWrapper
.
and
(
andConsumer
);
}
};
return
consumer
;
}
/**
* 解析自定义条件[or]
* @param queryFilters
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseOrQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
)
return
null
;
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
for
(
QueryFilter
queryFilter:
queryFilters
){
Consumer
tempQueryWrapper
=
parseQueryFilter
(
queryFilter
);
queryWrapper
.
or
(
tempQueryWrapper
);
}
};
return
consumer
;
}
/**
* 解析自定义条件[and]
* @param queryFilters
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseAndQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
)
{
return
null
;
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
for
(
QueryFilter
queryFilter:
queryFilters
){
Consumer
tempQueryWrapper
=
parseQueryFilter
(
queryFilter
);
queryWrapper
.
and
(
tempQueryWrapper
);
}
};
return
consumer
;
}
/**
* 解析自定义条件[字段条件]
* @param fieldMap
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseFieldMap
(
Map
<
String
,
QueryFilter
.
SegmentCond
>
fieldMap
)
{
if
(
fieldMap
.
size
()==
0
)
{
return
null
;
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
for
(
Map
.
Entry
<
String
,
QueryFilter
.
SegmentCond
>
field:
fieldMap
.
entrySet
()){
String
fieldName
=
field
.
getKey
();
QueryFilter
.
SegmentCond
segmentCond
=
field
.
getValue
();
Map
<
String
,
Object
>
segmentCondMap
=
segmentCond
.
any
();
for
(
Map
.
Entry
<
String
,
Object
>
fieldCond:
segmentCondMap
.
entrySet
()){
Object
value
=
fieldCond
.
getValue
();
switch
(
fieldCond
.
getKey
()){
case
"$eq"
:
queryWrapper
.
eq
(
fieldName
,
value
);
break
;
case
"$ne"
:
queryWrapper
.
ne
(
fieldName
,
value
);
break
;
case
"$gt"
:
queryWrapper
.
gt
(
fieldName
,
value
);
break
;
case
"$gte"
:
queryWrapper
.
ge
(
fieldName
,
value
);
break
;
case
"$lt"
:
queryWrapper
.
lt
(
fieldName
,
value
);
break
;
case
"$lte"
:
queryWrapper
.
le
(
fieldName
,
value
);
break
;
case
"$null"
:
queryWrapper
.
isNull
(
fieldName
);
break
;
case
"$notNull"
:
queryWrapper
.
isNotNull
(
fieldName
);
break
;
case
"$in"
:
queryWrapper
.
in
(
fieldName
,(
Collection
)
value
);
break
;
case
"$notIn"
:
queryWrapper
.
notIn
(
fieldName
,(
Collection
)
value
);
break
;
case
"$like"
:
queryWrapper
.
like
(
fieldName
,
value
);
break
;
case
"$startsWith"
:
queryWrapper
.
likeRight
(
fieldName
,
value
);
break
;
case
"$endsWith"
:
queryWrapper
.
likeLeft
(
fieldName
,
value
);
break
;
case
"$exists"
:
break
;
case
"$notExists"
:
break
;
}
}
}
};
return
consumer
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/SearchContextBase.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
filter
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.fasterxml.jackson.annotation.JsonAnyGetter
;
import
com.fasterxml.jackson.annotation.JsonAnySetter
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Data
public
class
SearchContextBase
{
/**
* 自定义查询条件
*/
@JsonProperty
(
"customcond"
)
public
String
customCond
;
/**
* 自定义查询参数
*/
@JsonProperty
(
"customparams"
)
public
String
customParams
;
/**
* 快速搜索
*/
@JsonProperty
(
"query"
)
public
String
query
;
/**
* 条件表达式
*/
@JsonProperty
(
"filter"
)
public
QueryFilter
filter
;
/**
* 数据查询
*/
public
List
dataQueryList
;
/**
* 当前页数
*/
public
int
page
=
0
;
/**
* 每页显示条数
*/
public
int
size
=
20
;
/**
* 排序
*/
public
String
sort
;
/**
* 排序对象
*/
@JsonIgnore
public
Sort
pageSort
;
/**
* 工作流步骤标识
*/
public
String
userTaskId
;
/**
* 工作流流程标识
*/
public
String
processDefinitionKey
;
/**
* 获取工作流步骤标识
*/
public
String
getUserTaskId
()
{
if
(
StringUtils
.
isEmpty
(
userTaskId
)){
Object
taskId
=
params
.
get
(
"usertaskid"
);
return
StringUtils
.
isEmpty
(
taskId
)?
null
:
String
.
valueOf
(
taskId
);
}
else
{
return
userTaskId
;
}
}
/**
* 获取工作流流程标识
* @return
*/
public
String
getProcessDefinitionKey
()
{
if
(
StringUtils
.
isEmpty
(
processDefinitionKey
)){
Object
processKey
=
params
.
get
(
"processdefinitionkey"
);
return
StringUtils
.
isEmpty
(
processKey
)?
null
:
String
.
valueOf
(
processKey
);
}
else
{
return
processDefinitionKey
;
}
}
/**
* 获取分页参数
* @return
*/
public
Pageable
getPageable
()
{
if
(
ObjectUtils
.
isEmpty
(
pageSort
))
{
return
PageRequest
.
of
(
page
,
size
);
}
else
{
return
PageRequest
.
of
(
page
,
size
,
pageSort
);
}
}
/**
* 设置排序值
* @param strSort
*/
public
void
setSort
(
String
strSort
)
{
this
.
sort
=
strSort
;
if
(!
StringUtils
.
isEmpty
(
strSort
)){
String
sortArr
[]=
strSort
.
split
(
","
);
String
sortField
=
sortArr
[
0
];
String
sortDirection
=
sortArr
[
1
];
if
(
sortDirection
.
equalsIgnoreCase
(
"asc"
)){
this
.
pageSort
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
sortField
);
}
else
if
(
sortDirection
.
equalsIgnoreCase
(
"desc"
)){
this
.
pageSort
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
sortField
);
}
}
}
/**
* 上下文参数
*/
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>()
;
/**
* 获取数据上下文
* @return
*/
public
Map
<
String
,
Object
>
getDatacontext
()
{
return
params
;
}
/**
* 获取网页请求上下文
* @return
*/
public
Map
<
String
,
Object
>
getWebcontext
()
{
return
params
;
}
/**
* 获取用户上下文
* @return
*/
@JsonIgnore
public
Map
<
String
,
Object
>
getSessioncontext
()
{
return
AuthenticationUser
.
getAuthenticationUser
().
getSessionParams
();
}
@JsonAnyGetter
public
Map
<
String
,
Object
>
any
()
{
return
params
;
}
@JsonAnySetter
public
void
set
(
String
name
,
Object
value
)
{
params
.
put
(
name
,
value
);
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
浏览文件 @
823d1523
...
...
@@ -12,7 +12,7 @@ import java.util.List;
/**
* 实体[MetaModel] 服务对象接口
*/
@FeignClient
(
value
=
"${ibiz.ref.service.ibzlite-api:ibzlite-api}"
,
contextId
=
"LiteModel"
,
fallback
=
LiteModelFallback
.
class
)
@FeignClient
(
value
=
"${ibiz.ref.service.ibzlite-api:ibzlite-api}"
,
contextId
=
"
Data
LiteModel"
,
fallback
=
LiteModelFallback
.
class
)
public
interface
LiteModelFeignClient
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
浏览文件 @
823d1523
...
...
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
import
javax.annotation.PostConstruct
;
import
java.io.File
;
@Component
@Component
(
"DataLiteStorage"
)
public
class
LiteStorage
{
public
static
String
MODEL_PATH
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.core.data.dto.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -29,21 +28,12 @@ public class Setting {
return
DataObject
.
getStringValue
(
getMap
(
configString
).
get
(
propertyName
),
""
);
}
public
static
<
T
extends
EntityBase
>
T
getEntity
(
String
configString
,
T
entityBase
)
{
if
(
entityBase
!=
null
)
{
Map
map
=
getMap
(
configString
);
map
.
keySet
().
forEach
(
key
->{
entityBase
.
set
(
key
.
toString
(),
map
.
get
(
key
));
});
}
return
entityBase
;
}
public
static
Map
getMap
(
String
configString
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"param"
,
configString
);
map
.
put
(
"
t
param"
,
configString
);
if
(!(
StringUtils
.
isEmpty
(
configString
)))
{
try
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.core.data.dto.DataObj
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoProperty.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
...
...
@@ -10,7 +10,6 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
ibzdata-
provider/ibzdata-provider-api/src/main/java/cn/ibizlab/api
/rest/DataResource.java
→
ibzdata-
core/src/main/java/cn/ibizlab/core/data
/rest/DataResource.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
api
.
rest
;
package
cn
.
ibizlab
.
core
.
data
.
rest
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -18,7 +17,6 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.logging.Filter
;
@Slf4j
@Api
(
tags
=
{
"数据"
})
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDataService.java
浏览文件 @
823d1523
...
...
@@ -5,13 +5,10 @@ import cn.ibizlab.core.data.dto.BaseData;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Collection
;
import
java.util.List
;
public
interface
IDataService
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
service
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.lite.*
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
...
...
@@ -29,13 +31,78 @@ public class ModelService {
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
public
String
getModelPath
()
{
if
(
modelPath
.
equals
(
File
.
separator
))
return
modelPath
.
substring
(
0
,
modelPath
.
length
()-
1
);
return
modelPath
;
}
@Autowired
private
IDOModelService
doModelService
;
@Autowired
private
LiteModelFeignClient
liteService
;
@Autowired
@Lazy
private
DynamicModelService
dynamicService
;
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
doModelService
.
get
(
system
+
".domain."
+
entity
);
}
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-models'"
)
public
Map
<
String
,
DstSystemModel
>
getAllSystemModels
()
{
Map
<
String
,
DstSystemModel
>
models
=
dynamicService
.
findAllDynamicModel
();
List
<
DstSystemModel
>
liteSystems
=
liteService
.
getSysApps
();
if
(!
ObjectUtils
.
isEmpty
(
liteSystems
))
{
liteSystems
.
forEach
(
dstSystemModel
->{
String
system
=
dstSystemModel
.
getPssystemid
();
if
(!
models
.
containsKey
(
system
))
models
.
put
(
system
,
dstSystemModel
);
if
((!
system
.
toLowerCase
().
equals
(
system
))&&(!
models
.
containsKey
(
system
.
toLowerCase
())))
models
.
put
(
system
.
toLowerCase
(),
dstSystemModel
);
});
}
File
modelDir
=
new
File
(
getModelPath
());
if
(
modelDir
.
exists
())
{
for
(
File
sysDir:
modelDir
.
listFiles
())
{
if
(
Files
.
exists
(
Paths
.
get
(
sysDir
.
getAbsolutePath
(),
"repo"
,
"domain"
)))
{
String
system
=
sysDir
.
getName
();
DstSystemModel
dstSystemModel
=
new
DstSystemModel
().
setPssystemid
(
system
).
setPssystemname
(
system
);
if
(!
models
.
containsKey
(
system
))
models
.
put
(
system
,
dstSystemModel
);
if
((!
system
.
toLowerCase
().
equals
(
system
))&&(!
models
.
containsKey
(
system
.
toLowerCase
())))
models
.
put
(
system
.
toLowerCase
(),
dstSystemModel
);
}
}
}
return
models
;
}
@Cacheable
(
value
=
"meta-entities"
,
key
=
"'system:'+#p0"
)
public
Map
<
String
,
String
>
getEntitiesBySystem
(
String
system
)
throws
Exception
{
Map
<
String
,
String
>
entities
=
new
HashMap
<>();
Map
<
String
,
MetaEntityModel
>
entityModels
=
dynamicService
.
getEntities
(
system
);
entityModels
.
entrySet
().
forEach
(
entity
->{
entities
.
put
(
entity
.
getKey
(),
entity
.
getValue
().
getEntityName
());
});
return
null
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
823d1523
...
...
@@ -4,7 +4,6 @@ import cn.ibizlab.core.data.domain.DOModel;
import
cn.ibizlab.core.data.dto.*
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -15,7 +14,6 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.util.StringUtils
;
import
java.io.Serializable
;
import
java.util.Collection
;
import
java.util.List
;
/**
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.dto.*
;
import
cn.ibizlab.core.data.filter.DOModelSearchContext
;
import
cn.ibizlab.core.data.mapper.DbDataMapper
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -21,7 +14,6 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
java.io.Serializable
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoDataServiceImpl.java
浏览文件 @
823d1523
...
...
@@ -6,7 +6,6 @@ import cn.ibizlab.core.data.dto.FilterData;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/POModelServiceImpl.java
浏览文件 @
823d1523
...
...
@@ -29,8 +29,6 @@ import cn.ibizlab.core.data.domain.POModel;
import
cn.ibizlab.core.data.filter.POModelSearchContext
;
import
cn.ibizlab.core.data.service.IPOModelService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
/**
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/FilterDataResolver.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
cn.ibizlab.util.domain.DTOBase
;
import
cn.ibizlab.core.data.filter.SearchContextBase
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.MethodParameter
;
...
...
@@ -11,7 +10,6 @@ import org.springframework.web.context.request.NativeWebRequest;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.ModelAndViewContainer
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -28,7 +26,7 @@ public class FilterDataResolver implements HandlerMethodArgumentResolver {
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
SearchContextBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
||
DTOBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
return
SearchContextBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
||
FilterData
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
());
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/LiquibaseConfiguration.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.sql.DataSource
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
org.apache.ibatis.mapping.VendorDatabaseIdProvider
;
import
org.apache.ibatis.mapping.DatabaseIdProvider
;
import
java.util.Properties
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
cn.ibizlab.util.domain.LiquibaseProp
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
liquibase.integration.spring.SpringLiquibase
;
import
org.springframework.util.StringUtils
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
@Configuration
public
class
LiquibaseConfiguration
{
/**
* 主数据源版本管理
* @param
* @return
*/
@Bean
public
SpringLiquibase
masterliquibase
(
LiquibaseProp
masterProperties
)
{
return
LiquibaseInit
(
masterProperties
);
}
/**
* liquibase初始化数据库
* @param properties
* @return
*/
private
SpringLiquibase
LiquibaseInit
(
LiquibaseProp
properties
){
DruidDataSource
druidDataSource
=
new
DruidDataSource
();
druidDataSource
.
setUsername
(
properties
.
getUsername
());
druidDataSource
.
setPassword
(
properties
.
getPassword
());
druidDataSource
.
setUrl
(
properties
.
getUrl
());
SpringLiquibase
liquibase
=
new
SpringLiquibase
();
liquibase
.
setDataSource
(
druidDataSource
);
liquibase
.
setChangeLog
(
getChangelog
(
properties
.
getIsSyncDBSchema
(),
properties
.
getConf
()));
liquibase
.
setContexts
(
"development,test,production"
);
liquibase
.
setShouldRun
(
true
);
liquibase
.
setDefaultSchema
(
properties
.
getDefaultSchema
());
return
liquibase
;
}
/**
* 获取数据库差异文件
* @param isSyncDBSchema 是否同步表结构
* @param conf //liquibase配置文件
* @return
*/
private
String
getChangelog
(
String
isSyncDBSchema
,
String
conf
){
String
defaultChangelog
=
"classpath:liquibase/empty.xml"
;
if
((!
StringUtils
.
isEmpty
(
isSyncDBSchema
))&&(!
StringUtils
.
isEmpty
(
conf
))){
if
(
isSyncDBSchema
.
toLowerCase
().
equals
(
"true"
))
defaultChangelog
=
conf
;
}
return
defaultChangelog
;
}
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
cn.ibizlab.util.helper.JSR310DateConverters
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.mongodb.core.convert.*
;
import
java.sql.Timestamp
;
import
java.time.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Configuration
...
...
@@ -22,4 +25,141 @@ public class MongoDBConfig {
return
new
MongoCustomConversions
(
converterList
);
}
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/core/util/config/MybatisConfiguration.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties
;
import
cn.ibizlab.util.helper.UniqueNameGenerator
;
import
com.baomidou.mybatisplus.core.injector.ISqlInjector
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize
;
import
org.apache.ibatis.mapping.DatabaseIdProvider
;
...
...
@@ -11,7 +7,7 @@ import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Properties
;
/**
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/UniqueNameGenerator.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.context.annotation.AnnotationBeanNameGenerator
;
@Slf4j
public
class
UniqueNameGenerator
extends
AnnotationBeanNameGenerator
{
@Override
public
String
generateBeanName
(
BeanDefinition
definition
,
BeanDefinitionRegistry
registry
)
{
//全限定类名
String
beanName
=
definition
.
getBeanClassName
();
return
beanName
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/XxlJobConfig.java
浏览文件 @
823d1523
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Configuration
;
@ConditionalOnExpression
(
"!'${jobs.admin-address:NA}'.equals('NA')"
)
@Configuration
public
class
XxlJobConfig
{
}
ibzdata-core/src/main/java/cn/ibizlab/util/errors/BadRequestAlertException.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
util
.
errors
;
import
org.zalando.problem.AbstractThrowableProblem
;
import
org.zalando.problem.Status
;
import
java.net.URI
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
BadRequestAlertException
extends
AbstractThrowableProblem
{
private
final
String
entityName
;
private
final
String
errorKey
;
public
static
final
String
PROBLEM_BASE_URL
=
""
;
public
static
final
URI
DEFAULT_TYPE
=
URI
.
create
(
PROBLEM_BASE_URL
+
"/problem-with-message"
);
public
BadRequestAlertException
(
String
defaultMessage
,
String
entityName
,
String
errorKey
)
{
this
(
DEFAULT_TYPE
,
defaultMessage
,
entityName
,
errorKey
);
}
public
BadRequestAlertException
(
URI
type
,
String
defaultMessage
,
String
entityName
,
String
errorKey
)
{
super
(
type
,
defaultMessage
,
Status
.
BAD_REQUEST
,
null
,
null
,
null
,
getAlertParameters
(
entityName
,
errorKey
));
this
.
entityName
=
entityName
;
this
.
errorKey
=
errorKey
;
}
public
String
getEntityName
()
{
return
entityName
;
}
public
String
getErrorKey
()
{
return
errorKey
;
}
private
static
Map
<
String
,
Object
>
getAlertParameters
(
String
entityName
,
String
errorKey
)
{
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"message"
,
"error."
+
errorKey
);
parameters
.
put
(
"params"
,
entityName
);
return
parameters
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/util/security/AuthenticationUser.java
0 → 100644
浏览文件 @
823d1523
package
cn
.
ibizlab
.
util
.
security
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.util.ObjectUtils
;
import
java.sql.Timestamp
;
import
java.util.*
;
import
com.alibaba.fastjson.JSONObject
;
@Data
@AllArgsConstructor
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
AuthenticationUser
implements
UserDetails
{
public
AuthenticationUser
(){}
/**
* 用戶标识
*/
private
String
userid
;
/**
* 用户全局名
*/
private
String
username
;
/**
* 用户姓名
*/
private
String
personname
;
/**
* 登录名
*/
private
String
loginname
;
/**
* 用户工号
*/
private
String
usercode
;
/**
* 登录密码
*/
private
String
password
;
/**
* 区属
*/
private
String
domain
;
/**
* 租户
*/
private
String
srfdcid
;
/**
* 系统标识
*/
private
String
srfsystemid
;
/**
/**
* 动态实例标识
*/
private
String
srfdynainstid
;
/**
* 部门标识
*/
private
String
mdeptid
;
/**
* 部门编码
*/
private
String
mdeptcode
;
/**
* 部门名称
*/
private
String
mdeptname
;
/**
* 业务编码
*/
private
String
bcode
;
/**
* 岗位标识
*/
private
String
postid
;
/**
* 岗位代码
*/
private
String
postcode
;
/**
* 岗位名称
*/
private
String
postname
;
/**
* 单位标识
*/
private
String
orgid
;
/**
* 单位编码
*/
private
String
orgcode
;
/**
* 单位名称
*/
private
String
orgname
;
/**
* 昵称别名
*/
private
String
nickname
;
/**
* 邮箱
*/
private
String
email
;
/**
* 社交账号
*/
private
String
avatar
;
/**
* 电话
*/
private
String
phone
;
/**
* 照片
*/
private
String
usericon
;
/**
* 性别
*/
private
String
sex
;
/**
* 出生日期
*/
private
Timestamp
birthday
;
/**
* 证件号码
*/
private
String
certcode
;
/**
* 地址
*/
private
String
addr
;
/**
* 主题
*/
private
String
theme
;
/**
* 字号
*/
private
String
fontsize
;
/**
* 语言
*/
private
String
lang
;
/**
* 备注
*/
private
String
memo
;
/**
* 保留字段
*/
private
String
reserver
;
/**
* 用户上下文参数
*/
private
Map
<
String
,
Object
>
sessionParams
;
/**
* 用户权限资源
*/
@JsonIgnore
private
Collection
<
GrantedAuthority
>
authorities
;
/**
* 是否为超级管理员
*/
private
int
superuser
;
/**
* 用户权限资源
*/
private
JSONObject
permissionList
;
/**
* 用户上下文参数
*/
@JsonIgnore
private
Map
<
String
,
Object
>
userSessionParam
;
/**
* 当前用户上下级组织信息
*/
private
Map
<
String
,
Set
<
String
>>
orgInfo
;
/**
* 上级组织
*/
private
String
porg
;
/**
* 下级组织
*/
private
String
sorg
;
/**
* 上级部门
*/
private
String
pdept
;
/**
* 下级部门
*/
private
String
sdept
;
@JsonIgnore
@Override
public
boolean
isAccountNonExpired
()
{
return
true
;
}
@JsonIgnore
@Override
public
boolean
isAccountNonLocked
()
{
return
true
;
}
@JsonIgnore
@Override
public
boolean
isCredentialsNonExpired
()
{
return
true
;
}
@JsonIgnore
@Override
public
String
getPassword
()
{
return
password
;
}
@Override
public
boolean
isEnabled
()
{
return
true
;
}
public
static
AuthenticationUser
getAuthenticationUser
()
{
if
(
SecurityContextHolder
.
getContext
()==
null
||
SecurityContextHolder
.
getContext
().
getAuthentication
()==
null
||
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
()==
null
){
return
new
AuthenticationUser
();
}
Object
userDetails
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
AuthenticationUser
authuserdetail
;
if
(
userDetails
instanceof
AuthenticationUser
)
{
authuserdetail
=
(
AuthenticationUser
)
userDetails
;
}
else
{
authuserdetail
=
new
AuthenticationUser
();
}
return
authuserdetail
;
}
public
static
AuthenticationUser
setAuthenticationUser
(
String
userId
,
String
userName
)
{
AuthenticationUser
user
=
new
AuthenticationUser
();
user
.
setUserid
(
userId
);
user
.
setPersonname
(
userName
);
UsernamePasswordAuthenticationToken
authentication
=
new
UsernamePasswordAuthenticationToken
(
user
,
null
,
user
.
getAuthorities
());
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
return
user
;
}
public
Map
<
String
,
Object
>
getSessionParams
()
{
if
(
this
.
sessionParams
==
null
)
{
sessionParams
=
getUserSessionParam
();
sessionParams
.
put
(
"srfsystemid"
,
this
.
getSrfsystemid
());
sessionParams
.
put
(
"srfpersonid"
,
this
.
getUserid
());
sessionParams
.
put
(
"srfpersonname"
,
this
.
getPersonname
());
sessionParams
.
put
(
"srforgsectorid"
,
this
.
getMdeptid
());
sessionParams
.
put
(
"srforgsectorcode"
,
this
.
getMdeptcode
());
sessionParams
.
put
(
"srforgsectorname"
,
this
.
getMdeptname
());
sessionParams
.
put
(
"srforgid"
,
this
.
getOrgid
());
sessionParams
.
put
(
"srforgcode"
,
this
.
getOrgcode
());
sessionParams
.
put
(
"srforgname"
,
this
.
getOrgname
());
sessionParams
.
put
(
"srfuserid"
,
this
.
getUserid
());
sessionParams
.
put
(
"srfusername"
,
this
.
getPersonname
());
sessionParams
.
put
(
"srfusermode"
,
""
);
sessionParams
.
put
(
"srforgsectorbc"
,
this
.
getBcode
());
sessionParams
.
put
(
"srfloginname"
,
this
.
getLoginname
());
sessionParams
.
put
(
"srflocale"
,
this
.
getLang
());
sessionParams
.
put
(
"srftimezone"
,
""
);
sessionParams
.
put
(
"srfusercode"
,
this
.
getUsercode
());
sessionParams
.
put
(
"srfporg"
,
this
.
getPorg
());
sessionParams
.
put
(
"srfsorg"
,
this
.
getSorg
());
sessionParams
.
put
(
"srfpdept"
,
this
.
getPdept
());
sessionParams
.
put
(
"srfsdept"
,
this
.
getSdept
());
}
return
this
.
sessionParams
;
}
private
Map
<
String
,
Object
>
getUserSessionParam
()
{
if
(
userSessionParam
!=
null
){
return
userSessionParam
;
}
else
{
return
new
HashMap
<>();
}
}
public
void
setOrgInfo
(
Map
<
String
,
Set
<
String
>>
orgInfo
)
{
this
.
orgInfo
=
orgInfo
;
if
(!
ObjectUtils
.
isEmpty
(
orgInfo
)
&&
!
ObjectUtils
.
isEmpty
(
orgInfo
.
get
(
"parentorg"
))){
porg
=(
String
.
format
(
"'%s'"
,
String
.
join
(
"','"
,
orgInfo
.
get
(
"parentorg"
))));
this
.
getSessionParams
().
put
(
"srfporg"
,
porg
);
}
if
(!
ObjectUtils
.
isEmpty
(
orgInfo
)
&&
!
ObjectUtils
.
isEmpty
(
orgInfo
.
get
(
"suborg"
))
){
sorg
=(
String
.
format
(
"'%s'"
,
String
.
join
(
"','"
,
orgInfo
.
get
(
"suborg"
))));
this
.
getSessionParams
().
put
(
"srfsorg"
,
sorg
);
}
if
(!
ObjectUtils
.
isEmpty
(
orgInfo
)
&&
!
ObjectUtils
.
isEmpty
(
orgInfo
.
get
(
"parentdept"
))){
pdept
=(
String
.
format
(
"'%s'"
,
String
.
join
(
"','"
,
orgInfo
.
get
(
"parentdept"
))));
this
.
getSessionParams
().
put
(
"srfpdept"
,
pdept
);
}
if
(!
ObjectUtils
.
isEmpty
(
orgInfo
)
&&
!
ObjectUtils
.
isEmpty
(
orgInfo
.
get
(
"subdept"
))){
sdept
=(
String
.
format
(
"'%s'"
,
String
.
join
(
"','"
,
orgInfo
.
get
(
"subdept"
))));
this
.
getSessionParams
().
put
(
"srfsdept"
,
sdept
);
}
}
public
void
setPermissionList
(
JSONObject
permissionList
)
{
this
.
permissionList
=
permissionList
;
if
(
authorities
==
null
&&
permissionList
!=
null
){
if
(
permissionList
.
getJSONArray
(
"authorities"
)!=
null
){
authorities
=
new
ArrayList
<>();
permissionList
.
getJSONArray
(
"authorities"
).
forEach
(
item
->
authorities
.
add
(
new
SimpleGrantedAuthority
(
String
.
valueOf
(
item
))));
}
}
}
}
ibzdata-core/src/main/resources/application.yml
0 → 100644
浏览文件 @
823d1523
#Mybatis-plus配置
mybatis-plus
:
global-config
:
refresh-mapper
:
true
db-config
:
# 全局逻辑已删除默认值
logic-delete-value
:
0
# 全局逻辑未删除默认值
logic-not-delete-value
:
1
mapper-locations
:
classpath*:/mapper/*/*/*.xml
configuration
:
jdbc-type-for-null
:
'
null'
map-underscore-to-camel-case
:
false
ibzdata-provider/ibzdata-provider-api/pom.xml
浏览文件 @
823d1523
...
...
@@ -14,6 +14,11 @@
<description>
micorservice
</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>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录