Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
e5bcafdf
提交
e5bcafdf
编写于
3月 05, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
7e114063
变更
13
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
718 行增加
和
26 行删除
+718
-26
DbEntityMapper.java
...ava/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
+18
-0
EntityModel.java
...a/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
+115
-0
EntityObj.java
...ava/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
+17
-3
FieldModel.java
...va/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
+10
-3
FieldObj.java
...java/cn/ibizlab/core/lite/extensions/domain/FieldObj.java
+263
-0
ModelObj.java
...java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
+85
-13
NestedArray.java
...a/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
+1
-0
CommonEntityService.java
...lab/core/lite/extensions/service/CommonEntityService.java
+4
-0
DbEntityService.java
...ibizlab/core/lite/extensions/service/DbEntityService.java
+62
-1
LiteDataService.java
...ibizlab/core/lite/extensions/service/LiteDataService.java
+26
-1
LiteModelService.java
...bizlab/core/lite/extensions/service/LiteModelService.java
+38
-2
MongoEntityService.java
...zlab/core/lite/extensions/service/MongoEntityService.java
+14
-0
LiteCoreResource.java
...java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
+65
-3
未找到文件。
ibzlite-core/src/main/java/cn/ibizlab/core/extensions/mapper/DbEntityMapper.java
浏览文件 @
e5bcafdf
package
cn
.
ibizlab
.
core
.
extensions
.
mapper
;
package
cn
.
ibizlab
.
core
.
extensions
.
mapper
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
cn.ibizlab.core.lite.extensions.domain.EntityObj
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,4 +14,20 @@ public interface DbEntityMapper extends BaseMapper<EntityObj>{
...
@@ -12,4 +14,20 @@ 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
);
Integer
searchCount
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"ew"
)
Wrapper
<
EntityObj
>
wrapper
);
@Insert
({
"<script> "
+
" MERGE INTO ${model.tableName} T1\n"
+
" USING (\n"
+
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\"UNION ALL\">\n"
+
" SELECT ${model.mergeColumnSegment} FROM dual\n"
+
"</foreach>\n"
+
" ) T2 \n ${model.mergeSegment}"
+
"</script>"
})
boolean
saveBatch
(
@Param
(
"model"
)
EntityModel
model
,
@Param
(
"list"
)
List
<
EntityObj
>
list
);
@Insert
({
"<script> "
+
" MERGE INTO ${model.tableName} T1\n"
+
" USING (\n"
+
" SELECT ${model.mergeColumnSegment} FROM dual\n"
+
" ) T2 \n ${model.mergeSegment}"
+
"</script>"
})
boolean
save
(
@Param
(
"model"
)
EntityModel
model
,
@Param
(
"entity"
)
EntityObj
entity
);
}
}
\ No newline at end of file
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
浏览文件 @
e5bcafdf
...
@@ -106,6 +106,24 @@ public class EntityModel {
...
@@ -106,6 +106,24 @@ public class EntityModel {
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
private
boolean
isLogicValid
=
true
;
private
boolean
isLogicValid
=
true
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLogicValid
()
{
if
(
isLogicValid
&&
logicValidField
==
null
)
{
if
(
fields
!=
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isLogicValidField
())
{
logicValidField
=
fieldModel
;
return
isLogicValid
;
}
}
}
isLogicValid
=
false
;
}
return
isLogicValid
;
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
private
FieldModel
logicValidField
;
private
FieldModel
logicValidField
;
...
@@ -182,6 +200,18 @@ public class EntityModel {
...
@@ -182,6 +200,18 @@ public class EntityModel {
return
unionKeyFields
;
return
unionKeyFields
;
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
List
<
FieldModel
>
getKeyFields
()
{
if
(
this
.
getKeyField
()!=
null
&&
this
.
getKeyField
().
isPhysicalField
())
{
List
<
FieldModel
>
keyFields
=
new
ArrayList
<>();
keyFields
.
add
(
getKeyField
());
return
keyFields
;
}
else
return
getUnionKeyFields
();
}
public
FieldModel
getField
(
String
name
)
public
FieldModel
getField
(
String
name
)
{
{
if
(
StringUtils
.
isEmpty
(
name
))
if
(
StringUtils
.
isEmpty
(
name
))
...
@@ -239,6 +269,91 @@ public class EntityModel {
...
@@ -239,6 +269,91 @@ public class EntityModel {
return
""
;
return
""
;
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getMergeColumnSegment
()
{
String
sql
=
""
;
boolean
first
=
true
;
for
(
FieldModel
fieldModel:
this
.
getFields
())
{
if
(!
fieldModel
.
isPhysicalField
())
continue
;
if
(
first
)
first
=
false
;
else
sql
+=
","
;
sql
+=(
"#{item."
+
fieldModel
.
getColumnName
().
toUpperCase
()+
"} "
+
fieldModel
.
getColumnName
().
toUpperCase
());
}
return
sql
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getMergeSegment
()
{
String
sql
=
""
;
sql
+=
" ON ("
;
boolean
first
=
true
;
for
(
FieldModel
fieldModel:
this
.
getKeyFields
())
{
if
(!
fieldModel
.
isPhysicalField
())
continue
;
if
(
first
)
first
=
false
;
else
sql
+=
" and "
;
sql
+=(
"T1."
+
fieldModel
.
getColumnName
().
toUpperCase
()+
"=T2."
+
fieldModel
.
getColumnName
().
toUpperCase
());
}
sql
+=
")\n"
+
" WHEN NOT MATCHED THEN INSERT("
;
first
=
true
;
for
(
FieldModel
fieldModel:
this
.
getFields
())
{
if
(!
fieldModel
.
isPhysicalField
())
continue
;
if
(
first
)
first
=
false
;
else
sql
+=
","
;
sql
+=(
fieldModel
.
getColumnName
().
toUpperCase
());
}
sql
+=
") VALUES ("
;
first
=
true
;
for
(
FieldModel
fieldModel:
this
.
getFields
())
{
if
(!
fieldModel
.
isPhysicalField
())
continue
;
if
(
first
)
first
=
false
;
else
sql
+=
","
;
sql
+=(
"T2."
+
fieldModel
.
getColumnName
().
toUpperCase
());
}
sql
+=
")\n"
+
" WHEN MATCHED THEN UPDATE SET "
;
first
=
true
;
for
(
FieldModel
fieldModel:
this
.
getFields
())
{
if
(!
fieldModel
.
isPhysicalField
())
continue
;
if
(
fieldModel
.
isKeyField
())
continue
;
if
(
fieldModel
.
isUnionKeyField
())
continue
;
if
(
first
)
first
=
false
;
else
sql
+=
","
;
sql
+=(
"T1."
+
fieldModel
.
getColumnName
().
toUpperCase
()+
"=T2."
+
fieldModel
.
getColumnName
().
toUpperCase
());
}
return
sql
;
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
String
getDsName
()
public
String
getDsName
()
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityObj.java
浏览文件 @
e5bcafdf
...
@@ -14,6 +14,15 @@ import java.util.List;
...
@@ -14,6 +14,15 @@ import java.util.List;
public
class
EntityObj
extends
DataObj
<
String
,
Object
>
{
public
class
EntityObj
extends
DataObj
<
String
,
Object
>
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
EntityObj
copy
()
{
EntityObj
copy
=
new
EntityObj
();
this
.
copyTo
(
copy
,
true
);
if
(
this
.
property
!=
null
)
copy
.
setProperty
(
this
.
property
);
return
copy
;
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
...
@@ -158,11 +167,14 @@ public class EntityObj extends DataObj<String,Object> {
...
@@ -158,11 +167,14 @@ public class EntityObj extends DataObj<String,Object> {
tmps
.
remove
(
modelObj
.
getRowKey
());
tmps
.
remove
(
modelObj
.
getRowKey
());
});
});
});
});
if
(
tmps
.
size
()>
0
)
if
(
tmps
.
size
()==
1
)
{
tmps
.
values
().
iterator
().
next
().
setEntity
(
this
.
getProperty
().
getPropertyName
(),
this
);
}
else
if
(
tmps
.
size
()>
1
)
{
{
tmps
.
values
().
forEach
(
obj
->{
tmps
.
values
().
forEach
(
obj
->{
EntityObj
copy
=
this
.
copyTo
(
new
EntityObj
(),
true
).
setProperty
(
this
.
getProperty
());
obj
.
setEntity
(
this
.
getProperty
().
getPropertyName
(),
this
.
copy
());
obj
.
setEntity
(
this
.
getProperty
().
getPropertyName
(),
copy
);
});
});
}
}
}
}
...
@@ -171,6 +183,8 @@ public class EntityObj extends DataObj<String,Object> {
...
@@ -171,6 +183,8 @@ public class EntityObj extends DataObj<String,Object> {
{
{
if
(!
this
.
getEntityModel
().
isLogicValid
())
if
(!
this
.
getEntityModel
().
isLogicValid
())
return
false
;
return
false
;
if
(
this
.
getEntityModel
().
getLogicValidField
()==
null
)
return
false
;
if
(
this
.
getEntityModel
().
getLogicVal
().
equals
(
this
.
get
(
this
.
getEntityModel
().
getLogicValidField
().
getColumnName
())))
if
(
this
.
getEntityModel
().
getLogicVal
().
equals
(
this
.
get
(
this
.
getEntityModel
().
getLogicValidField
().
getColumnName
())))
return
false
;
return
false
;
return
true
;
return
true
;
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
浏览文件 @
e5bcafdf
...
@@ -33,7 +33,7 @@ public class FieldModel {
...
@@ -33,7 +33,7 @@ public class FieldModel {
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
String
getColumnExp
()
public
String
getColumnExp
()
{
{
if
(
1
==
field
.
getPhysicalField
())
if
(
field
.
getPhysicalField
()!=
null
&&
1
==
field
.
getPhysicalField
())
{
{
return
columnName
+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
return
columnName
+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
}
}
...
@@ -48,14 +48,14 @@ public class FieldModel {
...
@@ -48,14 +48,14 @@ public class FieldModel {
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
boolean
isPhysicalField
()
public
boolean
isPhysicalField
()
{
{
return
1
==
this
.
getField
().
getPhysicalField
();
return
this
.
getField
().
getPhysicalField
()!=
null
&&
1
==
this
.
getField
().
getPhysicalField
();
}
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
boolean
isKeyField
()
public
boolean
isKeyField
()
{
{
return
1
==
this
.
getField
().
getKeyField
();
return
this
.
getField
().
getKeyField
()!=
null
&&
1
==
this
.
getField
().
getKeyField
();
}
}
@JsonIgnore
@JsonIgnore
...
@@ -72,6 +72,13 @@ public class FieldModel {
...
@@ -72,6 +72,13 @@ public class FieldModel {
return
"UPDATEDATE"
.
equals
(
this
.
getField
().
getPredefined
());
return
"UPDATEDATE"
.
equals
(
this
.
getField
().
getPredefined
());
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isCreateTimeField
()
{
return
"CREATEDATE"
.
equals
(
this
.
getField
().
getPredefined
());
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
boolean
isUnionKeyField
()
public
boolean
isUnionKeyField
()
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/FieldObj.java
0 → 100644
浏览文件 @
e5bcafdf
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
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
FieldObj
{
public
DataModel
getDataModel
()
{
if
(
property
!=
null
)
return
property
.
getOwnerDataModel
();
return
null
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getDataModelName
()
{
if
(
getDataModel
()!=
null
&&
getDataModel
().
getDataModelName
()!=
null
)
return
getDataModel
().
getDataModelName
();
else
return
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Property
property
;
public
FieldObj
setProperty
(
Property
property
)
{
this
.
property
=
property
;
return
this
;
}
private
String
columnName
;
private
Object
value
;
public
<
T
>
T
getValue
(
T
defaultVal
)
{
return
getValue
(
null
,
defaultVal
);
}
public
<
T
>
T
getValue
(
Class
<
T
>
type
,
T
defaultVal
)
{
T
ret
=
defaultVal
;
if
(
value
==
null
)
return
ret
;
Object
obj
=
null
;
if
((!(
defaultVal
instanceof
List
))&&(
value
instanceof
List
))
{
for
(
Object
item:
(
List
)
value
){
if
(
item
!=
null
)
{
if
(
obj
==
null
||
RuleUtils
.
gt
(
obj
,
item
))
obj
=
item
;
}
}
if
(
obj
==
null
)
return
defaultVal
;
}
else
{
obj
=
value
;
}
if
(
type
==
null
&&
defaultVal
!=
null
)
type
=
(
Class
<
T
>)
defaultVal
.
getClass
();
ret
=
DataObject
.
valueOf
(
type
,
obj
);
if
(
ret
==
null
)
return
defaultVal
;
return
ret
;
}
public
<
T
>
T
getItemValue
(
int
idx
,
Class
<
T
>
type
,
T
defaultVal
)
{
if
(
value
instanceof
List
)
{
List
list
=(
List
)
value
;
if
(
list
.
size
()>
idx
)
{
T
ret
=
DataObject
.
valueOf
(
type
,
list
.
get
(
idx
));
if
(
ret
==
null
)
return
defaultVal
;
return
ret
;
}
return
defaultVal
;
}
else
return
getValue
(
type
,
defaultVal
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getValues
()
{
String
rt
=
""
;
if
(
value
!=
null
&&
value
instanceof
List
)
{
for
(
Object
item:
(
List
)
value
){
if
(
item
!=
null
)
{
if
((!
StringUtils
.
isEmpty
(
rt
))&&(!
rt
.
endsWith
(
","
)))
rt
=
rt
+
","
;
rt
=
rt
+
DataObject
.
getStringValue
(
item
,
""
);
}
}
}
else
{
rt
=
DataObject
.
getStringValue
(
value
,
""
);
}
return
rt
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Integer
getCount
()
{
return
getCount
(
true
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Integer
getCount
(
boolean
includeNull
)
{
if
(
includeNull
)
{
if
(
value
instanceof
List
)
return
((
List
)
value
).
size
()==
0
?
1
:((
List
)
value
).
size
();
else
return
1
;
}
if
(
value
==
null
)
return
0
;
else
if
(
value
instanceof
List
)
{
List
list
=
(
List
)
value
;
int
cnt
=
0
;
for
(
Object
item:
list
)
cnt
+=
StringUtils
.
isEmpty
(
DataObject
.
getStringValue
(
list
.
get
(
0
),
null
))?
0
:
1
;
return
cnt
;
}
else
return
StringUtils
.
isEmpty
(
value
.
toString
())?
0
:
1
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isEmpty
()
{
return
getCount
(
false
)==
0
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isNotEmpty
()
{
return
!
isEmpty
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isMultiple
()
{
return
getCount
()>
1
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isSingle
()
{
return
!
isMultiple
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isSingleAndNotEmpty
()
{
return
isSingle
()&&
isNotEmpty
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
BigDecimal
getDecimal
()
{
BigDecimal
decimal
=
new
BigDecimal
(
1
);
Object
val
=
this
.
getValue
(
Object
.
class
,
null
);
if
(
val
==
null
)
decimal
=(
new
BigDecimal
(
1
));
else
if
(
(
val
instanceof
BigDecimal
))
decimal
=(((
BigDecimal
)
val
));
else
if
(
val
instanceof
Double
)
decimal
=(
new
BigDecimal
((
Double
)
val
));
else
if
(
val
instanceof
Float
)
decimal
=(
new
BigDecimal
(((
Float
)
val
).
doubleValue
()));
else
if
(
val
instanceof
Integer
)
decimal
=(
new
BigDecimal
((
int
)
val
));
else
if
(
val
instanceof
Long
)
decimal
=(
new
BigDecimal
((
Long
)
val
));
if
(
decimal
.
intValue
()>
Integer
.
MAX_VALUE
)
decimal
=(
new
BigDecimal
(
1
));
return
decimal
;
}
public
BigDecimal
getItemDecimal
(
int
idx
)
{
BigDecimal
decimal
=
new
BigDecimal
(
1
);
Object
val
=
this
.
getItemValue
(
idx
,
Object
.
class
,
null
);
if
(
val
==
null
)
decimal
=(
new
BigDecimal
(
1
));
else
if
(
(
val
instanceof
BigDecimal
))
decimal
=(((
BigDecimal
)
val
));
else
if
(
val
instanceof
Double
)
decimal
=(
new
BigDecimal
((
Double
)
val
));
else
if
(
val
instanceof
Float
)
decimal
=(
new
BigDecimal
(((
Float
)
val
).
doubleValue
()));
else
if
(
val
instanceof
Integer
)
decimal
=(
new
BigDecimal
((
int
)
val
));
else
if
(
val
instanceof
Long
)
decimal
=(
new
BigDecimal
((
Long
)
val
));
if
(
decimal
.
intValue
()>
Integer
.
MAX_VALUE
)
decimal
=(
new
BigDecimal
(
1
));
return
decimal
;
}
@Override
public
String
toString
()
{
return
getValues
();
}
public
static
void
main
(
String
[]
args
)
{
FieldObj
fieldObj
=
new
FieldObj
();
fieldObj
.
setValue
(
new
BigDecimal
(
1
));
Object
t
=
fieldObj
.
getValue
(
Object
.
class
,
null
);
System
.
out
.
println
(
t
);
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/ModelObj.java
浏览文件 @
e5bcafdf
...
@@ -19,6 +19,45 @@ import java.util.List;
...
@@ -19,6 +19,45 @@ import java.util.List;
public
class
ModelObj
extends
DataObj
<
String
,
Object
>
{
public
class
ModelObj
extends
DataObj
<
String
,
Object
>
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
ModelObj
copy
()
{
ModelObj
copy
=
new
ModelObj
();
if
(
this
.
dataModel
!=
null
)
copy
.
setDataModel
(
this
.
dataModel
);
if
(
copy
.
getDataModel
()!=
null
)
{
copy
.
getDataModel
().
getObjectProperties
().
forEach
(
property
->
{
Object
obj
=
this
.
get
(
property
.
getPropertyName
());
if
(
obj
!=
null
&&
obj
instanceof
EntityObj
)
{
copy
.
setEntity
(
property
.
getPropertyName
(),((
EntityObj
)
obj
).
copy
());
}
});
copy
.
getDataModel
().
getNestedDataModels
().
forEach
(
dm
->
{
Object
list
=
this
.
get
(
dm
.
getDataModelName
());
if
(
list
!=
null
&&
list
instanceof
NestedArray
)
{
NestedArray
nestedArray
=(
NestedArray
)
list
;
nestedArray
.
forEach
(
sub
->{
sub
.
copy
().
setParent
(
copy
);
});
}
});
}
if
(!
StringUtils
.
isEmpty
(
this
.
getRowKey
()))
copy
.
setRowKey
(
this
.
getRowKey
());
return
copy
;
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
private
DataModel
dataModel
;
...
@@ -270,12 +309,19 @@ public class ModelObj extends DataObj<String,Object> {
...
@@ -270,12 +309,19 @@ public class ModelObj extends DataObj<String,Object> {
{
{
this
.
setParent
(
tmps
.
values
().
iterator
().
next
());
this
.
setParent
(
tmps
.
values
().
iterator
().
next
());
}
}
else
if
(
tmps
.
size
()>
1
)
{
tmps
.
values
().
forEach
(
parent
->
{
ModelObj
copy
=
this
.
copy
().
setTimestamp
(
this
.
getTimestamp
());
copy
.
setParent
(
parent
);
});
}
return
this
;
return
this
;
}
}
public
Object
$
(
String
key
)
public
FieldObj
$
(
String
key
)
{
{
if
(
key
.
toString
().
indexOf
(
"."
)>
0
)
if
(
key
.
toString
().
indexOf
(
"."
)>
0
)
{
{
...
@@ -285,13 +331,16 @@ public class ModelObj extends DataObj<String,Object> {
...
@@ -285,13 +331,16 @@ public class ModelObj extends DataObj<String,Object> {
String
name
=
epair
[
0
];
String
name
=
epair
[
0
];
String
column
=
epair
[
1
];
String
column
=
epair
[
1
];
Property
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"UP"
);
Property
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"UP"
);
if
(
property
!=
null
)
if
(
property
!=
null
)
{
return
this
.
getEntity
(
name
).
get
(
column
);
Object
val
=
this
.
getEntity
(
name
).
get
(
column
);
return
new
FieldObj
().
setValue
(
val
).
setProperty
(
property
);
}
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"DOWN"
);
property
=
this
.
getDataModel
().
findObjectProperty
(
name
,
"DOWN"
);
if
(
property
!=
null
)
if
(
property
!=
null
)
{
{
return
this
.
getNested
(
property
.
getOwnerDataModel
().
getDataModelName
()).
get
(
key
);
Object
val
=
this
.
getNested
(
property
.
getOwnerDataModel
().
getDataModelName
()).
get
(
key
);
return
new
FieldObj
().
setValue
(
val
).
setProperty
(
property
);
}
}
if
(
this
.
getParent
()!=
null
)
if
(
this
.
getParent
()!=
null
)
...
@@ -300,21 +349,33 @@ public class ModelObj extends DataObj<String,Object> {
...
@@ -300,21 +349,33 @@ public class ModelObj extends DataObj<String,Object> {
}
}
}
}
return
get
(
key
);
return
new
FieldObj
().
setValue
(
get
(
key
)).
setProperty
(
this
.
getDataModel
().
getFactPorperty
()
);
}
}
@JsonIgnore
public
Double
$D
(
String
key
)
@JSONField
(
serialize
=
false
)
private
FieldObj
empty
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
FieldObj
getEmpty
()
{
{
Object
val
=
this
.
get
(
key
);
if
(
empty
==
null
)
if
(
val
==
null
)
empty
=
new
FieldObj
().
setValue
(
null
).
setProperty
(
this
.
getDataModel
().
getFactPorperty
());
return
0
d
;
return
empty
;
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
FieldObj
$S
(
String
val
)
{
return
new
FieldObj
().
setValue
(
val
).
setProperty
(
this
.
getDataModel
().
getFactPorperty
());
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
FieldObj
$K
()
{
return
new
FieldObj
().
setValue
(
this
.
getRowKey
()).
setProperty
(
this
.
getDataModel
().
getFactPorperty
());
}
public
boolean
IF
(
String
cond
)
public
boolean
IF
(
String
cond
)
...
@@ -413,6 +474,17 @@ public class ModelObj extends DataObj<String,Object> {
...
@@ -413,6 +474,17 @@ public class ModelObj extends DataObj<String,Object> {
return
null
;
return
null
;
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Boolean
isDelete
()
{
if
(
dataModel
!=
null
&&
dataModel
.
getFactPorperty
()!=
null
)
{
return
getFactEntity
().
isDelete
();
}
return
false
;
}
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/NestedArray.java
浏览文件 @
e5bcafdf
...
@@ -12,6 +12,7 @@ import java.util.List;
...
@@ -12,6 +12,7 @@ import java.util.List;
public
class
NestedArray
extends
ArrayList
<
ModelObj
>
{
public
class
NestedArray
extends
ArrayList
<
ModelObj
>
{
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
private
DataModel
dataModel
;
private
DataModel
dataModel
;
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/CommonEntityService.java
浏览文件 @
e5bcafdf
...
@@ -18,6 +18,10 @@ public interface CommonEntityService {
...
@@ -18,6 +18,10 @@ public interface CommonEntityService {
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
);
List
<
EntityObj
>
search
(
String
dsName
,
String
sql
,
QueryFilter
filter
);
boolean
saveBatch
(
EntityModel
entityModel
,
List
<
EntityObj
>
list
);
boolean
save
(
EntityModel
entityModel
,
EntityObj
entityObj
);
EntityObj
get
(
EntityModel
entityModel
,
EntityObj
entityObj
);
void
processList
(
DataModel
dataModel
,
Timestamp
lastModify
,
LiteDataCallback
callback
);
void
processList
(
DataModel
dataModel
,
Timestamp
lastModify
,
LiteDataCallback
callback
);
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/DbEntityService.java
浏览文件 @
e5bcafdf
...
@@ -146,8 +146,64 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
...
@@ -146,8 +146,64 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
}
}
}
}
@Override
public
boolean
saveBatch
(
EntityModel
entityModel
,
List
<
EntityObj
>
list
)
{
try
{
dstDataSourceService
.
initDataSource
(
entityModel
.
getDsName
());
DynamicDataSourceContextHolder
.
push
(
entityModel
.
getDsName
());
list
.
forEach
(
entityObj
->
{
entityObj
.
keySet
().
forEach
(
key
->
{
if
(!
key
.
toUpperCase
().
equals
(
key
))
entityObj
.
put
(
key
.
toUpperCase
(),
entityObj
.
get
(
key
));
});
});
return
baseMapper
.
saveBatch
(
entityModel
,
list
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"详细错误信息:"
+
ex
.
getMessage
()
+
", 执行sql:"
+
entityModel
.
getTableName
());
return
false
;
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
@Override
public
boolean
save
(
EntityModel
entityModel
,
EntityObj
entityObj
)
{
try
{
dstDataSourceService
.
initDataSource
(
entityModel
.
getDsName
());
DynamicDataSourceContextHolder
.
push
(
entityModel
.
getDsName
());
entityObj
.
keySet
().
forEach
(
key
->
{
if
(!
key
.
toUpperCase
().
equals
(
key
))
entityObj
.
put
(
key
.
toUpperCase
(),
entityObj
.
get
(
key
));
});
return
baseMapper
.
save
(
entityModel
,
entityObj
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"详细错误信息:"
+
ex
.
getMessage
()
+
", 执行sql:"
+
entityModel
.
getTableName
());
return
false
;
}
finally
{
DynamicDataSourceContextHolder
.
poll
();
}
}
@Override
public
EntityObj
get
(
EntityModel
entityModel
,
EntityObj
entityObj
)
{
QueryFilter
filter
=
QueryFilter
.
createQuery
();
entityModel
.
getKeyFields
().
forEach
(
item
->{
Object
val
=
entityObj
.
get
(
item
.
getColumnName
());
if
(
val
!=
null
)
{
filter
.
eq
(
item
.
getColumnName
().
toUpperCase
(),
val
);
}
});
List
<
EntityObj
>
list
=
this
.
selectBase
(
entityModel
,
filter
);
if
(
list
.
size
()==
1
)
entityObj
.
putAll
(
list
.
get
(
0
));
return
entityObj
;
}
@Autowired
@Autowired
...
@@ -169,6 +225,11 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
...
@@ -169,6 +225,11 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
callback
.
total
(
total
);
callback
.
total
(
total
);
//没有业务数据时,不进行后续操作
if
(
total
==
0
){
return
;
}
MyBatisCursorItemReader
myMyBatisCursorItemReader
=
new
MyBatisCursorItemReader
();
MyBatisCursorItemReader
myMyBatisCursorItemReader
=
new
MyBatisCursorItemReader
();
try
{
try
{
...
@@ -189,7 +250,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
...
@@ -189,7 +250,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
dstDataSourceService
.
initDataSource
(
entityModel
.
getDsName
());
dstDataSourceService
.
initDataSource
(
entityModel
.
getDsName
());
DynamicDataSourceContextHolder
.
push
(
entityModel
.
getDsName
());
DynamicDataSourceContextHolder
.
push
(
entityModel
.
getDsName
());
myMyBatisCursorItemReader
.
open
(
new
ExecutionContext
());
// 开启游标
myMyBatisCursorItemReader
.
open
(
new
ExecutionContext
());
// 开启游标
DynamicDataSourceContextHolder
.
poll
();
//
DynamicDataSourceContextHolder.poll();
List
<
EntityObj
>
datas
=
new
ArrayList
<>();
List
<
EntityObj
>
datas
=
new
ArrayList
<>();
EntityObj
rowdata
;
EntityObj
rowdata
;
while
((
rowdata
=
(
EntityObj
)
myMyBatisCursorItemReader
.
read
())
!=
null
)
{
while
((
rowdata
=
(
EntityObj
)
myMyBatisCursorItemReader
.
read
())
!=
null
)
{
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteDataService.java
浏览文件 @
e5bcafdf
...
@@ -56,12 +56,37 @@ public class LiteDataService {
...
@@ -56,12 +56,37 @@ public class LiteDataService {
}
}
public
boolean
saveBatch
(
String
systemId
,
String
entityName
,
List
<
EntityObj
>
list
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
systemId
,
entityName
);
splitList
(
list
,
500
).
forEach
(
objs
->{
getEntityService
(
entityModel
.
getDsName
()).
saveBatch
(
entityModel
,
objs
);
});
return
true
;
}
public
boolean
save
(
String
systemId
,
String
entityName
,
EntityObj
entityObj
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
systemId
,
entityName
);
return
getEntityService
(
entityModel
.
getDsName
()).
save
(
entityModel
,
entityObj
);
}
public
EntityObj
get
(
String
systemId
,
String
entityName
,
EntityObj
entityObj
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
systemId
,
entityName
);
return
getEntityService
(
entityModel
.
getDsName
()).
get
(
entityModel
,
entityObj
);
}
public
List
<
EntityObj
>
search
(
String
systemId
,
String
entityName
,
QueryFilter
filter
)
{
return
search
(
systemId
,
entityName
,
"BASE"
,
filter
);
}
public
List
<
EntityObj
>
search
(
String
systemId
,
String
entityName
,
String
dataset
,
QueryFilter
filter
)
{
EntityModel
entityModel
=
liteModelService
.
getEntityModel
(
systemId
,
entityName
);
return
getEntityService
(
entityModel
.
getDsName
()).
search
(
dataset
,
entityModel
,
filter
);
}
public
void
processDataModel
(
String
metaModelId
,
Timestamp
lastModify
,
LiteDataCallback
callback
)
public
void
processDataModel
(
String
metaModelId
,
Timestamp
lastModify
,
LiteDataCallback
callback
)
{
{
DataModel
dataModel
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
metaModelService
.
get
(
metaModelId
).
getConfig
()),
DataModel
.
class
);
DataModel
dataModel
=
liteModelService
.
getDataModel
(
metaModelId
);
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
EntityModel
entityModel
=
dataModel
.
getFactEntityModel
();
getEntityService
(
entityModel
.
getDsName
()).
processList
(
dataModel
,
lastModify
,
callback
);
getEntityService
(
entityModel
.
getDsName
()).
processList
(
dataModel
,
lastModify
,
callback
);
}
}
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteModelService.java
浏览文件 @
e5bcafdf
...
@@ -8,12 +8,16 @@ import cn.ibizlab.core.lite.extensions.domain.EntityModel;
...
@@ -8,12 +8,16 @@ import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import
cn.ibizlab.core.lite.extensions.domain.FieldModel
;
import
cn.ibizlab.core.lite.extensions.domain.FieldModel
;
import
cn.ibizlab.core.lite.extensions.domain.RelationshipModel
;
import
cn.ibizlab.core.lite.extensions.domain.RelationshipModel
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.model.Property
;
import
cn.ibizlab.core.lite.extensions.model.PropertyMapping
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.service.*
;
import
cn.ibizlab.core.lite.service.*
;
import
cn.ibizlab.util.domain.FileItem
;
import
cn.ibizlab.util.domain.FileItem
;
import
cn.ibizlab.util.errors.InternalServerErrorException
;
import
cn.ibizlab.util.errors.InternalServerErrorException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -182,8 +186,40 @@ public class LiteModelService {
...
@@ -182,8 +186,40 @@ public class LiteModelService {
public
DataModel
getDataModel
(
String
dataModelId
)
public
DataModel
getDataModel
(
String
dataModelId
)
{
{
String
cfg
=
metaModelService
.
get
(
dataModelId
).
getConfig
();
String
cfg
=
metaModelService
.
get
(
dataModelId
).
getConfig
();
DataModel
dataModel
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
metaModelService
.
get
(
dataModelId
).
getConfig
()),
DataModel
.
class
);
JSONObject
model
=
JSON
.
parseObject
(
metaModelService
.
get
(
dataModelId
).
getConfig
());
dataModel
.
setModelString
(
cfg
);
String
factPropertyName
=
""
;
String
factSystem
=
""
;
if
(
model
.
containsKey
(
"objectProperties"
))
{
JSONArray
objProps
=
model
.
getJSONArray
(
"objectProperties"
);
if
(
objProps
.
size
()>
0
)
{
JSONObject
factObject
=
objProps
.
getJSONObject
(
0
);
factPropertyName
=
factObject
.
getString
(
"propertyName"
);
factSystem
=
factObject
.
getString
(
"system"
);
if
(
"tyyw2plus"
.
equals
(
factSystem
))
{
String
aj
=
"{\"propertyName\":\"DL_GG_AJXX2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJXX2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]}"
;
String
blry
=
"{\"dataModelName\":\"AJBLRY\",\"objectProperties\":[{\"propertyName\":\"DL_GG_AJBLRY2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJBLRY2\"}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}"
;
String
wshz
=
"{\"dataModelName\":\"AJWSHZ\",\"objectProperties\":[{\"propertyName\":\"JCNJ_YX_AJJZWJ\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"JCNJ_YX_AJJZWJ\"},{\"propertyName\":\"YX_WS_NR2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"YX_WS_NR2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"JCNJ_YX_AJJZWJ\",\"joinPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"WSBH\",\"joinPropertyName\":\"JCNJ_YX_AJJZWJ\",\"joinPropertyColumn\":\"JZWJH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}"
;
String
jzhz
=
"{\"dataModelName\":\"AJDZJZJBXX\",\"objectProperties\":[{\"propertyName\":\"DZJZ_YX_JZML\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DZJZ_YX_JZML\"},{\"propertyName\":\"YX_DZJZ_NR2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"YX_DZJZ_NR2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"DZJZ_YX_JZML\",\"joinPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"MLBH\",\"joinPropertyName\":\"DZJZ_YX_JZML\",\"joinPropertyColumn\":\"MLBH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}"
;
String
glaj
=
"{\"dataModelName\":\"AJGLHZ\",\"objectProperties\":[{\"propertyName\":\"AJ_YX_GLAJJL\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"AJ_YX_GLAJJL\"},{\"propertyName\":\"YAJ_XX\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJXX2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"AJ_YX_GLAJJL\",\"joinPropertyColumn\":\"YAJ_BMSAH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"GLAJ_BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}"
;
objProps
.
add
(
JSON
.
parseObject
(
aj
));
if
(!
model
.
containsKey
(
"nestedDataModels"
))
model
.
put
(
"nestedDataModels"
,
new
JSONArray
());
JSONArray
nested
=
model
.
getJSONArray
(
"nestedDataModels"
);
nested
.
add
(
JSON
.
parseObject
(
blry
));
nested
.
add
(
JSON
.
parseObject
(
wshz
));
nested
.
add
(
JSON
.
parseObject
(
jzhz
));
nested
.
add
(
JSON
.
parseObject
(
glaj
));
}
}
}
DataModel
dataModel
=
JSON
.
toJavaObject
(
model
,
DataModel
.
class
);
dataModel
.
setModelString
(
JSON
.
toJSONString
(
model
));
return
dataModel
;
return
dataModel
;
}
}
...
...
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/MongoEntityService.java
浏览文件 @
e5bcafdf
...
@@ -39,6 +39,20 @@ public class MongoEntityService implements CommonEntityService{
...
@@ -39,6 +39,20 @@ public class MongoEntityService implements CommonEntityService{
return
null
;
return
null
;
}
}
@Override
public
boolean
saveBatch
(
EntityModel
entityModel
,
List
<
EntityObj
>
list
)
{
return
false
;
}
@Override
public
boolean
save
(
EntityModel
entityModel
,
EntityObj
entityObj
)
{
return
false
;
}
@Override
public
EntityObj
get
(
EntityModel
entityModel
,
EntityObj
entityObj
)
{
return
null
;
}
@Override
@Override
...
...
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
浏览文件 @
e5bcafdf
...
@@ -10,13 +10,18 @@ import cn.ibizlab.core.lite.extensions.service.LiteCoreService;
...
@@ -10,13 +10,18 @@ import cn.ibizlab.core.lite.extensions.service.LiteCoreService;
import
cn.ibizlab.core.lite.extensions.service.LiteDataService
;
import
cn.ibizlab.core.lite.extensions.service.LiteDataService
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.service.*
;
import
cn.ibizlab.core.lite.service.IDstComponentService
;
import
cn.ibizlab.core.lite.service.IDstConfigService
;
import
cn.ibizlab.core.lite.service.IMetaEntityService
;
import
cn.ibizlab.core.lite.service.IMetaFieldService
;
import
cn.ibizlab.util.client.IBZDictFeignClient
;
import
cn.ibizlab.util.client.IBZDictFeignClient
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeItem
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.dict.CodeList
;
import
cn.ibizlab.util.dict.Option
;
import
cn.ibizlab.util.dict.Option
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.filter.QueryFilter
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -33,7 +38,11 @@ import org.springframework.util.DigestUtils;
...
@@ -33,7 +38,11 @@ import org.springframework.util.DigestUtils;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.UnsupportedEncodingException
;
import
java.sql.Wrapper
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -62,8 +71,8 @@ public class LiteCoreResource {
...
@@ -62,8 +71,8 @@ public class LiteCoreResource {
@Autowired
@Autowired
private
DbEntityService
dbEntityService
;
private
DbEntityService
dbEntityService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/
dst/test
/{modelid}/data/{key}"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/
lite/datamodels
/{modelid}/data/{key}"
)
public
ResponseEntity
<
ModelObj
>
get
str
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
)
public
ResponseEntity
<
ModelObj
>
get
ModelObj
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
)
{
{
if
(
StringUtils
.
isEmpty
(
modelid
))
if
(
StringUtils
.
isEmpty
(
modelid
))
...
@@ -189,6 +198,31 @@ public class LiteCoreResource {
...
@@ -189,6 +198,31 @@ public class LiteCoreResource {
return
ResponseEntity
.
ok
(
list
);
return
ResponseEntity
.
ok
(
list
);
}
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/lite/datamodels/{modelid}/allpropertys"
})
public
ResponseEntity
<
List
<
Option
>>
getDataModelParentProperty
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
)
{
List
<
Option
>
list
=
new
ArrayList
<>();
liteModelService
.
getDataModel
(
modelid
).
getAllProperty
().
forEach
(
property
->
{
Option
option
=
new
Option
().
setId
(
property
.
getPropertyName
()).
setLabel
(
property
.
getEntityModel
().
getLogicName
()+
"["
+
property
.
getPropertyName
()+
"]"
);
list
.
add
(
option
);
});
return
ResponseEntity
.
ok
(
list
);
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/lite/datamodels/{modelid}/allpropertys/{propertyname}/fields"
})
public
ResponseEntity
<
List
<
Option
>>
getDataModelField
(
@PathVariable
(
name
=
"modelid"
,
required
=
false
)
String
modelid
,
@PathVariable
(
name
=
"propertyname"
,
required
=
false
)
String
propertyname
,
@PathVariable
(
name
=
"fieldname"
,
required
=
false
)
String
fieldname
)
{
List
<
Option
>
list
=
new
ArrayList
<>();
Property
property
=
liteModelService
.
getDataModel
(
modelid
).
findObjectProperty
(
propertyname
,
"ALL"
);
property
.
getEntityModel
().
getFields
().
forEach
(
field
->
{
Option
option
=
new
Option
().
setId
(
property
.
getPropertyName
()+
"."
+
field
.
getColumnName
()).
setLabel
(
field
.
getComment
()+
"["
+
field
.
getColumnName
()+
"]"
);
list
.
add
(
option
);
});
return
ResponseEntity
.
ok
(
list
);
}
@Autowired
@Autowired
private
IBZDictFeignClient
dictFeignClient
;
private
IBZDictFeignClient
dictFeignClient
;
...
@@ -259,6 +293,34 @@ public class LiteCoreResource {
...
@@ -259,6 +293,34 @@ public class LiteCoreResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteModelService
.
getEntityModel
(
system
,
entity
).
getNesteds
());
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteModelService
.
getEntityModel
(
system
,
entity
).
getNesteds
());
}
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/lite/{system}/entitys/{entity}/get"
)
public
ResponseEntity
<
EntityObj
>
getEntity
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
,
HttpServletRequest
request
)
{
Map
<
String
,
String
[]>
params
=
request
.
getParameterMap
();
EntityObj
entityObj
=
new
EntityObj
();
for
(
String
key
:
params
.
keySet
())
{
entityObj
.
set
(
key
.
toUpperCase
(),
params
.
get
(
key
)[
0
]);
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteDataService
.
get
(
system
,
entity
,
entityObj
));
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/lite/{system}/entitys/{entity}/search{dataset}"
)
public
ResponseEntity
<
List
<
EntityObj
>>
searchEntity
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
,
@PathVariable
(
value
=
"dataset"
,
required
=
false
)
String
dataset
,
@RequestBody
QueryFilter
filter
)
{
if
(
StringUtils
.
isEmpty
(
dataset
))
dataset
=
"BASE"
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteDataService
.
search
(
system
,
entity
,
filter
));
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/lite/{system}/entitys/{entity}/save"
)
public
ResponseEntity
<
Boolean
>
saveEntity
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
,
@RequestBody
EntityObj
entityObj
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteDataService
.
save
(
system
,
entity
,
entityObj
));
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/lite/{system}/entitys/{entity}/batch"
)
public
ResponseEntity
<
Boolean
>
saveEntity
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
,
@RequestBody
List
<
EntityObj
>
list
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteDataService
.
saveBatch
(
system
,
entity
,
list
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{app}/components/{component}"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{app}/components/{component}"
)
public
ResponseEntity
<
JSON
>
getComponent
(
@PathVariable
(
"app"
)
String
app
,
@PathVariable
(
"component"
)
String
component
)
{
public
ResponseEntity
<
JSON
>
getComponent
(
@PathVariable
(
"app"
)
String
app
,
@PathVariable
(
"component"
)
String
component
)
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录