Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
59cbb66b
提交
59cbb66b
编写于
8月 22, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
4be78d7f
变更
14
展开全部
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
1048 行增加
和
258 行删除
+1048
-258
DevBootApplication.java
...ata-boot/src/main/java/cn/ibizlab/DevBootApplication.java
+4
-2
application-boot.yml
ibzdata-boot/src/main/resources/application-boot.yml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+5
-2
FilterData.java
...re/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
+277
-0
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+55
-2
DbDataMapper.java
...c/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
+20
-9
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+1
-6
IDataService.java
.../main/java/cn/ibizlab/core/data/service/IDataService.java
+142
-88
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+99
-40
DbDataServiceImpl.java
.../cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
+142
-35
MongoDataServiceImpl.java
.../ibizlab/core/data/service/impl/MongoDataServiceImpl.java
+82
-14
FilterDataResolver.java
.../java/cn/ibizlab/core/util/config/FilterDataResolver.java
+52
-0
DbDataMapper.xml
...re/src/main/resources/mapper/data/DbData/DbDataMapper.xml
+31
-10
DataResource.java
...r-api/src/main/java/cn/ibizlab/api/rest/DataResource.java
+137
-49
未找到文件。
ibzdata-boot/src/main/java/cn/ibizlab/DevBootApplication.java
浏览文件 @
59cbb66b
package
cn
.
ibizlab
;
import
cn.ibizlab.core.util.config.FilterDataResolver
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
...
...
@@ -36,8 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
@EnableScheduling
public
class
DevBootApplication
extends
WebMvcConfigurerAdapter
{
@Autowired
SearchContextHandlerMethodArgumentResolver
r
esolver
;
FilterDataResolver
filterDataR
esolver
;
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DevBootApplication
.
class
,
args
);
...
...
@@ -46,6 +48,6 @@ public class DevBootApplication extends WebMvcConfigurerAdapter {
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
super
.
addArgumentResolvers
(
argumentResolvers
);
argumentResolvers
.
add
(
r
esolver
);
argumentResolvers
.
add
(
filterDataR
esolver
);
}
}
ibzdata-boot/src/main/resources/application-boot.yml
浏览文件 @
59cbb66b
...
...
@@ -2,7 +2,7 @@ spring:
datasource
:
username
:
root
password
:
root
url
:
jdbc:mysql://1
72.16.100.77
:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true&useTimezone=true&serverTimezone=GMT%2B8
url
:
jdbc:mysql://1
27.0.0.1
:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true&useTimezone=true&serverTimezone=GMT%2B8
isSyncDBSchema
:
false
dynamic
:
druid
:
#以下是全局默认值,可以全局更改
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
59cbb66b
...
...
@@ -292,18 +292,21 @@ public class DOModel extends EntityBase implements Serializable {
}
public
POSchema
getPOSchema
(
String
name
)
{
if
(
StringUtils
.
isEmpty
(
name
)&&
this
.
getSchema
()!=
null
)
name
=
this
.
getSchema
().
getDefaultDataSoruce
();
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
if
(
poSchemas
.
containsKey
(
name
))
{
return
poSchemas
.
get
(
name
);
}
else
if
(
this
.
getSchema
()!=
null
&&(
"default"
.
equals
(
name
)||
this
.
getSchema
().
getDefault
TableNam
e
().
equals
(
name
)))
else
if
(
this
.
getSchema
()!=
null
&&(
"default"
.
equals
(
name
)||
this
.
getSchema
().
getDefault
DataSoruc
e
().
equals
(
name
)))
{
POSchema
defaultPOSchema
=
TransUtils
.
PojoSchema2PO
(
this
.
getSchema
());
if
(
defaultPOSchema
!=
null
)
{
poSchemas
.
put
(
"default"
,
defaultPOSchema
);
poSchemas
.
put
(
this
.
getSchema
().
getDefault
TableNam
e
(),
defaultPOSchema
);
poSchemas
.
put
(
this
.
getSchema
().
getDefault
DataSoruc
e
(),
defaultPOSchema
);
return
defaultPOSchema
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
0 → 100644
浏览文件 @
59cbb66b
package
cn
.
ibizlab
.
core
.
data
.
dto
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
cn.ibizlab.util.filter.QueryWrapperContext
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
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.extension.plugins.pagination.Page
;
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
{
public
FilterData
set
(
String
key
,
Object
value
)
{
this
.
put
(
key
,
value
);
return
this
;
}
public
String
getDataSource
()
{
return
this
.
getStringValue
(
"datasource"
);
}
public
String
getQuery
()
{
return
this
.
getStringValue
(
"query"
);
}
public
FilterData
setQuery
(
String
query
)
{
return
this
.
set
(
"query"
,
query
);
}
public
int
getPage
()
{
return
this
.
getIntegerValue
(
"page"
,
0
);
}
public
FilterData
setPage
(
int
page
)
{
return
this
.
set
(
"page"
,
page
);
}
public
int
getSize
()
{
return
getIntegerValue
(
"size"
,
20
);
}
public
FilterData
setSize
(
int
size
)
{
return
this
.
set
(
"size"
,
size
);
}
public
String
getSort
()
{
return
this
.
getStringValue
(
"sort"
);
}
public
FilterData
setSort
(
String
sort
)
{
pageable
=
PageRequest
.
of
(
getPage
(),
getSize
(),
getPageSort
());
return
this
.
set
(
"sort"
,
sort
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Sort
pageSort
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Sort
getPageSort
()
{
if
(
pageSort
==
null
)
{
if
(!
StringUtils
.
isEmpty
(
getSort
())){
String
sortArr
[]=
getSort
().
split
(
","
);
String
sortField
=
sortArr
[
0
];
String
sortDirection
=
sortArr
.
length
>
1
?
sortArr
[
1
]:
"asc"
;
if
(
sortDirection
.
equalsIgnoreCase
(
"desc"
))
this
.
pageSort
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
sortField
);
else
this
.
pageSort
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
sortField
);
}
else
this
.
pageSort
=
Sort
.
unsorted
();
}
return
pageSort
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Pageable
pageable
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Pageable
getPageable
()
{
if
(
pageable
==
null
)
pageable
=
PageRequest
.
of
(
getPage
(),
getSize
(),
getPageSort
());
return
pageable
;
}
public
FilterData
setPageable
(
Pageable
pageable
)
{
this
.
pageable
=
pageable
;
return
this
;
}
public
BaseData
getParams
()
{
BaseData
param
=
null
;
Object
obj
=
this
.
get
(
"params"
);
if
(
obj
!=
null
)
{
if
(
obj
instanceof
BaseData
)
param
=(
BaseData
)
obj
;
else
if
(
obj
instanceof
Map
)
{
param
=
new
BaseData
().
setAll
((
Map
)
obj
);
this
.
set
(
"params"
,
param
);
}
}
else
{
return
this
;
}
return
param
;
}
public
FilterData
setParams
(
BaseData
params
)
{
return
this
.
set
(
"params"
,
params
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
Object
>
getDatacontext
()
{
return
getParams
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
Object
>
getWebcontext
()
{
return
getParams
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
Object
>
getSessioncontext
()
{
return
AuthenticationUser
.
getAuthenticationUser
().
getSessionParams
();
}
public
String
getUserTaskId
()
{
return
this
.
getStringValue
(
"userTaskId"
,
this
.
getParams
().
getStringValue
(
"userTaskId"
));
}
public
FilterData
setUserTaskId
(
String
userTaskId
)
{
return
this
.
set
(
"userTaskId"
,
userTaskId
);
}
public
String
getProcessDefinitionKey
()
{
return
this
.
getStringValue
(
"processDefinitionKey"
,
this
.
getParams
().
getStringValue
(
"processDefinitionKey"
));
}
public
FilterData
setProcessDefinitionKey
(
String
processDefinitionKey
)
{
return
this
.
set
(
"processDefinitionKey"
,
processDefinitionKey
);
}
private
QueryFilter
filter
;
public
QueryFilter
getFilter
()
{
return
filter
;
}
public
FilterData
setFilter
(
QueryFilter
filter
)
{
this
.
filter
=
filter
;
return
this
;
}
public
Page
getPages
(
POSchema
poSchema
)
{
return
getPages
(
poSchema
,
this
.
getPageable
());
}
public
static
Page
getPages
(
POSchema
poSchema
,
Pageable
pageable
){
Page
page
;
int
currentPage
=
pageable
.
getPageNumber
();
int
pageSize
=
pageable
.
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
=
pageable
.
getSort
();
Iterator
<
Sort
.
Order
>
it_sort
=
sort
.
iterator
();
if
(
ObjectUtils
.
isEmpty
(
it_sort
))
{
return
page
;
}
while
(
it_sort
.
hasNext
())
{
Sort
.
Order
sort_order
=
it_sort
.
next
();
String
colName
=
sort_order
.
getProperty
();
if
(
poSchema
!=
null
&&
poSchema
.
getColumn
(
colName
)!=
null
)
colName
=
poSchema
.
getColumn
(
colName
).
getName
();
page
.
addOrder
(
new
OrderItem
().
setColumn
(
colName
).
setAsc
(
sort_order
.
getDirection
()!=
Sort
.
Direction
.
DESC
));
}
return
page
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
QueryWrapper
searchCond
=
null
;
public
QueryWrapper
getSearchCond
()
{
if
(
searchCond
==
null
)
{
if
(
this
.
getFilter
()!=
null
)
{
QueryWrapperContext
context
=
new
QueryWrapperContext
();
context
.
setFilter
(
this
.
getFilter
());
searchCond
=
context
.
getSelectCond
();
}
else
{
searchCond
=
new
QueryWrapper
();
}
for
(
Object
obj:
this
.
keySet
())
{
String
key
=
obj
.
toString
().
toLowerCase
();
if
(
key
.
startsWith
(
"n_"
)&&
key
.
endsWith
(
"_like"
))
{
searchCond
.
like
(
key
.
substring
(
2
).
replace
(
"_like"
,
""
),
this
.
get
(
obj
));
}
}
}
return
searchCond
;
}
public
String
getSql
(
POSchema
.
Segment
segment
)
{
String
sql
=
segment
.
getBody
();
QueryWrapper
qw
=
this
.
getSearchCond
();
if
(
qw
!=
null
&&
qw
.
getSqlSegment
()!=
null
)
{
if
(!
qw
.
isEmptyOfWhere
())
sql
=
sql
.
concat
(
" where "
);
sql
=
sql
.
concat
(
qw
.
getSqlSegment
());
}
return
sql
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
59cbb66b
...
...
@@ -11,6 +11,8 @@ import net.ibizsys.model.dataentity.defield.IPSDEField;
import
net.ibizsys.model.dataentity.defield.IPSLinkDEField
;
import
net.ibizsys.model.dataentity.der.IPSDER1N
;
import
net.ibizsys.model.dataentity.der.IPSDERBase
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataQueryCode
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataQueryCodeCond
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.Cacheable
;
...
...
@@ -302,9 +304,12 @@ public class DynamicModelService {
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()!=
null
)
{
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->{
String
code
=
getQueryCode
(
dq
);
MetaDataSetModel
dsModel
=
new
MetaDataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
())
.
setDatasetName
(
dataQuery
.
getLogicName
()).
setCodeName
(
dataQuery
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
dq
.
getQueryCode
()
);
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
code
);
entityModel
.
addDataSet
(
dsModel
);
});
}
...
...
@@ -343,7 +348,8 @@ public class DynamicModelService {
code
=
map
.
get
(
dq
.
getDBType
());
code
=
code
+
"\r\n union all \r\n"
;
}
code
=
code
+
"<include refid=\""
+
entityModel
.
getEntityName
().
toLowerCase
()+
"_dq_"
+
dataQuery
.
getCodeName
()+
"_"
+
dq
.
getDBType
().
toLowerCase
()+
"\"/>"
;
code
=
code
+
getQueryCode
(
dq
);
;
//"<include refid=\""+entityModel.getEntityName().toLowerCase()+"_dq_"+dataQuery.getCodeName()+"_"+dq.getDBType().toLowerCase()+"\"/>";
map
.
put
(
dq
.
getDBType
(),
code
);
});
}
...
...
@@ -461,4 +467,51 @@ public class DynamicModelService {
}
}
/*
<#function contextParamConvert contextParam>
<#comment>补充上下文的IN查询(in通过$获取参数,其余为#): IN (${srfdatacontext('cityid','{"defname":"CITYID","dename":"CITY"}')}) -->IN ( ${srf.srfdatacontext.cityid} ) </#comment>
<#assign resultParam=contextParam?replace("(IN|in) \\(\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}\\)","$1 (\\$\{srf.$2.$3})","r")>
<#comment>平台配置格式替换${srfdatacontext('cityid','{"defname":"CITYID","dename":"CITY"}')} --> #{srf.srfdatacontext.cityid} </#comment>
<#assign resultParam=resultParam?replace("\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}","#\{srf.$1.$2}","r")>
<#comment>用户配置格式替换${srfdatacontext('cityid')} --> #{srf.srfdatacontext.cityid} </#comment>
<#assign resultParam=resultParam?replace("\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)'\\)}","#\{srf.$1.$2}","r")>
<#comment>将上下文参数转小写 #{srf.srfdatacontext.SRFORGID} --> #{srf.srfdatacontext.srforgid}</#comment>
<#assign params=resultParam?matches('srf.(datacontext|sessioncontext|webcontext).(\\w+)')>
<#list params as param>
<#assign resultParam=resultParam?replace(param,param?lower_case,'i')>
</#list>
<#if sys.getSaaSMode()==1 && item.getSaaSMode()==1>
<#assign resultParam=resultParam?replace("AND t11.SRFDCID = '__SRFSAASDCID__'","")>
</#if>
<#return resultParam>
</#function>
*/
private
String
contextParamConvert
(
String
contextParam
)
{
String
resultParam
=
contextParam
.
replaceAll
(
"(IN|in) \\(\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}\\)"
,
"$1 (\\${srf.$2.$3})"
);
resultParam
=
resultParam
.
replaceAll
(
"\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)','(.*?)'\\)}"
,
"#{srf.$1.$2}"
);
resultParam
=
resultParam
.
replaceAll
(
"\\$\\{srf(datacontext|sessioncontext|webcontext)\\('(\\w+)'\\)}"
,
"#{srf.$1.$2}"
);
resultParam
=
resultParam
.
replace
(
"AND t11.SRFDCID = '__SRFSAASDCID__'"
,
""
);
return
resultParam
;
}
private
String
getQueryCode
(
IPSDEDataQueryCode
dq
)
{
String
code
=
contextParamConvert
(
dq
.
getQueryCode
());
if
(
dq
.
getPSDEDataQueryCodeConds
()!=
null
)
{
int
i
=
0
;
for
(
IPSDEDataQueryCodeCond
cond:
dq
.
getPSDEDataQueryCodeConds
())
{
if
(
i
==
0
)
code
=
code
.
concat
(
" where "
);
else
if
(
i
>
0
)
code
=
code
.
concat
(
" and "
);
code
=
code
.
concat
(
contextParamConvert
(
cond
.
getCustomCond
()));
i
++;
}
}
return
code
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
浏览文件 @
59cbb66b
package
cn
.
ibizlab
.
core
.
data
.
mapper
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.model.POSchema
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Update
;
import
java.util.List
;
public
interface
DbDataMapper
{
List
<
BaseData
>
search
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
BaseData
>
wrapper
);
int
searchCount
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
BaseData
>
wrapper
);
int
insertData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
saveBatch
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
);
int
updateData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
removeData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
save
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
saveBatch
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"list"
)
List
<
BaseData
>
list
);
List
<
BaseData
>
check
Data
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
count
Data
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
List
<
BaseData
>
getData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
inser
tData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
List
<
BaseData
>
selec
tData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
Page
<
BaseData
>
selectData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
,
IPage
page
);
int
updateData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
@Update
(
"${sql}"
)
boolean
executeRaw
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"param"
)
BaseData
param
);
@Select
(
"${sql}"
)
List
<
BaseData
>
queryData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"srf"
)
FilterData
context
,
@Param
(
"ew"
)
QueryWrapper
wrapper
);
@Select
(
"${sql}"
)
Page
<
BaseData
>
queryData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"srf"
)
FilterData
context
,
@Param
(
"ew"
)
QueryWrapper
wrapper
,
IPage
page
);
int
removeData
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
59cbb66b
...
...
@@ -571,12 +571,7 @@ public class POSchema {
String
cols
=
""
;
if
(
getBaseColumnMap
()!=
null
)
{
for
(
String
key:
baseColumnMap
.
keySet
())
{
if
(!
StringUtils
.
isEmpty
(
cols
))
cols
+=
","
;
cols
+=(
"t1."
+
key
+
" as "
+
baseColumnMap
.
get
(
key
));
}
cols
=
String
.
join
(
","
,
baseColumnMap
.
keySet
());
}
else
cols
=
"t1.*"
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDataService.java
浏览文件 @
59cbb66b
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
59cbb66b
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
59cbb66b
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoDataServiceImpl.java
浏览文件 @
59cbb66b
...
...
@@ -2,9 +2,14 @@ package cn.ibizlab.core.data.service.impl;
import
cn.ibizlab.core.data.domain.DOModel
;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.io.Serializable
;
...
...
@@ -15,89 +20,152 @@ import java.util.List;
*/
@Slf4j
@Service
public
class
MongoDataServiceImpl
extends
BaseDataService
{
public
class
MongoDataServiceImpl
implements
IDataService
{
@Override
public
ResponseData
call
(
DOModel
model
,
String
scope
,
String
datasource
,
String
method
,
RequestData
requestData
)
{
return
null
;
}
@Override
public
boolean
create
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
void
createBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
}
@Override
public
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
update
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
void
createBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
updateBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
}
@Override
public
boolean
update
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
remove
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
return
false
;
}
@Override
public
void
updateBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
l
ist
)
public
void
removeBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idL
ist
)
{
}
@Override
public
boolean
remove
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
boolean
remove
ByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
void
removeBatch
(
DOModel
model
,
String
datasource
,
List
<
Serializable
>
idList
)
public
BaseData
get
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
return
null
;
}
@Override
public
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
)
{
return
null
;
}
@Override
public
BaseData
get
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
BaseData
get
ByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
null
;
}
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
null
;
}
@Override
public
boolean
checkKey
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
checkKey
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
boolean
save
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
save
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
void
saveBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
saveBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
}
@Override
public
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
dataSet
,
String
datasource
,
SearchContextBase
contex
t
)
public
List
<
BaseData
>
select
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
e
t
)
{
return
null
;
}
@Override
public
List
<
BaseData
>
list
(
DOModel
model
,
String
dataSet
,
String
datasource
,
SearchContextBase
context
)
public
Page
<
BaseData
>
select
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
,
Pageable
pageable
)
{
return
null
;
}
@Override
public
List
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
)
{
return
null
;
}
@Override
public
Page
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
)
{
return
null
;
}
@Override
public
List
<
BaseData
>
selectRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
FilterData
context
)
{
return
null
;
}
@Override
public
boolean
execRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
BaseData
param
)
{
return
false
;
}
@Override
public
List
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
)
{
return
null
;
}
@Override
public
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
)
{
return
null
;
}
@Override
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
null
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/FilterDataResolver.java
0 → 100644
浏览文件 @
59cbb66b
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
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.web.bind.support.WebDataBinderFactory
;
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
;
import
org.springframework.context.annotation.Configuration
;
@Slf4j
@Configuration
public
class
FilterDataResolver
implements
HandlerMethodArgumentResolver
{
@Value
(
"${ibiz.pageLimit:1000}"
)
private
int
pageLimit
=
1000
;
private
static
ObjectMapper
objectMapper
=
new
ObjectMapper
();
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
SearchContextBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
||
DTOBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
||
FilterData
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
());
}
@Override
public
Object
resolveArgument
(
MethodParameter
parameter
,
ModelAndViewContainer
mavContainer
,
NativeWebRequest
webRequest
,
WebDataBinderFactory
binderFactory
)
throws
Exception
{
Map
<
String
,
String
[]>
params
=
webRequest
.
getParameterMap
();
LinkedHashMap
<
String
,
Object
>
set
=
new
LinkedHashMap
<>();
for
(
String
key
:
params
.
keySet
())
{
set
.
put
(
key
,
params
.
get
(
key
)[
0
]);
}
if
(
SearchContextBase
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
&&
(!
set
.
containsKey
(
"size"
))){
set
.
put
(
"size"
,
pageLimit
);
}
if
(
FilterData
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
())
&&
(!
set
.
containsKey
(
"size"
))){
set
.
put
(
"size"
,
pageLimit
);
}
String
json
=
objectMapper
.
writeValueAsString
(
set
);
return
objectMapper
.
readValue
(
json
,
parameter
.
getParameterType
());
}
}
\ No newline at end of file
ibzdata-core/src/main/resources/mapper/data/DbData/DbDataMapper.xml
浏览文件 @
59cbb66b
...
...
@@ -43,21 +43,42 @@
</update>
<select
id=
"getData"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
resultType=
"cn.ibizlab.core.data.dto.BaseData"
>
select
<foreach
collection=
"schema.baseColumnMap"
item=
"value"
index=
"key"
separator=
","
>
${key}
</foreach>
from ${schema.name}
where
select t1.* from
<choose>
<when
test=
"schema.defaultQueryScript!=null"
>
( ${schema.defaultQueryScript.body} ) t1 where
</when>
<otherwise>
${schema.name} t1 where
<if
test=
"schema.logicValidColumn!=null"
>
${schema.logicValidCond} and
</if>
</otherwise>
</choose>
<foreach
collection=
"schema.keyMap"
item=
"value"
index=
"key"
separator=
"and"
>
${key}= #{data[${value}]}
</foreach>
</select>
<select
id=
"checkData"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
resultType=
"cn.ibizlab.core.data.dto.BaseData"
>
<select
id=
"selectData"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
resultType=
"cn.ibizlab.core.data.dto.BaseData"
>
select t1.* from
<choose>
<when
test=
"schema.defaultQueryScript!=null"
>
( ${schema.defaultQueryScript.body} ) t1 where
</when>
<otherwise>
${schema.name} t1 where
<if
test=
"schema.logicValidColumn!=null"
>
${schema.logicValidCond} and
</if>
</otherwise>
</choose>
<foreach
collection=
"schema.resultMap"
item=
"value"
index=
"key"
separator=
","
>
<if
test=
"data.keys.contains(value)"
>
${key}= #{data[${value}]}
</if>
</foreach>
</select>
<select
id=
"countData"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
resultType=
"java.lang.Integer"
>
select count(1) as cnt from ${schema.name}
where
<if
test=
"schema.logicValidColumn!=null"
>
...
...
ibzdata-provider/ibzdata-provider-api/src/main/java/cn/ibizlab/api/rest/DataResource.java
浏览文件 @
59cbb66b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录