Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
9aa83a97
提交
9aa83a97
编写于
12月 24, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
litedata 逻辑
上级
6014a1f9
变更
18
展开全部
显示空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
620 行增加
和
221 行删除
+620
-221
application-boot.yml
ibzlite-boot/src/main/resources/application-boot.yml
+0
-2
pom.xml
ibzlite-core/pom.xml
+7
-0
DbEntityMapper.java
...ava/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
+3
-2
DstDataSourceExService.java
...izlab/core/extensions/service/DstDataSourceExService.java
+40
-32
EntityModel.java
...a/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
+19
-18
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+9
-0
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+146
-0
NestedArray.java
...a/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
+50
-0
Setting.java
.../java/cn/ibizlab/core/lite/extensions/domain/Setting.java
+21
-0
DataModel.java
...java/cn/ibizlab/core/lite/extensions/model/DataModel.java
+25
-4
CommonEntityService.java
...lab/core/lite/extensions/service/CommonEntityService.java
+4
-5
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+108
-134
LiteDataCallback.java
...bizlab/core/lite/extensions/service/LiteDataCallback.java
+8
-0
LiteDataService.java
...ibizlab/core/lite/extensions/service/LiteDataService.java
+149
-0
LiteModelService.java
...bizlab/core/lite/extensions/service/LiteModelService.java
+4
-1
MongoEntityService.java
...zlab/core/lite/extensions/service/MongoEntityService.java
+8
-14
DbEntityMapper.xml
...rc/main/resources/mapper/lite/dbentity/DbEntityMapper.xml
+12
-5
LiteCoreResource.java
...java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
+7
-4
未找到文件。
ibzlite-boot/src/main/resources/application-boot.yml
浏览文件 @
9aa83a97
server
:
port
:
8086
ibiz
:
filePath
:
/app/file/
#nacos配置中心
spring
:
cloud
:
...
...
ibzlite-core/pom.xml
浏览文件 @
9aa83a97
...
...
@@ -58,6 +58,13 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
<!-- MyBatis游标查询 -->
<dependency>
<groupId>
org.springframework.batch
</groupId>
<artifactId>
spring-batch-core
</artifactId>
<version>
4.1.2.RELEASE
</version>
</dependency>
<!-- MySQL数据库 -->
<dependency>
<groupId>
mysql
</groupId>
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
浏览文件 @
9aa83a97
...
...
@@ -4,11 +4,12 @@ import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
public
interface
DbEntityMapper
extends
BaseMapper
<
EntityObj
>{
List
<
EntityObj
>
search
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
EntityObj
>
wrapper
);
List
<
EntityObj
>
search
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
EntityObj
>
wrapper
);
Integer
searchCount
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
EntityObj
>
wrapper
);
}
\ No newline at end of file
ibzlite-core/src/main/java/cn/ibizlab/core/extensions/service/DstDataSourceExService.java
浏览文件 @
9aa83a97
...
...
@@ -45,6 +45,7 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
@Resource
public
DstLiquibaseService
dstLiquibaseService
;
/**
* [BuildDS:buildDS] 行为扩展
* @param dstDataSource
...
...
@@ -54,12 +55,15 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
@Transactional
public
DstDataSource
buildDS
(
DstDataSource
dstDataSource
)
{
if
(
!(
StringUtils
.
isEmpty
(
dstDataSource
.
getDsCfg
())))
if
(
dstDataSource
!=
null
&&(!
StringUtils
.
isEmpty
(
dstDataSource
.
getDsCfg
())))
{
synchronized
(
lock
)
{
if
(
check
.
containsKey
(
dstDataSource
.
getDsName
()))
return
super
.
buildDS
(
dstDataSource
);
if
(!
"mongodb"
.
equalsIgnoreCase
(
dstDataSource
.
getDsType
()))
{
DataSourceProperty
dataSourceProperty
=
new
DataSourceProperty
();
DynamicRoutingDataSource
ds
=
dataSource
;
List
<
Setting
>
settings
=
JSONArray
.
parseArray
(
dstDataSource
.
getDsCfg
(),
Setting
.
class
);
...
...
@@ -81,7 +85,9 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
DataSource
dataSource
=
druidDataSourceCreator
.
createDataSource
(
dataSourceProperty
);
ds
.
addDataSource
(
dstDataSource
.
getDsName
(),
dataSource
);
check
.
put
(
dstDataSource
.
getDsName
(),
1
);
}
check
.
put
(
dstDataSource
.
getDsName
(),
StringUtils
.
isEmpty
(
dstDataSource
.
getDsType
())?
"mysql"
:
dstDataSource
.
getDsType
());
}
}
...
...
@@ -97,25 +103,24 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
private
DataSourceCreator
druidDataSourceCreator
;
private
HashMap
<
String
,
Integer
>
check
=
new
HashMap
<>();
private
HashMap
<
String
,
String
>
check
=
new
HashMap
<>();
private
Object
lock
=
new
Object
();
public
void
initDataSource
(
String
dsName
)
public
synchronized
String
initDataSource
(
String
dsName
)
{
DstDataSource
dstDataSource
=
null
;
synchronized
(
lock
)
{
if
(
check
.
containsKey
(
dsName
))
return
;
return
check
.
get
(
dsName
);
dstDataSource
=
this
.
getOne
(
Wrappers
.<
DstDataSource
>
lambdaQuery
().
eq
(
DstDataSource:
:
getDsId
,
dsName
).
or
().
eq
(
DstDataSource:
:
getDsName
,
dsName
),
false
);
if
(
dstDataSource
!=
null
)
dstDataSource
.
setDsName
(
dsName
);
}
DstDataSource
dstDataSource
=
this
.
getOne
(
Wrappers
.<
DstDataSource
>
lambdaQuery
().
eq
(
DstDataSource:
:
getDsId
,
dsName
).
or
().
eq
(
DstDataSource:
:
getDsName
,
dsName
),
false
);
if
(
dstDataSource
!=
null
)
{
dstDataSource
.
setDsName
(
dsName
);
buildDS
(
dstDataSource
);
synchronized
(
lock
)
{
return
StringUtils
.
isEmpty
(
check
.
get
(
dsName
))?
"mysql"
:
check
.
get
(
dsName
);
}
}
@Override
...
...
@@ -127,11 +132,13 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
DynamicRoutingDataSource
ds
=
(
DynamicRoutingDataSource
)
dataSource
;
if
(
check
.
containsKey
(
et
.
getDsId
()))
{
if
(!
"mongodb"
.
equalsIgnoreCase
(
check
.
get
(
et
.
getDsId
())))
ds
.
removeDataSource
(
et
.
getDsId
());
check
.
remove
(
et
.
getDsId
());
}
if
(
check
.
containsKey
(
et
.
getDsName
()))
{
if
(!
"mongodb"
.
equalsIgnoreCase
(
check
.
get
(
et
.
getDsName
())))
ds
.
removeDataSource
(
et
.
getDsName
());
check
.
remove
(
et
.
getDsName
());
}
...
...
@@ -140,6 +147,7 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
return
true
;
}
@Override
@Transactional
public
DstDataSource
initDS
(
DstDataSource
et
)
{
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
浏览文件 @
9aa83a97
...
...
@@ -22,26 +22,38 @@ import java.util.Map;
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
EntityModel
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getEntityId
()
{
return
getEntity
().
getEntityId
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getCodeName
()
{
return
getEntity
().
getCodeName
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getEntityName
()
{
return
getEntity
().
getEntityName
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getTableName
()
{
return
getEntity
().
getTableName
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getLogicName
()
{
return
getEntity
().
getLogicName
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getSystemId
()
{
return
getEntity
().
getSystemId
();
}
...
...
@@ -192,18 +204,12 @@ public class EntityModel {
String
columnExp
=
fieldModel
.
getColumnExp
();
if
(
StringUtils
.
isEmpty
(
columnExp
))
continue
;
// if(fieldModel.isPhysicalField())
// continue;
if
(!
StringUtils
.
isEmpty
(
columnSet
)){
columnSet
=
columnSet
+
","
;
}
columnSet
=
columnSet
+
columnExp
;
}
// if(!StringUtils.isEmpty(columnSet)){
// columnSet=columnSet+",";
// }
//columnSet=columnSet+"t.*";
return
"select "
+
columnSet
+
" from "
+
this
.
getTableName
()+
" t "
;
}
else
if
(
"CORE"
.
equalsIgnoreCase
(
dataSet
))
...
...
@@ -219,6 +225,10 @@ public class EntityModel {
return
"select "
+
columnSet
+
" from "
+
this
.
getTableName
()+
" "
;
}
else
if
(
"COUNT"
.
equalsIgnoreCase
(
dataSet
))
{
return
"select count(1) from "
+
this
.
getTableName
()+
" "
;
}
else
{
if
(
dataSets
!=
null
)
...
...
@@ -229,6 +239,8 @@ public class EntityModel {
return
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDsName
()
{
String
dsName
=
this
.
getEntity
().
getDsId
();
...
...
@@ -242,18 +254,7 @@ public class EntityModel {
public
String
getExtParams
(
String
key
)
{
if
(!(
StringUtils
.
isEmpty
(
this
.
getEntity
().
getExtParams
())))
{
List
<
Setting
>
settings
=
JSONArray
.
parseArray
(
this
.
getEntity
().
getExtParams
(),
Setting
.
class
);
for
(
Setting
setting:
settings
)
{
if
(
key
.
equals
(
setting
.
getValue
()))
{
return
setting
.
getValue
();
}
}
}
return
null
;
return
Setting
.
getValue
(
this
.
getEntity
().
getExtParams
(),
key
);
}
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
浏览文件 @
9aa83a97
...
...
@@ -166,4 +166,13 @@ public class EntityObj extends DataObj<String,Object> {
});
}
}
public
boolean
isDelete
()
{
if
(!
this
.
getEntityModel
().
isLogicValid
())
return
false
;
if
(
this
.
getEntityModel
().
getLogicVal
().
equals
(
this
.
get
(
this
.
getEntityModel
().
getLogicValidField
().
getColumnName
())))
return
false
;
return
true
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
浏览文件 @
9aa83a97
...
...
@@ -3,12 +3,16 @@ package cn.ibizlab.core.lite.extensions.domain;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -269,4 +273,146 @@ public class ModelObj extends DataObj<String,Object> {
return
this
;
}
public
Object
$
(
String
key
)
{
if
(
key
.
toString
().
indexOf
(
"."
)>
0
)
{
String
[]
epair
=
key
.
toString
().
split
(
"[.]"
);
if
(
epair
.
length
>=
2
)
{
String
name
=
epair
[
0
];
String
column
=
epair
[
1
];
Property
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"UP"
);
if
(
property
!=
null
)
return
this
.
getEntity
(
name
).
get
(
column
);
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"DOWN"
);
if
(
property
!=
null
)
{
return
this
.
getNested
(
property
.
getOwnerDataModel
().
getDataModelName
()).
get
(
key
);
}
if
(
this
.
getParent
()!=
null
)
return
this
.
getParent
().
$
(
key
);
}
}
return
get
(
key
);
}
public
Double
$D
(
String
key
)
{
Object
val
=
this
.
get
(
key
);
if
(
val
==
null
)
return
0
d
;
else
if
((
val
instanceof
Integer
)||(
val
instanceof
Double
)||(
val
instanceof
Long
)||(
val
instanceof
BigDecimal
)||(
val
instanceof
BigInteger
)||(
val
instanceof
Float
))
return
(
double
)
val
;
return
1
d
;
}
public
boolean
IF
(
String
cond
)
{
String
[]
arr
=
cond
.
split
(
"\\s+"
);
String
option
=
""
;
String
members
=
""
;
String
exp
=
""
;
if
(
arr
.
length
>=
2
)
{
members
=
arr
[
0
];
option
=
arr
[
1
];
}
Object
val
=
null
;
String
[]
ms
=
members
.
split
(
"[.]"
);
if
(
ms
.
length
>=
2
&&(!
StringUtils
.
isEmpty
(
ms
[
0
])))
{
EntityObj
sub
=
this
.
getEntity
(
ms
[
0
]);
if
(
sub
.
isDelete
())
return
false
;
if
(
sub
!=
null
)
{
val
=
sub
.
get
(
ms
[
1
]);
}
}
if
(
arr
.
length
>=
3
)
{
exp
=
arr
[
2
];
if
(
exp
.
startsWith
(
"%"
))
{
return
RuleUtils
.
test
(
val
,
option
,
execFunc
(
exp
));
}
}
return
RuleUtils
.
test
(
val
,
option
,
exp
);
}
private
Object
execFunc
(
String
exp
)
{
exp
=
exp
.
replace
(
"%"
,
""
).
trim
();
if
(
exp
.
startsWith
(
"DAY("
))
{
Calendar
calendar
=
Calendar
.
getInstance
();
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
int
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
exp
.
endsWith
(
")"
))
{
String
quStr
=
exp
.
substring
(
exp
.
indexOf
(
"("
)+
1
,
exp
.
indexOf
(
")"
));
exp
=
exp
.
substring
(
0
,
exp
.
indexOf
(
"("
)).
trim
();
quStr
=
quStr
.
replace
(
"+"
,
""
).
trim
();
Integer
day
=
0
;
if
(!
StringUtils
.
isEmpty
(
quStr
)){
day
=
Integer
.
parseInt
(
quStr
);
}
Object
val
=
this
.
get
(
exp
);
if
(
val
!=
null
)
{
if
(
val
instanceof
Timestamp
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
((
Timestamp
)
val
);
calendar
.
add
(
Calendar
.
DATE
,
day
);
return
new
Timestamp
(
calendar
.
getTime
().
getTime
());
}
else
if
(
val
instanceof
Integer
)
{
return
(
int
)
val
+
day
;
}
else
if
(
val
instanceof
BigDecimal
)
{
return
((
BigDecimal
)
val
).
intValue
()+
day
;
}
}
return
val
;
}
return
null
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
浏览文件 @
9aa83a97
...
...
@@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
public
class
NestedArray
extends
ArrayList
<
ModelObj
>
{
...
...
@@ -64,4 +66,52 @@ public class NestedArray extends ArrayList<ModelObj> {
return
last
;
}
public
List
<
Object
>
get
(
String
key
)
{
List
<
Object
>
list
=
new
ArrayList
<>();
if
(
key
==
null
)
return
null
;
if
(
key
.
indexOf
(
"."
)>
0
)
{
String
[]
epair
=
key
.
toString
().
split
(
"[.]"
);
if
(
epair
.
length
>=
2
)
{
String
name
=
epair
[
0
];
String
column
=
epair
[
1
];
this
.
forEach
(
modelObj
->
{
Object
obj
=
modelObj
.
getEntity
(
name
).
get
(
column
);
list
.
add
(
obj
);
});
}
}
return
list
;
}
public
List
<
Object
>
get
(
String
key
,
String
cond
)
{
List
<
Object
>
list
=
new
ArrayList
<>();
if
(
key
==
null
)
return
null
;
if
(
key
.
indexOf
(
"."
)>
0
)
{
String
[]
epair
=
key
.
toString
().
split
(
"[.]"
);
if
(
epair
.
length
>=
2
)
{
String
name
=
epair
[
0
];
String
column
=
epair
[
1
];
this
.
forEach
(
modelObj
->
{
if
(
modelObj
.
IF
(
cond
))
{
Object
obj
=
modelObj
.
getEntity
(
name
).
get
(
column
);
list
.
add
(
obj
);
}
});
}
}
return
list
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/Setting.java
浏览文件 @
9aa83a97
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
com.alibaba.fastjson.JSONArray
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
@Getter
@Setter
...
...
@@ -12,4 +16,21 @@ import lombok.experimental.Accessors;
public
class
Setting
{
private
String
property
;
private
String
value
;
public
static
String
getValue
(
String
configString
,
String
propertyName
)
{
if
(!(
StringUtils
.
isEmpty
(
configString
)))
{
List
<
Setting
>
settings
=
JSONArray
.
parseArray
(
configString
,
Setting
.
class
);
for
(
Setting
setting:
settings
)
{
if
(
propertyName
.
equals
(
setting
.
getProperty
()))
{
return
setting
.
getValue
();
}
}
}
return
""
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/DataModel.java
浏览文件 @
9aa83a97
...
...
@@ -2,6 +2,8 @@ package cn.ibizlab.core.lite.extensions.model;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Getter
;
...
...
@@ -20,6 +22,27 @@ import java.util.List;
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
DataModel
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
String
modelString
;
public
String
getModelString
()
{
if
(
StringUtils
.
isEmpty
(
modelString
))
{
modelString
=
JSONObject
.
toJSONString
(
this
);
}
return
modelString
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
clone
()
{
DataModel
clone
=
JSON
.
toJavaObject
(
JSONObject
.
parseObject
(
this
.
getModelString
()),
DataModel
.
class
);
clone
.
setModelString
(
this
.
getModelString
());
return
clone
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
...
...
@@ -138,9 +161,6 @@ public class DataModel {
for
(
Property
property:
this
.
getObjectProperties
())
if
(
name
.
equalsIgnoreCase
(
property
.
getPropertyName
()))
return
property
;
for
(
Property
property:
this
.
getObjectProperties
())
if
(
name
.
equalsIgnoreCase
(
property
.
getPropertyEntity
()))
return
property
;
}
return
null
;
}
...
...
@@ -336,7 +356,8 @@ public class DataModel {
@JSONField
(
serialize
=
false
)
public
LinkedHashSet
<
Property
>
getAllProperty
()
{
LinkedHashSet
<
Property
>
properties
=
this
.
getObjectProperties
();
LinkedHashSet
<
Property
>
properties
=
new
LinkedHashSet
<>();
properties
.
addAll
(
this
.
getObjectProperties
());
if
(
this
.
getNestedDataModels
()
!=
null
)
{
for
(
DataModel
dm
:
this
.
getNestedDataModels
())
{
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/CommonEntityService.java
浏览文件 @
9aa83a97
...
...
@@ -2,7 +2,7 @@ package cn.ibizlab.core.lite.extensions.service;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.core.lite.extensions.
domain.ModelObj
;
import
cn.ibizlab.core.lite.extensions.
model.DataModel
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
java.sql.Timestamp
;
...
...
@@ -12,15 +12,14 @@ public interface CommonEntityService {
List
<
EntityObj
>
selectBase
(
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
selectCore
(
EntityModel
entityModel
,
QueryFilter
filter
);
Integer
selectCount
(
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
);
List
<
ModelObj
>
getModelObjs
(
String
metaModelId
,
Timestamp
lastModify
);
ModelObj
getModelObjs
(
String
metaModelId
,
Object
factKey
);
ModelObj
getModelObjs
(
String
metaModelId
,
Object
...
factUniKey
);
List
<
ModelObj
>
getModelObjs
(
String
metaModelId
,
List
<
EntityObj
>
kEntityObjs
);
void
processList
(
DataModel
dataModel
,
Timestamp
lastModify
,
LiteDataCallback
callback
);
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
9aa83a97
此差异已折叠。
点击以展开。
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteDataCallback.java
0 → 100644
浏览文件 @
9aa83a97
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
service
;
public
interface
LiteDataCallback
<
K
>
{
void
total
(
Integer
total
);
boolean
processData
(
K
k
);
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteDataService.java
0 → 100644
浏览文件 @
9aa83a97
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
service
;
import
cn.ibizlab.core.extensions.service.DstDataSourceExService
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.core.lite.extensions.domain.FieldModel
;
import
cn.ibizlab.core.lite.extensions.domain.ModelObj
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.core.lite.service.IMetaModelService
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.util.*
;
@Slf4j
@Service
public
class
LiteDataService
{
@Autowired
private
DbEntityService
dbEntityService
;
@Autowired
private
MongoEntityService
mongoEntityService
;
@Autowired
private
IMetaModelService
metaModelService
;
@Autowired
@Lazy
private
SqlSessionFactory
sqlSessionFactory
;
@Autowired
private
DstDataSourceExService
dstDataSourceService
;
@Autowired
private
LiteModelService
liteModelService
;
public
CommonEntityService
getEntityService
(
String
dsId
)
{
String
dsType
=
dstDataSourceService
.
initDataSource
(
dsId
);
if
(
"mongodb"
.
equalsIgnoreCase
(
dsType
))
return
mongoEntityService
;
else
return
dbEntityService
;
}
public
void
processDataModel
(
String
metaModelId
,
Timestamp
lastModify
,
LiteDataCallback
callback
)
{
DataModel
dataModel
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
metaModelService
.
get
(
metaModelId
).
getConfig
()),
DataModel
.
class
);
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
getEntityService
(
entityModel
.
getDsName
()).
processList
(
dataModel
,
lastModify
,
callback
);
}
public
ModelObj
getModelObjs
(
String
metaModelId
,
Set
<
String
>
fillPropertys
,
Object
factKey
)
{
DataModel
dataModel
=
liteModelService
.
getDataModel
(
metaModelId
);
List
<
EntityObj
>
kEntityObjs
=
new
ArrayList
<>();
kEntityObjs
.
add
(
new
EntityObj
().
set
(
dataModel
.
getFactEntityModel
().
getKeyField
().
getColumnName
(),
factKey
));
List
<
ModelObj
>
list
=
getModelObjs
(
dataModel
,
fillPropertys
,
kEntityObjs
);
if
(
list
.
size
()
>
0
)
return
list
.
get
(
0
);
return
null
;
}
public
ModelObj
getModelObjs
(
String
metaModelId
,
Set
<
String
>
fillPropertys
,
Object
...
factUniKey
)
{
DataModel
dataModel
=
liteModelService
.
getDataModel
(
metaModelId
);
List
<
EntityObj
>
kEntityObjs
=
new
ArrayList
<>();
EntityObj
entityObj
=
new
EntityObj
();
List
<
FieldModel
>
uniKeys
=
dataModel
.
getFactEntityModel
().
getUnionKeyFields
();
for
(
int
i
=
0
;
i
<
uniKeys
.
size
();
i
++)
entityObj
.
set
(
uniKeys
.
get
(
i
).
getColumnName
(),
factUniKey
[
i
]);
kEntityObjs
.
add
(
entityObj
);
List
<
ModelObj
>
list
=
getModelObjs
(
dataModel
,
fillPropertys
,
kEntityObjs
);
if
(
list
.
size
()
>
0
)
return
list
.
get
(
0
);
return
null
;
}
public
List
<
ModelObj
>
getModelObjs
(
String
metaModelId
,
Set
<
String
>
fillPropertys
,
List
<
EntityObj
>
kEntityObjs
)
{
DataModel
dataModel
=
liteModelService
.
getDataModel
(
metaModelId
);
return
getModelObjs
(
dataModel
,
fillPropertys
,
kEntityObjs
);
}
public
List
<
ModelObj
>
getModelObjs
(
DataModel
dataModel
,
Set
<
String
>
fillPropertys
,
List
<
EntityObj
>
kEntityObjs
)
{
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
List
<
ModelObj
>
rt
=
new
ArrayList
<>();
List
<
EntityObj
>
factEntityList
=
new
ArrayList
<>();
if
(
fillPropertys
==
null
||
fillPropertys
.
size
()
==
0
||
fillPropertys
.
contains
(
dataModel
.
getFactPorperty
().
getPropertyName
()))
splitList
(
kEntityObjs
,
1000
).
forEach
(
list
->
factEntityList
.
addAll
(
getEntityService
(
entityModel
.
getDsName
()).
selectBase
(
entityModel
,
QueryFilter
.
createQuery
().
cust
(
dataModel
.
lookup
(
list
)))));
factEntityList
.
forEach
(
entityObj
->
rt
.
add
(
new
ModelObj
().
setDataModel
(
dataModel
).
setFactEntity
(
entityObj
.
setProperty
(
dataModel
.
getFactPorperty
()))));
fillEntityObj
(
dataModel
,
fillPropertys
,
rt
);
dataModel
.
getNestedDataModels
().
forEach
(
subModel
->
this
.
getModelObjs
(
subModel
,
fillPropertys
,
factEntityList
).
forEach
(
subObj
->
subObj
.
findParent
(
rt
)));
rt
.
forEach
(
modelObj
->
modelObj
.
getTimestamp
());
return
rt
;
}
public
void
fillEntityObj
(
DataModel
dataModel
,
Set
<
String
>
fillPropertys
,
List
<
ModelObj
>
modelObjs
)
{
if
(
dataModel
.
getObjectProperties
().
size
()
>
1
)
{
for
(
Property
property
:
dataModel
.
getObjectProperties
())
{
if
(
property
.
getPropertyName
().
equals
(
dataModel
.
getFactPorperty
().
getPropertyName
()))
continue
;
EntityModel
entityModel
=
property
.
getEntityModel
();
List
<
EntityObj
>
entityObjs
=
new
ArrayList
<>();
if
(
fillPropertys
==
null
||
fillPropertys
.
size
()
==
0
||
fillPropertys
.
contains
(
property
.
getPropertyName
()))
splitList
(
modelObjs
,
1000
).
forEach
(
list
->
entityObjs
.
addAll
(
getEntityService
(
entityModel
.
getDsName
()).
selectBase
(
entityModel
,
QueryFilter
.
createQuery
().
cust
(
property
.
lookup
(
list
)))));
entityObjs
.
forEach
(
entityObj
->
{
entityObj
.
setProperty
(
property
);
entityObj
.
findModel
(
modelObjs
);
});
}
}
}
private
<
T
>
List
<
List
<
T
>>
splitList
(
List
<
T
>
list
,
int
groupSize
)
{
int
length
=
list
.
size
();
// 计算可以分成多少组
int
num
=
(
length
+
groupSize
-
1
)
/
groupSize
;
// TODO
List
<
List
<
T
>>
newList
=
new
ArrayList
<>(
num
);
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
// 开始位置
int
fromIndex
=
i
*
groupSize
;
// 结束位置
int
toIndex
=
(
i
+
1
)
*
groupSize
<
length
?
(
i
+
1
)
*
groupSize
:
length
;
newList
.
add
(
list
.
subList
(
fromIndex
,
toIndex
));
}
return
newList
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteModelService.java
浏览文件 @
9aa83a97
...
...
@@ -177,7 +177,10 @@ public class LiteModelService {
public
DataModel
getDataModel
(
String
dataModelId
)
{
return
JSON
.
toJavaObject
(
JSON
.
parseObject
(
metaModelService
.
get
(
dataModelId
).
getConfig
()),
DataModel
.
class
);
String
cfg
=
metaModelService
.
get
(
dataModelId
).
getConfig
();
DataModel
dataModel
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
metaModelService
.
get
(
dataModelId
).
getConfig
()),
DataModel
.
class
);
dataModel
.
setModelString
(
cfg
);
return
dataModel
;
}
public
DataModel
getDataModel
(
String
rootDataModelId
,
String
subDataModelName
)
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/MongoEntityService.java
浏览文件 @
9aa83a97
...
...
@@ -2,12 +2,13 @@ package cn.ibizlab.core.lite.extensions.service;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.core.lite.extensions.
domain.ModelObj
;
import
cn.ibizlab.core.lite.extensions.
model.DataModel
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.Set
;
@Service
public
class
MongoEntityService
implements
CommonEntityService
{
...
...
@@ -23,32 +24,25 @@ public class MongoEntityService implements CommonEntityService{
}
@Override
public
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
)
{
public
Integer
selectCount
(
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
List
<
ModelObj
>
getModelObjs
(
String
metaModelId
,
Timestamp
lastModify
)
{
public
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
ModelObj
getModelObjs
(
String
metaModelId
,
Object
factKey
)
{
public
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
ModelObj
getModelObjs
(
String
metaModelId
,
Object
...
factUniKey
)
{
return
null
;
}
@Override
public
List
<
ModelObj
>
getModelObjs
(
String
metaModelId
,
List
<
EntityObj
>
kEntityObjs
)
{
return
null
;
public
void
processList
(
DataModel
dataModel
,
Timestamp
lastModify
,
LiteDataCallback
callback
)
{
}
}
ibzlite-core/src/main/resources/mapper/lite/dbentity/DbEntityMapper.xml
浏览文件 @
9aa83a97
...
...
@@ -8,5 +8,12 @@
<where><if
test=
"ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere"
>
${ew.sqlSegment}
</if></where>
<if
test=
"ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"
>
${ew.sqlSegment}
</if>
</select>
<select
id=
"searchCount"
parameterType=
"cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext"
resultType=
"Integer"
>
${sql}
<where><if
test=
"ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere"
>
${ew.sqlSegment}
</if></where>
<if
test=
"ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"
>
${ew.sqlSegment}
</if>
</select>
</mapper>
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
浏览文件 @
9aa83a97
...
...
@@ -9,6 +9,7 @@ import cn.ibizlab.core.lite.extensions.model.DataModel;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.core.lite.extensions.service.DbEntityService
;
import
cn.ibizlab.core.lite.extensions.service.LiteCoreService
;
import
cn.ibizlab.core.lite.extensions.service.LiteDataService
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.service.IDstComponentService
;
import
cn.ibizlab.core.lite.service.IDstConfigService
;
...
...
@@ -55,17 +56,19 @@ public class LiteCoreResource {
@Lazy
LiteCoreService
liteCoreService
;
@Autowired
private
LiteDataService
liteDataService
;
@Autowired
private
DbEntityService
dbEntityService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/
lite/test/{modelid
}"
)
public
ResponseEntity
<
List
<
ModelObj
>>
getstr
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/
dst/test/{modelid}/data/{key
}"
)
public
ResponseEntity
<
ModelObj
>
getstr
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
)
{
if
(
StringUtils
.
isEmpty
(
modelid
))
modelid
=
"dataModelff8080816a8b510c016a8c2f18b10001"
;
List
<
ModelObj
>
list
=
dbEntityService
.
getModelObjs
(
modelid
,
DataObject
.
getBeginDate
());
return
ResponseEntity
.
ok
(
list
);
return
ResponseEntity
.
ok
(
liteDataService
.
getModelObjs
(
modelid
,
null
,
key
));
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录