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
...
...
@@ -2,10 +2,12 @@ package cn.ibizlab.core.data.service;
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.util.filter.SearchContextBase
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
...
...
@@ -15,171 +17,223 @@ import java.util.List;
public
interface
IDataService
{
default
ResponseData
call
(
String
system
,
String
entity
,
String
method
,
RequestData
requestData
)
ResponseData
call
(
DOModel
model
,
String
scope
,
String
datasource
,
String
method
,
RequestData
requestData
);
boolean
create
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
void
createBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
);
boolean
update
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
void
updateBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
);
boolean
remove
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
);
void
removeBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
);
boolean
removeByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
BaseData
get
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
);
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
);
BaseData
getByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
boolean
checkKey
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
boolean
save
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
void
saveBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
);
List
<
BaseData
>
select
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
);
Page
<
BaseData
>
select
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
,
Pageable
pageable
);
List
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
);
Page
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
);
List
<
BaseData
>
selectRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
FilterData
context
);
boolean
execRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
BaseData
param
);
List
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
);
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
);
default
ResponseData
call
(
RequestData
requestData
)
{
return
call
(
system
,
""
,
entity
,
method
,
""
,
requestData
);
return
call
(
requestData
.
getSystem
(),
requestData
.
getScope
(),
requestData
.
getEntity
(),
requestData
.
getDataSource
(),
requestData
.
getMethod
()
,
requestData
);
}
default
ResponseData
call
(
RequestData
requestData
)
default
ResponseData
call
(
String
system
,
String
entity
,
String
method
,
RequestData
requestData
)
{
return
call
(
getDOModel
(
requestData
.
getSystem
(),
requestData
.
getEntity
()),
requestData
.
getScope
(),
requestData
.
getMethod
(),
requestData
.
getDataSource
()
,
requestData
);
return
call
(
system
,
""
,
entity
,
method
,
""
,
requestData
);
}
default
boolean
create
(
String
system
,
String
entity
,
BaseData
et
)
{
return
create
(
getDOModel
(
system
,
entity
)
,
""
,
et
);
return
create
(
system
,
""
,
entity
,
""
,
et
);
}
default
void
createBatch
(
String
system
,
String
entity
,
List
<
BaseData
>
list
)
{
createBatch
(
getDOModel
(
system
,
entity
)
,
""
,
list
);
createBatch
(
system
,
""
,
entity
,
""
,
list
);
}
default
boolean
update
(
String
system
,
String
entity
,
BaseData
et
)
{
return
update
(
getDOModel
(
system
,
entity
)
,
""
,
et
);
return
update
(
system
,
""
,
entity
,
""
,
et
);
}
default
void
updateBatch
(
String
system
,
String
entity
,
List
<
BaseData
>
list
)
{
updateBatch
(
getDOModel
(
system
,
entity
)
,
""
,
list
);
updateBatch
(
system
,
""
,
entity
,
""
,
list
);
}
default
boolean
remove
(
String
system
,
String
entity
,
Serializable
key
)
{
return
remove
(
getDOModel
(
system
,
entity
)
,
""
,
key
);
return
remove
(
system
,
""
,
entity
,
""
,
key
);
}
default
void
removeBatch
(
String
system
,
String
entity
,
List
<
Serializable
>
idList
)
{
removeBatch
(
getDOModel
(
system
,
entity
),
""
,
idList
);
removeBatch
(
system
,
""
,
entity
,
""
,
idList
);
}
default
boolean
removeByMap
(
String
system
,
String
entity
,
BaseData
et
)
{
return
removeByMap
(
system
,
""
,
entity
,
""
,
et
);
}
default
BaseData
get
(
String
system
,
String
entity
,
Serializable
key
)
{
return
get
(
getDOModel
(
system
,
entity
),
""
,
key
);
return
get
(
system
,
""
,
entity
,
""
,
key
);
}
default
List
<
BaseData
>
getBatch
(
String
system
,
String
entity
,
List
<
Serializable
>
idList
)
{
return
getBatch
(
system
,
""
,
entity
,
""
,
idList
);
}
default
BaseData
getByMap
(
String
system
,
String
entity
,
BaseData
et
)
{
return
getByMap
(
system
,
""
,
entity
,
""
,
et
);
}
default
BaseData
getDraft
(
String
system
,
String
entity
,
BaseData
et
)
{
return
getDraft
(
getDOModel
(
system
,
entity
)
,
""
,
et
);
return
getDraft
(
system
,
""
,
entity
,
""
,
et
);
}
default
boolean
checkKey
(
String
system
,
String
entity
,
BaseData
et
)
{
return
checkKey
(
getDOModel
(
system
,
entity
)
,
""
,
et
);
return
checkKey
(
system
,
""
,
entity
,
""
,
et
);
}
default
boolean
save
(
String
system
,
String
entity
,
BaseData
et
)
{
return
save
(
getDOModel
(
system
,
entity
)
,
""
,
et
);
return
save
(
system
,
""
,
entity
,
""
,
et
);
}
default
void
saveBatch
(
String
system
,
String
entity
,
List
<
BaseData
>
list
)
{
saveBatch
(
getDOModel
(
system
,
entity
)
,
""
,
list
);
saveBatch
(
system
,
""
,
entity
,
""
,
list
);
}
default
Page
<
BaseData
>
fetch
(
String
system
,
String
entity
,
String
dataSet
,
SearchContextBase
context
)
{
return
fetch
(
getDOModel
(
system
,
entity
),
dataSet
,
""
,
context
);
default
List
<
BaseData
>
select
(
String
system
,
String
entity
,
BaseData
et
){
return
select
(
system
,
""
,
entity
,
""
,
et
);
}
default
List
<
BaseData
>
list
(
String
system
,
String
entity
,
String
dataSet
,
SearchContextBase
context
)
{
return
list
(
getDOModel
(
system
,
entity
),
dataSet
,
""
,
context
);
default
Page
<
BaseData
>
select
(
String
system
,
String
entity
,
BaseData
et
,
Pageable
pageable
){
return
select
(
system
,
""
,
entity
,
""
,
et
,
pageable
);
}
default
Page
<
BaseData
>
fetchDefault
(
String
system
,
String
entity
,
SearchContextBase
context
)
{
return
fetchDefault
(
getDOModel
(
system
,
entity
),
""
,
context
);
default
List
<
BaseData
>
query
(
String
system
,
String
entity
,
String
dataQuery
,
FilterData
context
){
return
query
(
system
,
""
,
entity
,
""
,
dataQuery
,
context
);
}
default
List
<
BaseData
>
listDefault
(
String
system
,
String
entity
,
SearchContextBase
context
)
{
return
listDefault
(
getDOModel
(
system
,
entity
),
""
,
context
);
default
Page
<
BaseData
>
query
(
String
system
,
String
entity
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
){
return
query
(
system
,
""
,
entity
,
""
,
dataQuery
,
context
,
pageable
);
}
DOModel
getDOModel
(
String
system
,
String
entity
);
ResponseData
call
(
DOModel
model
,
String
scope
,
String
method
,
String
datasource
,
RequestData
requestData
);
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
);
void
createBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
);
boolean
update
(
DOModel
model
,
String
datasource
,
BaseData
et
);
void
updateBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
);
boolean
remove
(
DOModel
model
,
String
datasource
,
Serializable
key
);
void
removeBatch
(
DOModel
model
,
String
datasource
,
List
<
Serializable
>
idList
);
BaseData
get
(
DOModel
model
,
String
datasource
,
Serializable
key
);
BaseData
getDraft
(
DOModel
model
,
String
datasource
,
BaseData
et
);
boolean
checkKey
(
DOModel
model
,
String
datasource
,
BaseData
et
);
boolean
save
(
DOModel
model
,
String
datasource
,
BaseData
et
);
void
saveBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
);
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
dataSet
,
String
datasource
,
SearchContextBase
context
);
List
<
BaseData
>
list
(
DOModel
model
,
String
dataSet
,
String
datasource
,
SearchContextBase
context
);
default
Page
<
BaseData
>
fetchDefault
(
DOModel
model
,
String
datasource
,
SearchContextBase
context
){
return
fetch
(
model
,
"default"
,
datasource
,
context
);
default
List
<
BaseData
>
selectRaw
(
String
system
,
String
entity
,
String
sql
,
FilterData
context
){
return
selectRaw
(
system
,
""
,
entity
,
""
,
sql
,
context
);
}
default
List
<
BaseData
>
listDefault
(
DOModel
model
,
String
datasource
,
SearchContextBase
context
){
return
list
(
model
,
"default"
,
datasource
,
context
);
default
boolean
execRaw
(
String
system
,
String
entity
,
String
sql
,
BaseData
param
){
return
execRaw
(
system
,
""
,
entity
,
""
,
sql
,
param
);
}
default
List
<
BaseData
>
fetch
(
String
system
,
String
entity
,
String
dataSet
,
FilterData
context
)
{
return
fetch
(
system
,
""
,
entity
,
""
,
dataSet
,
context
);
}
default
Page
<
BaseData
>
fetch
(
String
system
,
String
entity
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
)
{
return
fetch
(
system
,
""
,
entity
,
""
,
dataSet
,
context
,
pageable
);
}
default
ResponseData
call
(
String
system
,
String
scope
,
String
entity
,
String
method
,
String
datasource
,
RequestData
requestData
)
default
ResponseData
call
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
method
,
RequestData
requestData
)
{
requestData
.
setSystem
(
system
).
setScope
(
scope
).
setEntity
(
entity
).
setMethod
(
method
).
setDataSource
(
datasource
);
return
call
(
getDOModel
(
system
,
entity
),
scope
,
method
,
datasource
,
requestData
);
return
call
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
method
,
requestData
);
}
default
boolean
create
(
String
system
,
String
entity
,
String
datasource
,
BaseData
et
)
default
boolean
create
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
{
return
create
(
getDOModel
(
system
,
entity
),
datasource
,
et
);
return
create
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
);
}
default
void
createBatch
(
String
system
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
default
void
createBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
{
createBatch
(
getDOModel
(
system
,
entity
),
datasource
,
list
);
createBatch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
list
);
}
default
boolean
update
(
String
system
,
String
entity
,
String
datasource
,
BaseData
et
)
default
boolean
update
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
{
return
update
(
getDOModel
(
system
,
entity
),
datasource
,
et
);
return
update
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
);
}
default
void
updateBatch
(
String
system
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
default
void
updateBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
BaseData
>
list
)
{
updateBatch
(
getDOModel
(
system
,
entity
),
datasource
,
list
);
updateBatch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
list
);
}
default
boolean
remove
(
String
system
,
String
entity
,
String
datasource
,
Serializable
key
)
default
boolean
remove
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
Serializable
key
)
{
return
remove
(
getDOModel
(
system
,
entity
),
datasource
,
key
);
return
remove
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
key
);
}
default
void
removeBatch
(
String
system
,
String
entity
,
String
datasource
,
List
<
Serializable
>
idList
)
default
void
removeBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
Serializable
>
idList
)
{
removeBatch
(
getDOModel
(
system
,
entity
),
datasource
,
idList
);
removeBatch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
idList
);
}
default
BaseData
get
(
String
system
,
String
entity
,
String
datasource
,
Serializable
key
)
default
boolean
removeByMap
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
{
return
get
(
getDOModel
(
system
,
entity
),
datasource
,
key
);
return
removeByMap
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
);
}
default
BaseData
get
Draft
(
String
system
,
String
entity
,
String
datasource
,
BaseData
et
)
default
BaseData
get
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
Serializable
key
)
{
return
get
Draft
(
getDOModel
(
system
,
entity
),
datasource
,
et
);
return
get
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
key
);
}
default
boolean
checkKey
(
String
system
,
String
entity
,
String
datasource
,
BaseData
e
t
)
default
List
<
BaseData
>
getBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
Serializable
>
idLis
t
)
{
return
checkKey
(
getDOModel
(
system
,
entity
),
datasource
,
e
t
);
return
getBatch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
idLis
t
);
}
default
boolean
save
(
String
system
,
String
entity
,
String
datasource
,
BaseData
et
)
default
BaseData
getByMap
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
)
{
return
save
(
getDOModel
(
system
,
entity
)
,
datasource
,
et
);
return
getByMap
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
);
}
default
void
saveBatch
(
String
system
,
String
entity
,
String
datasource
,
List
<
BaseData
>
lis
t
)
default
BaseData
getDraft
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
e
t
)
{
saveBatch
(
getDOModel
(
system
,
entity
),
datasource
,
lis
t
);
return
getDraft
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
e
t
);
}
default
Page
<
BaseData
>
fetch
(
String
system
,
String
entity
,
String
dataSet
,
String
datasource
,
SearchContextBase
contex
t
)
default
boolean
checkKey
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
e
t
)
{
return
fetch
(
getDOModel
(
system
,
entity
),
dataSet
,
datasource
,
contex
t
);
return
checkKey
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
e
t
);
}
default
List
<
BaseData
>
list
(
String
system
,
String
entity
,
String
dataSet
,
String
datasource
,
SearchContextBase
contex
t
)
default
boolean
save
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
e
t
)
{
return
list
(
getDOModel
(
system
,
entity
),
dataSet
,
datasource
,
contex
t
);
return
save
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
e
t
);
}
default
Page
<
BaseData
>
fetchDefault
(
String
system
,
String
entity
,
String
datasource
,
SearchContextBase
contex
t
)
default
void
saveBatch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
List
<
BaseData
>
lis
t
)
{
return
fetchDefault
(
getDOModel
(
system
,
entity
),
datasource
,
contex
t
);
saveBatch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
lis
t
);
}
default
List
<
BaseData
>
listDefault
(
String
system
,
String
entity
,
String
datasource
,
SearchContextBase
context
)
{
return
listDefault
(
getDOModel
(
system
,
entity
),
datasource
,
context
);
default
List
<
BaseData
>
select
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
){
return
select
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
);
}
default
Page
<
BaseData
>
select
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
BaseData
et
,
Pageable
pageable
){
return
select
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
et
,
pageable
);
}
default
List
<
BaseData
>
query
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
dataQuery
,
FilterData
context
){
return
query
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
dataQuery
,
context
);
}
default
Page
<
BaseData
>
query
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
){
return
query
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
dataQuery
,
context
,
pageable
);
}
default
List
<
BaseData
>
selectRaw
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
sql
,
FilterData
context
){
return
selectRaw
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
sql
,
context
);
}
default
boolean
execRaw
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
sql
,
BaseData
param
){
return
execRaw
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
sql
,
param
);
}
default
List
<
BaseData
>
fetch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
dataSet
,
FilterData
context
){
return
fetch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
dataSet
,
context
);
}
default
Page
<
BaseData
>
fetch
(
String
system
,
String
scope
,
String
entity
,
String
datasource
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
){
return
fetch
(
getDOModel
(
system
,
entity
),
scope
,
datasource
,
dataSet
,
context
,
pageable
);
}
DOModel
getDOModel
(
String
system
,
String
entity
);
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
59cbb66b
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.DbDataQuery
;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
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
;
...
...
@@ -12,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
...
...
@@ -57,21 +55,21 @@ public class BaseDataService implements IDataService {
{
if
(
"create"
.
equalsIgnoreCase
(
method
))
{
if
(
create
(
model
,
datasource
,
requestBody
.
getBaseData
()))
if
(
create
(
model
,
scope
,
datasource
,
requestBody
.
getBaseData
()))
return
ResponseData
.
ok
(
requestBody
.
getBaseData
());
else
return
ResponseData
.
error
(
1
,
""
);
}
else
if
(
"update"
.
equalsIgnoreCase
(
method
))
{
if
(
update
(
model
,
datasource
,
requestBody
.
getBaseData
()))
if
(
update
(
model
,
scope
,
datasource
,
requestBody
.
getBaseData
()))
return
ResponseData
.
ok
(
requestBody
.
getBaseData
());
else
return
ResponseData
.
error
(
1
,
""
);
}
else
if
(
"save"
.
equalsIgnoreCase
(
method
))
{
if
(
save
(
model
,
datasource
,
requestBody
.
getBaseData
()))
if
(
save
(
model
,
scope
,
datasource
,
requestBody
.
getBaseData
()))
return
ResponseData
.
ok
(
requestBody
.
getBaseData
());
else
return
ResponseData
.
error
(
1
,
""
);
...
...
@@ -83,7 +81,7 @@ public class BaseDataService implements IDataService {
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKeyPropertyName
());
if
(
ObjectUtils
.
isEmpty
(
key
))
return
ResponseData
.
error
(
400
,
"key 没有输入"
);
if
(
remove
(
model
,
datasource
,
key
))
if
(
remove
(
model
,
scope
,
datasource
,
key
))
return
ResponseData
.
ok
(
requestBody
.
getBaseData
());
else
return
ResponseData
.
error
(
1
,
""
);
...
...
@@ -95,7 +93,7 @@ public class BaseDataService implements IDataService {
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKeyPropertyName
());
if
(
ObjectUtils
.
isEmpty
(
key
))
return
ResponseData
.
error
(
400
,
"key 没有输入"
);
BaseData
data
=
get
(
model
,
datasource
,
key
);
BaseData
data
=
get
(
model
,
scope
,
datasource
,
key
);
if
(
data
!=
null
)
return
ResponseData
.
ok
(
data
);
else
...
...
@@ -103,124 +101,185 @@ public class BaseDataService implements IDataService {
}
else
if
(
"checkKey"
.
equalsIgnoreCase
(
method
))
{
if
(
checkKey
(
model
,
datasource
,
requestBody
.
getBaseData
()))
if
(
checkKey
(
model
,
scope
,
datasource
,
requestBody
.
getBaseData
()))
return
ResponseData
.
ok
(
requestBody
.
getBaseData
());
else
return
ResponseData
.
error
(
1
,
""
);
}
else
if
(
"getDraft"
.
equalsIgnoreCase
(
method
))
{
return
ResponseData
.
ok
(
getDraft
(
model
,
datasource
,
requestBody
.
getBaseData
()));
return
ResponseData
.
ok
(
getDraft
(
model
,
scope
,
datasource
,
requestBody
.
getBaseData
()));
}
else
if
(
"createBatch"
.
equalsIgnoreCase
(
method
))
{
createBatch
(
model
,
datasource
,
requestBody
.
getListData
());
createBatch
(
model
,
scope
,
datasource
,
requestBody
.
getListData
());
return
ResponseData
.
ok
(
true
);
}
else
if
(
"updateBatch"
.
equalsIgnoreCase
(
method
))
{
updateBatch
(
model
,
datasource
,
requestBody
.
getListData
());
updateBatch
(
model
,
scope
,
datasource
,
requestBody
.
getListData
());
return
ResponseData
.
ok
(
true
);
}
else
if
(
"saveBatch"
.
equalsIgnoreCase
(
method
))
{
saveBatch
(
model
,
datasource
,
requestBody
.
getListData
());
saveBatch
(
model
,
scope
,
datasource
,
requestBody
.
getListData
());
return
ResponseData
.
ok
(
true
);
}
return
null
;
}
@Override
public
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
create
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
create
(
model
,
datasource
,
et
);
return
getProxyService
(
datasource
).
create
(
model
,
scope
,
datasource
,
et
);
}
@Override
public
void
createBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
createBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
getProxyService
(
datasource
).
createBatch
(
model
,
datasource
,
list
);
getProxyService
(
datasource
).
createBatch
(
model
,
scope
,
datasource
,
list
);
}
@Override
public
boolean
update
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
update
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
update
(
model
,
datasource
,
et
);
return
getProxyService
(
datasource
).
update
(
model
,
scope
,
datasource
,
et
);
}
@Override
public
void
updateBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
updateBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
getProxyService
(
datasource
).
updateBatch
(
model
,
datasource
,
list
);
getProxyService
(
datasource
).
updateBatch
(
model
,
scope
,
datasource
,
list
);
}
@Override
public
boolean
remove
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
boolean
remove
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
remove
(
model
,
datasource
,
key
);
return
getProxyService
(
datasource
).
remove
(
model
,
scope
,
datasource
,
key
);
}
@Override
public
void
removeBatch
(
DOModel
model
,
String
datasource
,
List
<
Serializable
>
idList
)
public
void
removeBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
getProxyService
(
datasource
).
removeBatch
(
model
,
datasource
,
idList
);
getProxyService
(
datasource
).
removeBatch
(
model
,
scope
,
datasource
,
idList
);
}
@Override
public
BaseData
get
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
boolean
removeByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
false
;
}
@Override
public
BaseData
get
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
get
(
model
,
datasource
,
key
);
return
getProxyService
(
datasource
).
get
(
model
,
scope
,
datasource
,
key
);
}
@Override
public
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
)
{
return
null
;
}
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
BaseData
getByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
null
;
}
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
getDraft
(
model
,
datasource
,
et
);
return
getProxyService
(
datasource
).
getDraft
(
model
,
scope
,
datasource
,
et
);
}
@Override
public
boolean
checkKey
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
checkKey
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
checkKey
(
model
,
datasource
,
et
);
return
getProxyService
(
datasource
).
checkKey
(
model
,
scope
,
datasource
,
et
);
}
@Override
public
boolean
save
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
save
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
save
(
model
,
datasource
,
et
);
return
getProxyService
(
datasource
).
save
(
model
,
scope
,
datasource
,
et
);
}
@Override
public
void
saveBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
saveBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
getProxyService
(
datasource
).
saveBatch
(
model
,
datasource
,
list
);
getProxyService
(
datasource
).
saveBatch
(
model
,
scope
,
datasource
,
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
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
dataSet
,
datasource
,
contex
t
);
return
getProxyService
(
datasource
).
select
(
model
,
scope
,
datasource
,
e
t
);
}
@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
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
list
(
model
,
dataSet
,
datasource
,
context
);
return
getProxyService
(
datasource
).
select
(
model
,
scope
,
datasource
,
et
,
pageable
);
}
@Override
public
List
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataQuery
,
context
);
}
@Override
public
Page
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataQuery
,
context
,
pageable
);
}
@Override
public
List
<
BaseData
>
selectRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
FilterData
context
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
selectRaw
(
model
,
scope
,
datasource
,
sql
,
context
);
}
@Override
public
boolean
execRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
BaseData
param
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
execRaw
(
model
,
scope
,
datasource
,
sql
,
param
);
}
@Override
public
List
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataSet
,
context
);
}
@Override
public
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
)
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
fetch
(
model
,
scope
,
datasource
,
dataSet
,
context
,
pageable
);
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
59cbb66b
...
...
@@ -2,21 +2,23 @@ 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.BaseData
;
import
cn.ibizlab.core.data.dto.DbDataQuery
;
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.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
;
...
...
@@ -31,127 +33,232 @@ import java.util.List;
*/
@Slf4j
@Service
public
class
DbDataServiceImpl
extends
Base
DataService
{
public
class
DbDataServiceImpl
implements
I
DataService
{
@Autowired
private
DbDataMapper
dbDataMapper
;
@Override
public
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
)
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
)
{
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
if
(
dbDataMapper
.
insertData
(
model
.
get
DefaultPOSchema
(
),
et
)==
1
)
et
.
setAll
(
get
(
model
,
datasource
,
key
));
if
(
dbDataMapper
.
insertData
(
model
.
get
POSchema
(
datasource
),
et
)==
1
)
et
.
setAll
(
get
(
model
,
scope
,
datasource
,
key
));
return
true
;
}
@Override
public
void
createBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
createBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
}
@Override
public
boolean
update
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
update
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
Serializable
key
=
model
.
getKeyValue
(
et
,
tru
e
);
Serializable
key
=
model
.
getKeyValue
(
et
,
fals
e
);
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
dbDataMapper
.
updateData
(
model
.
get
DefaultPOSchema
(
),
et
);
et
.
setAll
(
get
(
model
,
datasource
,(
Serializable
)
key
));
dbDataMapper
.
updateData
(
model
.
get
POSchema
(
datasource
),
et
);
et
.
setAll
(
get
(
model
,
scope
,
datasource
,(
Serializable
)
key
));
return
true
;
}
@Override
public
void
updateBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
)
public
void
updateBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
BaseData
>
list
)
{
}
@Override
public
boolean
remove
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
boolean
remove
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
BaseData
et
=
model
.
newData
(
key
);
if
(
et
==
null
)
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
dbDataMapper
.
removeData
(
model
.
get
DefaultPOSchema
(
),
et
);
dbDataMapper
.
removeData
(
model
.
get
POSchema
(
datasource
),
et
);
return
true
;
}
@Override
public
void
removeBatch
(
DOModel
model
,
String
datasource
,
List
<
Serializable
>
idList
)
public
void
removeBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idList
)
{
}
@Override
public
BaseData
get
(
DOModel
model
,
String
datasource
,
Serializable
key
)
public
boolean
removeByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
dbDataMapper
.
removeData
(
poSchema
,
et
);
return
true
;
}
@Override
public
BaseData
get
(
DOModel
model
,
String
scope
,
String
datasource
,
Serializable
key
)
{
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
BaseData
et
=
model
.
newData
(
key
);
if
(
et
==
null
)
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
get
DefaultPOSchema
(
);
POSchema
poSchema
=
model
.
get
POSchema
(
datasource
);
List
<
BaseData
>
list
=
dbDataMapper
.
getData
(
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
if
(
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"数据不唯一"
,
model
.
getName
(),
key
.
toString
());
return
poSchema
.
trans
(
list
.
get
(
0
));
}
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
datasource
,
BaseData
e
t
)
public
List
<
BaseData
>
getBatch
(
DOModel
model
,
String
scope
,
String
datasource
,
List
<
Serializable
>
idLis
t
)
{
return
null
;
}
@Override
public
boolean
checkKey
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
BaseData
getByMap
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
Serializable
key
=
model
.
getKeyValue
(
et
,
true
);
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到主键"
,
model
.
getName
(),
null
);
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
List
<
BaseData
>
list
=
dbDataMapper
.
getData
(
poSchema
,
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
return
poSchema
.
trans
(
list
.
get
(
0
));
}
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
return
null
;
}
@Override
public
boolean
checkKey
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
Serializable
key
=
model
.
getKeyValue
(
et
,
false
);
if
(
ObjectUtils
.
isEmpty
(
key
))
return
false
;
List
<
BaseData
>
list
=
dbDataMapper
.
getData
(
model
.
getDefaultPOSchema
(),
et
);
if
(
ObjectUtils
.
isEmpty
(
list
)&&
list
.
size
()==
1
)
return
list
.
get
(
0
).
getIntegerValue
(
"cnt"
,
0
)==
1
;
return
false
;
int
cnt
=
dbDataMapper
.
countData
(
model
.
getPOSchema
(
datasource
),
et
);
return
cnt
==
1
;
}
@Override
public
boolean
save
(
DOModel
model
,
String
datasource
,
BaseData
et
)
public
boolean
save
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
if
(
checkKey
(
model
,
datasource
,
et
))
return
update
(
model
,
datasource
,
et
);
if
(
checkKey
(
model
,
scope
,
datasource
,
et
))
return
update
(
model
,
scope
,
datasource
,
et
);
else
return
create
(
model
,
datasource
,
et
);
return
create
(
model
,
scope
,
datasource
,
et
);
}
@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
;
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
return
dbDataMapper
.
selectData
(
poSchema
,
et
);
}
@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
;
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
BaseData
>
pages
=
dbDataMapper
.
selectData
(
poSchema
,
et
,
FilterData
.
getPages
(
poSchema
,
pageable
));
return
new
PageImpl
<
BaseData
>(
pages
.
getRecords
(),
pageable
,
pages
.
getTotal
());
}
@Override
public
List
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
POSchema
.
Segment
segment
=
poSchema
.
getSegment
(
"-dq-"
+
dataQuery
+
"-"
,
""
);
return
dbDataMapper
.
queryData
(
poSchema
,
context
.
getSql
(
segment
),
context
,
context
.
getSearchCond
());
}
@Override
public
Page
<
BaseData
>
query
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataQuery
,
FilterData
context
,
Pageable
pageable
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
POSchema
.
Segment
segment
=
poSchema
.
getSegment
(
"-dq-"
+
dataQuery
+
"-"
,
""
);
if
(
pageable
!=
null
)
context
.
setPageable
(
pageable
);
else
pageable
=
context
.
getPageable
();
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
BaseData
>
pages
=
dbDataMapper
.
queryData
(
poSchema
,
context
.
getSql
(
segment
),
context
,
context
.
getSearchCond
(),
context
.
getPages
(
poSchema
));
return
new
PageImpl
<
BaseData
>(
pages
.
getRecords
(),
pageable
,
pages
.
getTotal
());
}
@Override
public
List
<
BaseData
>
selectRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
FilterData
context
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
return
dbDataMapper
.
queryData
(
poSchema
,
sql
,
context
,
context
.
getSearchCond
());
}
@Override
public
boolean
execRaw
(
DOModel
model
,
String
scope
,
String
datasource
,
String
sql
,
BaseData
param
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
return
dbDataMapper
.
executeRaw
(
poSchema
,
sql
,
param
);
}
@Override
public
List
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
POSchema
.
Segment
segment
=
poSchema
.
getSegment
(
"-ds-"
+
dataSet
+
"-"
,
""
);
return
dbDataMapper
.
queryData
(
poSchema
,
context
.
getSql
(
segment
),
context
,
context
.
getSearchCond
());
}
@Override
public
Page
<
BaseData
>
fetch
(
DOModel
model
,
String
scope
,
String
datasource
,
String
dataSet
,
FilterData
context
,
Pageable
pageable
)
{
POSchema
poSchema
=
model
.
getPOSchema
(
datasource
);
POSchema
.
Segment
segment
=
poSchema
.
getSegment
(
"-ds-"
+
dataSet
+
"-"
,
""
);
if
(
pageable
!=
null
)
context
.
setPageable
(
pageable
);
else
pageable
=
context
.
getPageable
();
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
BaseData
>
pages
=
dbDataMapper
.
queryData
(
poSchema
,
context
.
getSql
(
segment
),
context
,
context
.
getSearchCond
(),
context
.
getPages
(
poSchema
));
return
new
PageImpl
<
BaseData
>(
pages
.
getRecords
(),
pageable
,
pages
.
getTotal
());
}
@Override
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
modelService
.
getDOModel
(
system
,
entity
);
}
@Autowired
private
ModelService
modelService
;
}
...
...
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
<if
test=
"schema.logicValidColumn!=null"
>
${schema.logicValidCond} and
</if>
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
package
cn
.
ibizlab
.
api
.
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
;
...
...
@@ -17,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.logging.Filter
;
@Slf4j
@Api
(
tags
=
{
"数据"
})
...
...
@@ -24,102 +26,170 @@ import java.util.List;
@RequestMapping
(
""
)
public
class
DataResource
{
@Autowired
public
IDataService
dataService
;
@ApiOperation
(
value
=
"保存数据"
,
tags
=
{
"数据"
},
notes
=
"保存数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{system}/{entity}/{method}"
,
"/{system}/{scope}/{entity}/{method}"
,
"/ibiz-repository/{system}/{entity}/{method}"
,
"/ibiz-repository/{system}/{scope}/{entity}/{method}"
,
"/ibiz-repo/{system}/{entity}/{method}"
,
"/ibiz-repo/{system}/{scope}/{entity}/{method}"
})
public
ResponseEntity
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"method"
,
required
=
true
)
String
method
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
RequestData
requestData
)
{
ResponseData
responseData
=
dataService
.
call
(
system
,
scope
,
entity
,
method
,
datasource
,
requestData
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/{method}"
,
"/ibiz-repo/{system}/{entity}/{method}"
})
public
ResponseEntity
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"method"
,
required
=
true
)
String
method
,
@RequestBody
RequestData
requestData
)
{
ResponseData
responseData
=
dataService
.
call
(
system
,
scope
,
entity
,
datasource
,
method
,
requestData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
responseData
.
getBody
());
}
@ApiOperation
(
value
=
"新建数据"
,
tags
=
{
"数据"
},
notes
=
"新建数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}"
)
public
ResponseEntity
<
BaseData
>
create
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@Validated
@RequestBody
BaseData
baseData
)
{
dataService
.
create
(
system
,
entity
,
datasource
,
baseData
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}"
,
"/ibiz-repo/{system}/{entity}"
,
"/ibiz-repository/{system}/{scope}/{entity}/create"
,
"/ibiz-repo/{system}/{entity}/create"
})
public
ResponseEntity
<
BaseData
>
create
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@Validated
@RequestBody
BaseData
baseData
)
{
dataService
.
create
(
system
,
scope
,
entity
,
datasource
,
baseData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
}
@ApiOperation
(
value
=
"批量新建数据"
,
tags
=
{
"数据"
},
notes
=
"批量新建数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/batch"
)
public
ResponseEntity
<
Boolean
>
createBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
createBatch
(
system
,
entity
,
datasource
,
baseDatas
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/batch"
,
"/ibiz-repo/{system}/{entity}/batch"
,
"/ibiz-repository/{system}/{scope}/{entity}/createbatch"
,
"/ibiz-repo/{system}/{entity}/createbatch"
})
public
ResponseEntity
<
Boolean
>
createBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
createBatch
(
system
,
scope
,
entity
,
datasource
,
baseDatas
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"获取数据"
,
tags
=
{
"数据"
},
notes
=
"获取数据"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}/{entity}/{key}"
)
public
ResponseEntity
<
BaseData
>
get
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
true
)
String
key
)
{
BaseData
baseData
=
dataService
.
get
(
system
,
entity
,
datasource
,
key
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/{key}"
,
"/ibiz-repo/{system}/{entity}/{key}"
})
public
ResponseEntity
<
BaseData
>
get
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
true
)
String
key
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
get
(
system
,
scope
,
entity
,
datasource
,
key
));
}
@ApiOperation
(
value
=
"获取数据"
,
tags
=
{
"数据"
},
notes
=
"获取数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/get"
,
"/ibiz-repo/{system}/{entity}/get"
})
public
ResponseEntity
<
BaseData
>
get
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@Validated
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
getByMap
(
system
,
scope
,
entity
,
datasource
,
baseData
));
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
"/{system}/{entity}/{key}"
)
public
ResponseEntity
<
Boolean
>
remove
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
true
)
String
key
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
remove
(
system
,
entity
,
datasource
,
key
));
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/{key}"
,
"/ibiz-repo/{system}/{entity}/{key}"
}
)
public
ResponseEntity
<
Boolean
>
remove
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"
scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"
entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
true
)
String
key
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
remove
(
system
,
scope
,
entity
,
datasource
,
key
));
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/remove"
,
"/ibiz-repo/{system}/{entity}/remove"
})
public
ResponseEntity
<
Boolean
>
remove
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@Validated
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
removeByMap
(
system
,
scope
,
entity
,
datasource
,
baseData
));
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
"/{system}/{entity}/batch"
)
public
ResponseEntity
<
Boolean
>
removeBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
ids
)
{
dataService
.
removeBatch
(
system
,
entity
,
datasource
,
ids
);
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/batch"
,
"/ibiz-repo/{system}/{entity}/batch"
})
public
ResponseEntity
<
Boolean
>
removeBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
ids
)
{
dataService
.
removeBatch
(
system
,
scope
,
entity
,
datasource
,
ids
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/removebatch"
,
"/ibiz-repo/{system}/{entity}/removebatch"
})
public
ResponseEntity
<
Boolean
>
removeBatch2
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
ids
)
{
dataService
.
removeBatch
(
system
,
scope
,
entity
,
datasource
,
ids
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
"/{system}/{entity}/{key}"
)
public
ResponseEntity
<
BaseData
>
update
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
true
)
String
key
,
@RequestBody
BaseData
baseData
)
{
dataService
.
update
(
system
,
entity
,
datasource
,
baseData
.
setKey
(
key
));
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/{key}"
,
"/ibiz-repo/{system}/{entity}/{key}"
,
"/ibiz-repository/{system}/{scope}/{entity}"
,
"/ibiz-repo/{system}/{entity}"
})
public
ResponseEntity
<
BaseData
>
update
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestBody
BaseData
baseData
)
{
dataService
.
update
(
system
,
scope
,
entity
,
datasource
,
baseData
.
setKey
(
key
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/update"
,
"/ibiz-repo/{system}/{entity}/update"
})
public
ResponseEntity
<
BaseData
>
update
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
dataService
.
update
(
system
,
scope
,
entity
,
datasource
,
baseData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
}
@ApiOperation
(
value
=
"批量更新数据"
,
tags
=
{
"数据"
},
notes
=
"批量更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
"/{system}/{entity}/batch"
)
public
ResponseEntity
<
Boolean
>
updateBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
updateBatch
(
system
,
entity
,
datasource
,
baseDatas
);
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/batch"
,
"/ibiz-repo/{system}/{entity}/batch"
})
public
ResponseEntity
<
Boolean
>
updateBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
updateBatch
(
system
,
scope
,
entity
,
datasource
,
baseDatas
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"批量更新数据"
,
tags
=
{
"数据"
},
notes
=
"批量更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/updatebatch"
,
"/ibiz-repo/{system}/{entity}/updatebatch"
})
public
ResponseEntity
<
Boolean
>
updateBatch2
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
updateBatch
(
system
,
scope
,
entity
,
datasource
,
baseDatas
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"检查数据"
,
tags
=
{
"数据"
},
notes
=
"检查数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/checkkey"
)
public
ResponseEntity
<
Boolean
>
checkKey
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
checkKey
(
system
,
entity
,
datasource
,
baseData
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/checkkey"
,
"/ibiz-repo/{system}/{entity}/checkkey"
})
public
ResponseEntity
<
Boolean
>
checkKey
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dataService
.
checkKey
(
system
,
scope
,
entity
,
datasource
,
baseData
));
}
@ApiOperation
(
value
=
"获取数据草稿"
,
tags
=
{
"数据"
},
notes
=
"获取数据草稿"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}/{entity}/getdraft"
)
public
ResponseEntity
<
BaseData
>
getDraft
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
(
required
=
false
)
BaseData
baseData
)
{
dataService
.
getDraft
(
system
,
entity
,
datasource
,
baseData
);
@RequestMapping
(
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
},
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/getdraft"
,
"/ibiz-repo/{system}/{entity}/getdraft"
})
public
ResponseEntity
<
BaseData
>
getDraft
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
(
required
=
false
)
BaseData
baseData
)
{
dataService
.
getDraft
(
system
,
scope
,
entity
,
datasource
,
baseData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
}
@ApiOperation
(
value
=
"保存数据"
,
tags
=
{
"数据"
},
notes
=
"保存数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/save"
)
public
ResponseEntity
<
BaseData
>
save
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
dataService
.
save
(
system
,
entity
,
datasource
,
baseData
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/save"
,
"/ibiz-repo/{system}/{entity}/save"
})
public
ResponseEntity
<
BaseData
>
save
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
dataService
.
save
(
system
,
scope
,
entity
,
datasource
,
baseData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
baseData
);
}
@ApiOperation
(
value
=
"批量保存数据"
,
tags
=
{
"数据"
},
notes
=
"批量保存数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/savebatch"
)
public
ResponseEntity
<
Boolean
>
saveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
saveBatch
(
system
,
entity
,
datasource
,
baseDatas
);
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/ibiz-repository/{system}/{scope}/{entity}/savebatch"
,
"/ibiz-repo/{system}/{entity}/savebatch"
})
public
ResponseEntity
<
Boolean
>
saveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
dataService
.
saveBatch
(
system
,
scope
,
entity
,
datasource
,
baseDatas
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"数据"
}
,
notes
=
"获取数据集"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}/{entity}/fetch{dataset}"
)
public
ResponseEntity
<
List
<
BaseData
>>
fetchDefault
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
SearchContextBase
context
)
{
Page
<
BaseData
>
baseDatas
=
dataService
.
fetch
(
system
,
entity
,
dataset
,
datasource
,
context
)
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
={
"/ibiz-repository/{system}/{scope}/{entity}/fetch{dataset}"
,
"/ibiz-repo/{system}/{entity}/fetch{dataset}"
})
public
ResponseEntity
<
List
<
BaseData
>>
fetch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
FilterData
context
)
{
Page
<
BaseData
>
baseDatas
=
dataService
.
fetch
(
system
,
scope
,
entity
,
context
.
getDataSource
(),
dataset
,
context
,
context
.
getPageable
())
;
List
<
BaseData
>
list
=
baseDatas
.
getContent
();
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
...
...
@@ -128,11 +198,29 @@ public class DataResource
.
body
(
list
);
}
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"数据"
}
,
notes
=
"获取数据集"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/ibiz-repository/{system}/{scope}/{entity}/fetch{dataset}"
,
"/ibiz-repo/{system}/{entity}/fetch{dataset}"
})
public
ResponseEntity
<
List
<
BaseData
>>
fetch2
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestBody
FilterData
context
)
{
Page
<
BaseData
>
baseDatas
=
dataService
.
fetch
(
system
,
scope
,
entity
,
datasource
,
dataset
,
context
,
context
.
getPageable
())
;
List
<
BaseData
>
list
=
baseDatas
.
getContent
();
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
.
header
(
"x-total"
,
String
.
valueOf
(
baseDatas
.
getTotalElements
()))
.
body
(
list
);
}
@ApiOperation
(
value
=
"查询数据集"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据集"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/search{dataset}"
)
public
ResponseEntity
<
Page
<
BaseData
>>
searchDefault
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
SearchContextBase
context
)
{
Page
<
BaseData
>
baseDatas
=
dataService
.
fetch
(
system
,
entity
,
dataset
,
datasource
,
context
)
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/ibiz-repository/{system}/{scope}/{entity}/search{dataset}"
,
"/ibiz-repo/{system}/{entity}/search{dataset}"
})
public
ResponseEntity
<
Page
<
BaseData
>>
search
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestBody
FilterData
context
)
{
Page
<
BaseData
>
baseDatas
=
dataService
.
fetch
(
system
,
scope
,
entity
,
datasource
,
dataset
,
context
,
context
.
getPageable
())
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
body
(
new
PageImpl
(
baseDatas
.
getContent
(),
context
.
getPageable
(),
baseDatas
.
getTotalElements
()));
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录