Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
219aade2
提交
219aade2
编写于
11月 19, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model
上级
1f452fbb
变更
13
显示空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
720 行增加
和
6 行删除
+720
-6
DbEntityMapper.java
...ava/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
+17
-0
DataObj.java
.../java/cn/ibizlab/core/lite/extensions/domain/DataObj.java
+203
-0
EntityModel.java
...a/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
+57
-0
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+98
-0
FieldModel.java
...va/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
+18
-0
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+55
-0
DbEntitySearchContext.java
...ab/core/lite/extensions/filter/DbEntitySearchContext.java
+22
-0
DataModel.java
...java/cn/ibizlab/core/lite/extensions/model/DataModel.java
+105
-6
Property.java
.../java/cn/ibizlab/core/lite/extensions/model/Property.java
+28
-0
CommonEntityService.java
...lab/core/lite/extensions/service/CommonEntityService.java
+18
-0
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+62
-0
MongoEntityService.java
...zlab/core/lite/extensions/service/MongoEntityService.java
+32
-0
LiteStorage.java
...ava/cn/ibizlab/core/lite/extensions/util/LiteStorage.java
+5
-0
未找到文件。
ibzlite-core/src/main/java/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
0 → 100644
浏览文件 @
219aade2
package
cn
.
ibizlab
.
core
.
extensions
.
mapper
;
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
>{
@Select
(
"${sql} \n"
+
"<where><if test=\"ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere\">${ew.sqlSegment}</if></where> \n"
+
"<if test=\"ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere\">${ew.sqlSegment}</if> "
)
List
<
EntityObj
>
search
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
EntityObj
>
wrapper
);
}
\ No newline at end of file
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/DataObj.java
0 → 100644
浏览文件 @
219aade2
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.util.domain.DTOBase
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.ObjectUtils
;
import
java.math.BigDecimal
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
DataObj
<
K
,
V
>
extends
ConcurrentHashMap
<
K
,
V
>
{
public
String
getRowKey
()
{
return
this
.
getStringValue
(
"ROWKEY"
,
""
);
}
public
<
T
>
T
setRowKey
(
String
rowKey
)
{
return
this
.
set
(
"ROWKEY"
,(
V
)
rowKey
);
}
public
Timestamp
getTimestamp
()
{
return
getTimestampBegin
(
"TIMESTAMP"
);
}
public
<
T
>
T
setTimestamp
(
Timestamp
timestamp
)
{
return
this
.
set
(
"TIMESTAMP"
,(
V
)
DataObject
.
getTimestampValue
(
timestamp
,
DataObject
.
getBeginDate
()));
}
public
<
T
>
T
set
(
String
key
,
V
value
)
{
return
(
T
)
this
.
put
((
K
)
key
.
toUpperCase
(),
value
);
}
@Override
public
V
get
(
Object
key
)
{
if
(
key
==
null
)
return
null
;
V
objValue
=
super
.
get
(
key
);
if
(
objValue
==
null
)
objValue
=
super
.
get
(
key
.
toString
().
toUpperCase
());
if
(
objValue
==
null
)
objValue
=
super
.
get
(
key
.
toString
().
toLowerCase
());
return
objValue
;
}
public
JSONObject
getJSONObjectValue
(
String
strParamName
)
{
return
getJSONObjectValue
(
strParamName
,
new
JSONObject
());
}
public
JSONObject
getJSONObjectValue
(
String
strParamName
,
JSONObject
jDefault
)
{
return
DataObject
.
getJSONObjectValue
(
this
.
get
(
strParamName
),
jDefault
);
}
public
List
<
String
>
getListValue
(
String
strParamName
)
{
return
DataObject
.
getListValue
(
strParamName
);
}
public
JSONArray
getJSONArrayValue
(
String
strParamName
)
{
return
getJSONArrayValue
(
strParamName
,
new
JSONArray
());
}
public
JSONArray
getJSONArrayValue
(
String
strParamName
,
JSONArray
jDefault
)
{
return
DataObject
.
getJSONArrayValue
(
this
.
get
(
strParamName
),
jDefault
);
}
public
Integer
getIntegerValue
(
String
objValue
)
{
return
getIntegerValue
(
objValue
,
Integer
.
MIN_VALUE
);
}
public
int
getIntegerValue
(
String
strParamName
,
int
nDefault
)
{
return
DataObject
.
getIntegerValue
(
this
.
get
(
strParamName
),
nDefault
);
}
public
Float
getFloatValue
(
String
objValue
)
{
return
this
.
getFloatValue
(
objValue
,-
9999
f
);
}
public
Float
getFloatValue
(
String
strParamName
,
float
fDefault
)
{
return
DataObject
.
getFloatValue
(
this
.
get
(
strParamName
),
fDefault
);
}
public
BigDecimal
getBigDecimalValue
(
String
objValue
)
{
return
this
.
getBigDecimalValue
(
objValue
,
BigDecimal
.
valueOf
(-
9999
));
}
public
BigDecimal
getBigDecimalValue
(
String
strParamName
,
BigDecimal
fDefault
)
{
return
DataObject
.
getBigDecimalValue
(
this
.
get
(
strParamName
),
fDefault
);
}
public
Long
getLongValue
(
String
strParamName
)
{
return
this
.
getLongValue
(
strParamName
,
Long
.
MIN_VALUE
);
}
public
Long
getLongValue
(
String
strParamName
,
long
nDefault
)
{
return
DataObject
.
getLongValue
(
this
.
get
(
strParamName
),
nDefault
);
}
public
String
getStringValue
(
String
objValue
)
{
return
getStringValue
(
objValue
,
""
);
}
public
String
getStringValue
(
String
strParamName
,
String
strDefault
)
{
return
DataObject
.
getStringValue
(
this
.
get
(
strParamName
),
strDefault
);
}
public
byte
[]
getBinaryValue
(
String
objValue
)
{
return
getBinaryValue
(
objValue
,
null
);
}
public
byte
[]
getBinaryValue
(
String
strParamName
,
byte
[]
def
)
{
return
DataObject
.
getBinaryValue
(
this
.
get
(
strParamName
),
def
);
}
public
Timestamp
getTimestampBegin
(
String
strParamName
)
{
return
getTimestampValue
(
strParamName
,
DataObject
.
getBeginDate
());
}
public
Timestamp
getTimestampEnd
(
String
strParamName
)
{
Object
objValue
=
this
.
get
(
strParamName
);
if
(
objValue
==
null
)
{
return
DataObject
.
getEndDate
();
}
try
{
Timestamp
t
=
DataObject
.
getTimestampValue
(
objValue
,
DataObject
.
getEndDate
());
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
time
=
df
.
format
(
t
);
Calendar
cl
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"GMT+8"
));
cl
.
setTime
(
Timestamp
.
valueOf
(
time
+
" 23:59:59"
));
return
new
Timestamp
(
cl
.
getTime
().
getTime
());
}
catch
(
Exception
ex
)
{
return
DataObject
.
getEndDate
();
}
}
public
Timestamp
getTimestampValue
(
String
strParamName
,
Timestamp
dtDefault
)
{
Object
objValue
=
this
.
get
(
strParamName
);
if
(
objValue
==
null
||
objValue
.
equals
(
""
))
{
return
dtDefault
;
}
try
{
return
DataObject
.
getTimestampValue
(
objValue
,
null
);
}
catch
(
Exception
ex
)
{
return
dtDefault
;
}
}
public
<
T
>
T
copyTo
(
T
targetEntity
,
boolean
bIncEmpty
){
if
(
targetEntity
instanceof
EntityBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
EntityBase
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
DTOBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
DTOBase
)
targetEntity
).
set
(((
String
)
field
).
toLowerCase
(),
value
);
}
}
}
else
if
(
targetEntity
instanceof
DataObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
DataObj
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
Map
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
Map
)
targetEntity
).
put
(
field
,
value
);
}
}
}
return
targetEntity
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
浏览文件 @
219aade2
...
...
@@ -91,5 +91,62 @@ public class EntityModel {
}
public
String
getSqlSegment
(
String
dataSet
)
{
if
(
"BASE"
.
equalsIgnoreCase
(
dataSet
))
{
String
columnSet
=
""
;
for
(
FieldModel
fieldModel:
fields
)
{
String
columnExp
=
fieldModel
.
getColumnExp
();
if
(
StringUtils
.
isEmpty
(
columnExp
))
continue
;
if
(!
StringUtils
.
isEmpty
(
columnSet
)){
columnSet
=
columnSet
+
","
;
}
columnSet
=
columnSet
+
columnExp
;
}
return
"select "
+
columnSet
+
" from "
+
this
.
getTableName
()+
" "
;
}
else
if
(
"CORE"
.
equalsIgnoreCase
(
dataSet
))
{
String
columnSet
=
""
;
for
(
FieldModel
fieldModel:
fields
)
{
if
(
StringUtils
.
isEmpty
(
fieldModel
.
getField
().
getUnionKey
())&&
1
!=
fieldModel
.
getField
().
getKeyField
())
continue
;
String
columnExp
=
fieldModel
.
getColumnExp
();
if
(
StringUtils
.
isEmpty
(
columnExp
))
continue
;
if
(!
StringUtils
.
isEmpty
(
columnSet
)){
columnSet
=
columnSet
+
","
;
}
columnSet
=
columnSet
+
columnExp
;
}
return
"select "
+
columnSet
+
" from "
+
this
.
getTableName
()+
" "
;
}
else
{
if
(
dataSets
!=
null
)
for
(
MetaDataSet
metaDataSet:
dataSets
)
if
(
metaDataSet
.
getCodeName
().
equalsIgnoreCase
(
dataSet
)&&(!
StringUtils
.
isEmpty
(
metaDataSet
.
getDsCode
())))
return
"select t1.* from ("
+
metaDataSet
.
getDsCode
()+
") t1"
;
}
return
""
;
}
public
String
getDsName
()
{
String
dsName
=
this
.
getEntity
().
getDsName
();
if
(
StringUtils
.
isEmpty
(
dsName
))
{
dsName
=
this
.
getSystemId
()+
"-master"
;
}
return
dsName
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
0 → 100644
浏览文件 @
219aade2
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.core.lite.extensions.util.LiteStorage
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.util.StringUtils
;
public
class
EntityObj
extends
DataObj
<
String
,
Object
>
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
EntityModel
entityModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityModel
getEntityModel
()
{
if
(
entityModel
==
null
)
entityModel
=
LiteStorage
.
getLiteModelService
().
getEntityModel
(
this
.
getDstSystemId
(),
this
.
getMetaEntityName
());
return
entityModel
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
getDataModel
()
{
if
(
this
.
dataModel
==
null
&&
this
.
getProperty
()!=
null
)
this
.
dataModel
=
this
.
getProperty
().
getOwnerDataModel
();
return
dataModel
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
setDataModel
(
DataModel
dataModel
)
{
this
.
dataModel
=
dataModel
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Property
property
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Property
getProperty
()
{
return
property
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
setProperty
(
Property
property
)
{
if
(
property
!=
null
)
{
if
(!
StringUtils
.
isEmpty
(
property
.
getSystem
()))
this
.
setDstSystemId
(
property
.
getSystem
());
if
(!
StringUtils
.
isEmpty
(
property
.
getPropertyEntity
()))
this
.
setMetaEntityName
(
property
.
getPropertyEntity
());
}
this
.
property
=
property
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getMetaEntityName
()
{
return
this
.
getStringValue
(
"METAENTITYNAME"
,
""
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
setMetaEntityName
(
String
metaEntityName
)
{
return
this
.
set
(
"METAENTITYNAME"
,
metaEntityName
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDstSystemId
()
{
return
this
.
getStringValue
(
"DSTSYSTEMID"
,
""
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
setDstSystemId
(
String
dstSystemId
)
{
return
this
.
set
(
"DSTSYSTEMID"
,
dstSystemId
);
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
浏览文件 @
219aade2
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.springframework.util.StringUtils
;
@Getter
@Setter
...
...
@@ -25,4 +28,19 @@ public class FieldModel {
private
MetaField
field
;
private
RelationshipModel
reference
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getColumnExp
()
{
if
(
1
==
field
.
getPhysicalField
())
{
return
columnName
+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
}
else
if
(!
StringUtils
.
isEmpty
(
field
.
getExpression
()))
{
return
field
.
getExpression
()+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
}
return
""
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
0 → 100644
浏览文件 @
219aade2
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.core.lite.extensions.util.LiteStorage
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ModelObj
extends
DataObj
<
String
,
Object
>
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
getDataModel
()
{
return
dataModel
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
void
setDataModel
(
DataModel
dataModel
)
{
this
.
dataModel
=
dataModel
;
}
public
EntityObj
getEntity
(
String
name
)
{
Property
property
=
this
.
getDataModel
().
getObjectProperty
(
name
);
Object
obj
=
this
.
get
(
name
);
if
(
obj
!=
null
&&
obj
instanceof
EntityObj
)
return
(
EntityObj
)
obj
;
else
if
(
property
==
null
)
return
new
EntityObj
().
setDataModel
(
this
.
getDataModel
()).
setProperty
(
property
).
setRowKey
(
this
.
getRowKey
());
else
return
new
EntityObj
().
setDataModel
(
this
.
getDataModel
()).
setDstSystemId
(
this
.
getDataModel
().
getFactPorperty
().
getSystem
()).
setMetaEntityName
(
name
).
setRowKey
(
this
.
getRowKey
());
}
public
List
<
ModelObj
>
getNested
(
String
name
)
{
Object
list
=
this
.
get
(
name
);
if
(
list
!=
null
&&
list
instanceof
List
)
return
(
List
<
ModelObj
>)
list
;
else
return
new
ArrayList
<>();
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/filter/DbEntitySearchContext.java
0 → 100644
浏览文件 @
219aade2
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
filter
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.util.filter.QueryWrapperContext
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
/**
* 关系型数据实体[MetaEntity] 查询条件对象
*/
@Slf4j
@Data
public
class
DbEntitySearchContext
extends
QueryWrapperContext
<
EntityObj
>
{
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/DataModel.java
浏览文件 @
219aade2
...
...
@@ -23,6 +23,38 @@ public class DataModel {
@JSONField
(
serialize
=
false
)
private
DataModel
parentDataModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
getRootDataModel
()
{
if
(
this
.
getParentDataModel
()==
null
)
return
this
;
else
return
this
.
getParentDataModel
().
getRootDataModel
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
int
getLayerNo
()
{
int
layerNo
=
1
;
DataModel
parent
=
this
.
getParentDataModel
();
while
(
parent
!=
null
)
{
layerNo
++;
parent
=
parent
.
getParentDataModel
();
}
return
layerNo
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Property
getRootFactPorperty
()
{
return
this
.
getRootFactPorperty
().
getFactPorperty
();
}
@JSONField
(
ordinal
=
1
)
private
String
dataModelName
;
public
String
getDataModelName
()
...
...
@@ -75,25 +107,92 @@ public class DataModel {
return
null
;
}
public
Property
getObjectProperty
(
String
propertyN
ame
)
public
Property
getObjectProperty
(
String
n
ame
)
{
if
(
this
.
getObjectProperties
()!=
null
&&(!
StringUtils
.
isEmpty
(
propertyN
ame
)))
if
(
this
.
getObjectProperties
()!=
null
&&(!
StringUtils
.
isEmpty
(
n
ame
)))
{
for
(
Property
property:
this
.
getObjectProperties
())
if
(
propertyName
.
equalsIgnoreCase
(
property
.
getPropertyName
()))
if
(
name
.
equalsIgnoreCase
(
property
.
getPropertyName
()))
return
property
;
for
(
Property
property:
this
.
getObjectProperties
())
if
(
name
.
equalsIgnoreCase
(
property
.
getPropertyEntity
()))
return
property
;
}
return
null
;
}
public
DataModel
getNestedDataModel
(
String
dataModelName
)
public
Property
findObjectProperty
(
String
name
)
{
Property
rt
=
this
.
getObjectProperty
(
name
);
if
(
rt
!=
null
)
return
rt
;
if
(
this
.
getNestedDataModels
()!=
null
)
{
for
(
DataModel
dm:
this
.
getNestedDataModels
())
{
rt
=
dm
.
findObjectProperty
(
name
);
if
(
rt
!=
null
)
return
rt
;
}
}
DataModel
parent
=
this
.
getParentDataModel
();
while
(
parent
!=
null
)
{
rt
=
parent
.
getObjectProperty
(
name
);
if
(
rt
!=
null
)
return
rt
;
else
parent
=
parent
.
getParentDataModel
();
}
return
null
;
}
public
DataModel
getNestedDataModel
(
String
name
)
{
if
(
this
.
getNestedDataModels
()!=
null
&&(!
StringUtils
.
isEmpty
(
dataModelN
ame
)))
if
(
this
.
getNestedDataModels
()!=
null
&&(!
StringUtils
.
isEmpty
(
n
ame
)))
{
for
(
DataModel
dataModel:
this
.
getNestedDataModels
())
if
(
dataModelN
ame
.
equalsIgnoreCase
(
dataModel
.
getDataModelName
()))
if
(
n
ame
.
equalsIgnoreCase
(
dataModel
.
getDataModelName
()))
return
dataModel
;
for
(
DataModel
dataModel:
this
.
getNestedDataModels
())
if
(
dataModel
.
getObjectProperty
(
name
)!=
null
)
return
dataModel
;
}
return
null
;
}
public
DataModel
findDataModel
(
String
name
)
{
if
(
name
.
equalsIgnoreCase
(
this
.
getDataModelName
()))
return
this
;
DataModel
rt
=
this
.
getNestedDataModel
(
name
);
if
(
rt
!=
null
)
return
rt
;
if
(
this
.
getNestedDataModels
()!=
null
)
{
for
(
DataModel
dm:
this
.
getNestedDataModels
())
{
rt
=
dm
.
getNestedDataModel
(
name
);
if
(
rt
!=
null
)
return
rt
;
}
}
if
(
this
.
getObjectProperty
(
name
)!=
null
)
return
this
;
DataModel
parent
=
this
.
getParentDataModel
();
while
(
parent
!=
null
)
{
if
(
name
.
equalsIgnoreCase
(
parent
.
getDataModelName
()))
rt
=
parent
;
if
(
rt
==
null
&&
parent
.
getObjectProperty
(
name
)!=
null
)
rt
=
parent
;
if
(
rt
!=
null
)
return
rt
;
else
parent
=
parent
.
getParentDataModel
();
}
return
null
;
}
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/Property.java
浏览文件 @
219aade2
...
...
@@ -25,6 +25,34 @@ public class Property {
@JSONField
(
serialize
=
false
)
private
DataModel
ownerDataModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
DataModel
getRootDataModel
()
{
return
this
.
getOwnerDataModel
().
getRootDataModel
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Property
getRootFactPorperty
()
{
return
this
.
getOwnerDataModel
().
getRootFactPorperty
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Property
getFactPorperty
()
{
return
this
.
getOwnerDataModel
().
getFactPorperty
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
int
getLayerNo
()
{
return
this
.
getOwnerDataModel
().
getLayerNo
();
}
@JSONField
(
ordinal
=
1
)
private
String
propertyName
;
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/CommonEntityService.java
0 → 100644
浏览文件 @
219aade2
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.util.filter.QueryFilter
;
import
com.sun.jndi.toolkit.dir.SearchFilter
;
import
java.util.List
;
public
interface
CommonEntityService
{
List
<
EntityObj
>
selectBase
(
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
selectCore
(
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
);
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
);
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
0 → 100644
浏览文件 @
219aade2
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.filter.DbEntitySearchContext
;
import
cn.ibizlab.core.extensions.mapper.DbEntityMapper
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
@Primary
@Slf4j
public
class
DbEntityService
extends
ServiceImpl
<
DbEntityMapper
,
EntityObj
>
implements
CommonEntityService
{
@Override
public
List
<
EntityObj
>
selectBase
(
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
search
(
"BASE"
,
entityModel
,
filter
);
}
@Override
public
List
<
EntityObj
>
selectCore
(
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
search
(
"CORE"
,
entityModel
,
filter
);
}
@Override
public
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
)
{
String
sql
=
entityModel
.
getSqlSegment
(
dataSet
);
if
(
StringUtils
.
isEmpty
(
sql
))
return
new
ArrayList
<>();
else
return
search
(
entityModel
.
getDsName
(),
sql
,
filter
);
}
@Override
public
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
)
{
try
{
DynamicDataSourceContextHolder
.
push
(
dsName
);
DbEntitySearchContext
context
=
new
DbEntitySearchContext
();
context
.
setFilter
(
filter
);
return
baseMapper
.
search
(
sql
,
context
.
getSelectCond
());
}
catch
(
Exception
ex
)
{
log
.
error
(
"详细错误信息:"
+
ex
.
getMessage
()
+
", 执行sql:"
+
sql
);
return
null
;
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/MongoEntityService.java
0 → 100644
浏览文件 @
219aade2
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.util.filter.QueryFilter
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
MongoEntityService
implements
CommonEntityService
{
@Override
public
List
<
EntityObj
>
selectBase
(
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
List
<
EntityObj
>
selectCore
(
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
List
<
EntityObj
>
search
(
String
dataSet
,
EntityModel
entityModel
,
QueryFilter
filter
)
{
return
null
;
}
@Override
public
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
)
{
return
null
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/util/LiteStorage.java
浏览文件 @
219aade2
...
...
@@ -32,6 +32,11 @@ public class LiteStorage {
LiteStorage
.
service
=
service
;
}
public
static
LiteModelService
getLiteModelService
()
{
return
service
;
}
public
static
MetaEntity
getMetaEntity
(
String
name
)
{
synchronized
(
entityLock
)
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录