Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
b8d21011
提交
b8d21011
编写于
11月 22, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model
上级
3a12d7aa
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
145 行增加
和
6 行删除
+145
-6
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+7
-2
FieldModel.java
...va/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
+7
-0
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+4
-2
DataModel.java
...java/cn/ibizlab/core/lite/extensions/model/DataModel.java
+70
-0
Property.java
.../java/cn/ibizlab/core/lite/extensions/model/Property.java
+17
-0
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+24
-2
QueryFilter.java
...til/src/main/java/cn/ibizlab/util/filter/QueryFilter.java
+16
-0
未找到文件。
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
浏览文件 @
b8d21011
...
...
@@ -19,11 +19,15 @@ public class EntityObj extends DataObj<String,Object> {
@JSONField
(
serialize
=
false
)
public
EntityModel
getEntityModel
()
{
if
(
entityModel
==
null
)
entityModel
=
LiteStorage
.
getLiteModelService
().
getEntityModel
(
this
.
getDstSystemId
(),
this
.
getMetaEntityName
());
return
entityModel
;
}
public
EntityObj
setEntityModel
(
EntityModel
entityModel
)
{
this
.
entityModel
=
entityModel
;
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
...
...
@@ -61,6 +65,7 @@ public class EntityObj extends DataObj<String,Object> {
this
.
setDstSystemId
(
property
.
getSystem
());
if
(!
StringUtils
.
isEmpty
(
property
.
getPropertyEntity
()))
this
.
setMetaEntityName
(
property
.
getPropertyEntity
());
this
.
setEntityModel
(
property
.
getEntityModel
());
}
this
.
property
=
property
;
return
this
;
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
浏览文件 @
b8d21011
...
...
@@ -44,6 +44,13 @@ public class FieldModel {
return
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isPhysicalField
()
{
return
1
==
this
.
getField
().
getPhysicalField
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isKeyField
()
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
浏览文件 @
b8d21011
...
...
@@ -26,8 +26,9 @@ public class ModelObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
void
setDataModel
(
DataModel
dataModel
)
{
public
ModelObj
setDataModel
(
DataModel
dataModel
)
{
this
.
dataModel
=
dataModel
;
return
this
;
}
@JsonIgnore
...
...
@@ -42,8 +43,9 @@ public class ModelObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
void
setParent
(
ModelObj
parent
)
{
public
ModelObj
setParent
(
ModelObj
parent
)
{
this
.
parent
=
parent
;
return
this
;
}
public
EntityObj
getEntity
(
String
name
)
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/DataModel.java
浏览文件 @
b8d21011
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
model
;
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
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
...
...
@@ -11,7 +14,9 @@ import lombok.experimental.Accessors;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
@Getter
@Setter
...
...
@@ -107,6 +112,13 @@ public class DataModel {
return
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityModel
getFactEntityModel
()
{
return
this
.
getFactPorperty
().
getEntityModel
();
}
public
Property
getObjectProperty
(
String
name
)
{
if
(
this
.
getObjectProperties
()!=
null
&&(!
StringUtils
.
isEmpty
(
name
)))
...
...
@@ -216,4 +228,62 @@ public class DataModel {
", layerMappings="
+
getLayerMappings
()
+
"}\r\n"
;
}
public
String
lookup
(
List
<
EntityObj
>
parentEntityList
)
{
String
sql
=
""
;
String
cond
=
""
;
List
<
String
>
selfCols
=
new
ArrayList
<>();
List
<
String
>
parentCols
=
new
ArrayList
<>();
if
(
layerMappings
.
size
()>
0
)
{
layerMappings
.
forEach
(
layerMapping
->
{
selfCols
.
add
(
layerMapping
.
getSelfPropertyColumn
());
parentCols
.
add
(
layerMapping
.
getParentPropertyColumn
());
});
}
else
{
EntityModel
entityModel
=
this
.
getFactEntityModel
();
if
(
entityModel
.
getKeyField
().
isPhysicalField
())
{
selfCols
.
add
(
entityModel
.
getKeyField
().
getColumnName
());
parentCols
.
add
(
entityModel
.
getKeyField
().
getColumnName
());
}
else
entityModel
.
getUnionKeyFields
().
forEach
(
fieldModel
->
{
selfCols
.
add
(
fieldModel
.
getColumnName
());
parentCols
.
add
(
fieldModel
.
getColumnName
());
});
}
for
(
String
selfCol
:
selfCols
)
{
if
(!
StringUtils
.
isEmpty
(
sql
))
sql
+=
","
;
sql
+=
selfCol
;
}
for
(
EntityObj
entityObj:
parentEntityList
)
{
String
condItem
=
""
;
for
(
String
parentCol:
parentCols
)
{
Object
val
=
entityObj
.
get
(
parentCol
);
if
(
val
instanceof
String
)
{
val
=
"'"
+
val
.
toString
()+
"'"
;
}
if
(!
StringUtils
.
isEmpty
(
condItem
))
condItem
+=
","
;
condItem
+=
val
;
}
if
(!
StringUtils
.
isEmpty
(
cond
))
cond
+=
","
;
cond
=
cond
+
"("
+
condItem
+
")"
;
}
return
"("
+
sql
+
") in ("
+
cond
+
")"
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/model/Property.java
浏览文件 @
b8d21011
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
model
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
...
...
@@ -83,4 +85,19 @@ public class Property {
", propertyMappings="
+
getPropertyMappings
()
+
"}\r\n"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
EntityModel
entityModel
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
synchronized
EntityModel
getEntityModel
()
{
if
(
entityModel
==
null
)
entityModel
=
LiteStorage
.
getLiteModelService
().
getEntityModel
(
this
.
getSystem
(),
this
.
getPropertyEntity
());
return
entityModel
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
b8d21011
...
...
@@ -20,6 +20,7 @@ import org.springframework.util.StringUtils;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
@Service
...
...
@@ -54,7 +55,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
DynamicDataSourceContextHolder
.
push
(
dsName
);
DbEntitySearchContext
context
=
new
DbEntitySearchContext
();
context
.
setFilter
(
filter
);
return
baseMapper
.
search
(
sql
,
context
.
getSelectCond
());
return
baseMapper
.
search
(
sql
,
context
.
getSelectCond
()
.
apply
(
filter
.
getCustSqlSegment
())
);
}
catch
(
Exception
ex
)
{
...
...
@@ -74,7 +75,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
public
List
<
ModelObj
>
getModelObjs
(
DataModel
dataModel
,
Timestamp
lastModify
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
dataModel
.
getFactPorperty
().
getSystem
(),
dataModel
.
getFactPorperty
().
getPropertyEntity
()
);
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
(
);
FieldModel
lastModifyField
=
entityModel
.
getLastModifyField
();
QueryFilter
filter
=
new
QueryFilter
();
...
...
@@ -86,4 +87,25 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
return
new
ArrayList
<>();
}
public
List
<
ModelObj
>
getModelObjs
(
DataModel
dataModel
,
List
<
EntityObj
>
kEntityObjs
)
{
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
LinkedHashMap
<
String
,
ModelObj
>
rt
=
new
LinkedHashMap
<>();
List
<
EntityObj
>
factEntityList
=
this
.
selectBase
(
entityModel
,
QueryFilter
.
createQuery
().
cust
(
dataModel
.
lookup
(
kEntityObjs
)));
factEntityList
.
forEach
(
entityObj
->{
entityObj
.
setProperty
(
dataModel
.
getFactPorperty
()).
setDataModel
(
dataModel
);
String
rowKey
=
entityObj
.
getStringValue
(
entityModel
.
getKeyField
().
getColumnName
());
ModelObj
modelObj
=
new
ModelObj
().
setDataModel
(
dataModel
).
setRowKey
(
rowKey
);
modelObj
.
set
(
dataModel
.
getFactPorperty
().
getPropertyName
(),
entityObj
);
rt
.
put
(
rowKey
,
modelObj
);
});
return
null
;
}
}
ibzlite-util/src/main/java/cn/ibizlab/util/filter/QueryFilter.java
浏览文件 @
b8d21011
...
...
@@ -124,6 +124,22 @@ public class QueryFilter {
}
@JsonIgnore
@Transient
private
String
custSqlSegment
;
public
QueryFilter
cust
(
String
custSqlSegment
)
{
this
.
custSqlSegment
=
custSqlSegment
;
return
null
;
}
@JsonIgnore
@Transient
public
String
getCustSqlSegment
()
{
return
this
.
custSqlSegment
;
}
@Override
public
String
toString
()
{
return
"QueryFilter{"
+
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录