Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
d669ef18
提交
d669ef18
编写于
8月 31, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重置
上级
58416c04
变更
20
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
487 行增加
和
946 行删除
+487
-946
pom.xml
ibzdata-boot/pom.xml
+0
-72
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+4
-4
BaseData.java
...core/src/main/java/cn/ibizlab/core/data/dto/BaseData.java
+33
-2
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+6
-3
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+7
-0
MetaRelationshipModel.java
...java/cn/ibizlab/core/data/lite/MetaRelationshipModel.java
+14
-0
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+6
-4
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+8
-0
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+107
-36
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+100
-0
DynamicMongoContextHolder.java
.../ibizlab/core/data/mongodb/DynamicMongoContextHolder.java
+2
-24
MongoDataRepository.java
.../cn/ibizlab/core/data/repository/MongoDataRepository.java
+44
-34
DataResource.java
...src/main/java/cn/ibizlab/core/data/rest/DataResource.java
+48
-3
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+46
-1
DbDataServiceImpl.java
.../cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
+23
-0
MongoDataServiceImpl.java
.../ibizlab/core/data/service/impl/MongoDataServiceImpl.java
+5
-10
MongoDBConfig.java
.../main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
+29
-0
AuthenticationUser.java
...ain/java/cn/ibizlab/util/security/AuthenticationUser.java
+5
-0
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+0
-627
AppController.java
...til/src/main/java/cn/ibizlab/util/rest/AppController.java
+0
-126
未找到文件。
ibzdata-boot/pom.xml
已删除
100644 → 0
浏览文件 @
58416c04
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<artifactId>
ibzdata
</artifactId>
<groupId>
cn.ibizlab
</groupId>
<version>
1.0.0.0
</version>
</parent>
<artifactId>
ibzdata-boot
</artifactId>
<name>
Ibzdata Dev Monolithic Boot
</name>
<description>
Ibzdata Boot
</description>
<dependencies>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-provider-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzdata-app-web
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
<!--由于boot是通过dependency来关联所有子项目,页面和配置等信息都存在与子项目中,
所以您在对boot进行打包前,需要先将子项目install到maven仓库,以确保boot可以正常引用所有完整的子项目-->
<profiles>
<profile>
<id>
boot
</id>
<build>
<resources>
<resource>
<directory>
${basedir}/src/main/resources
</directory>
<includes>
<include>
**/**
</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<finalName>
ibzdata
</finalName>
<jvmArguments>
-Dfile.encoding=UTF-8
</jvmArguments>
<mainClass>
cn.ibizlab.DevBootApplication
</mainClass>
<outputDirectory>
../
</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
d669ef18
...
@@ -218,10 +218,10 @@ public class DOModel implements Serializable {
...
@@ -218,10 +218,10 @@ public class DOModel implements Serializable {
if
(
this
.
getSchema
()!=
null
&&(
"mongodb"
.
equals
(
name
)))
if
(
this
.
getSchema
()!=
null
&&(
"mongodb"
.
equals
(
name
)))
{
{
POSchema
d
efaultPOSchema
=
TransUtils
.
PojoSchema2
PO
(
this
.
getSchema
());
POSchema
d
ocumentPOSchema
=
TransUtils
.
PojoSchema2Document
PO
(
this
.
getSchema
());
if
(
d
efaul
tPOSchema
!=
null
)
{
if
(
d
ocumen
tPOSchema
!=
null
)
{
poSchemas
.
put
(
"mongodb"
,
defaul
tPOSchema
);
poSchemas
.
put
(
name
,
documen
tPOSchema
);
return
d
efaul
tPOSchema
;
return
d
ocumen
tPOSchema
;
}
}
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/BaseData.java
浏览文件 @
d669ef18
...
@@ -222,18 +222,49 @@ public class BaseData extends DataObj
...
@@ -222,18 +222,49 @@ public class BaseData extends DataObj
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
BaseData
>
getParentData
()
public
Map
<
String
,
BaseData
>
getParentData
s
()
{
{
return
parentDatas
;
return
parentDatas
;
}
}
public
BaseData
setParentDatas
(
Map
<
String
,
BaseData
>
parentDatas
)
{
this
.
parentDatas
=
parentDatas
;
return
this
;
}
public
BaseData
addParentData
(
String
entity
,
Map
data
)
{
if
(
StringUtils
.
isEmpty
(
entity
)||
ObjectUtils
.
isEmpty
(
data
))
return
this
;
if
(
parentDatas
==
null
)
parentDatas
=
new
LinkedHashMap
<>();
BaseData
parent
=
null
;
if
(
parentDatas
.
containsKey
(
entity
))
parent
=
parentDatas
.
get
(
entity
);
else
{
parent
=
new
BaseData
();
parentDatas
.
put
(
entity
,
parent
);
}
parent
.
setAll
(
data
);
return
this
;
}
public
BaseData
addParent
(
String
entity
,
String
key
)
public
BaseData
addParent
(
String
entity
,
String
key
)
{
{
if
(
StringUtils
.
isEmpty
(
entity
)||
StringUtils
.
isEmpty
(
key
))
if
(
StringUtils
.
isEmpty
(
entity
)||
StringUtils
.
isEmpty
(
key
))
return
this
;
return
this
;
if
(
parentDatas
==
null
)
if
(
parentDatas
==
null
)
parentDatas
=
new
LinkedHashMap
<>();
parentDatas
=
new
LinkedHashMap
<>();
parentDatas
.
put
(
entity
,
new
BaseData
().
setKey
(
key
));
BaseData
parent
=
null
;
if
(
parentDatas
.
containsKey
(
entity
))
parent
=
parentDatas
.
get
(
entity
);
else
{
parent
=
new
BaseData
();
parentDatas
.
put
(
entity
,
parent
);
}
parent
.
setKey
(
key
);
return
this
;
return
this
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
d669ef18
...
@@ -247,7 +247,8 @@ public class DynamicModelService {
...
@@ -247,7 +247,8 @@ public class DynamicModelService {
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
metaFieldModel
.
setRefFieldId
(
linkDEField
.
getRelatedPSDEField
().
getId
())
metaFieldModel
.
setRefFieldId
(
linkDEField
.
getRelatedPSDEField
().
getId
())
.
setRefFieldName
(
linkDEField
.
getRelatedPSDEField
().
getName
()).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
.
setRefFieldName
(
linkDEField
.
getRelatedPSDEField
().
getName
()).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
.
setRelationName
(
linkDEField
.
getPSDER
().
getName
()).
setRelationCodeName
(
linkDEField
.
getPSDER
().
getCodeName
()).
setRefEntityName
(
linkDEField
.
getPSDER
().
getMajorPSDataEntity
().
getName
());
.
setRelationName
(
linkDEField
.
getPSDER
().
getName
()).
setRelationCodeName
(
linkDEField
.
getPSDER
().
getCodeName
()).
setRefEntityName
(
linkDEField
.
getPSDER
().
getMajorPSDataEntity
().
getName
())
.
setRefFieldCodeName
(
linkDEField
.
getRelatedPSDEField
().
getCodeName
());
}
}
if
(!
ObjectUtils
.
isEmpty
(
defield
.
getAllPSDEFSearchModes
()))
if
(!
ObjectUtils
.
isEmpty
(
defield
.
getAllPSDEFSearchModes
()))
...
@@ -277,7 +278,8 @@ public class DynamicModelService {
...
@@ -277,7 +278,8 @@ public class DynamicModelService {
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setRefEntityCodeName
(
der
.
getMajorPSDataEntity
().
getCodeName
())
.
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
()).
setEntityCodeName
(
dataEntity
.
getCodeName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
if
(
der
instanceof
IPSDER1N
)
...
@@ -307,7 +309,8 @@ public class DynamicModelService {
...
@@ -307,7 +309,8 @@ public class DynamicModelService {
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
MetaRelationshipModel
metaRel
=
new
MetaRelationshipModel
();
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
metaRel
.
setId
(
der
.
getId
()).
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setRefEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setRefEntityName
(
der
.
getMajorPSDataEntity
().
getName
()).
setRefEntityCodeName
(
der
.
getMajorPSDataEntity
().
getCodeName
())
.
setEntityId
(
dataEntity
.
getId
()).
setEntityName
(
dataEntity
.
getName
()).
setEntityCodeName
(
dataEntity
.
getCodeName
()).
setNestedName
(
der
.
getMinorCodeName
())
.
setSystemId
(
iPSSystem
.
getCodeName
());
.
setSystemId
(
iPSSystem
.
getCodeName
());
if
(
der
instanceof
IPSDER1N
)
if
(
der
instanceof
IPSDER1N
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
d669ef18
...
@@ -115,6 +115,13 @@ public class MetaFieldModel {
...
@@ -115,6 +115,13 @@ public class MetaFieldModel {
@JsonProperty
(
"ref_field_name"
)
@JsonProperty
(
"ref_field_name"
)
@ApiModelProperty
(
"引用属性名称"
)
@ApiModelProperty
(
"引用属性名称"
)
private
String
refFieldName
;
private
String
refFieldName
;
/**
* 引用属性代码名称
*/
@JSONField
(
name
=
"ref_field_code_name"
)
@JsonProperty
(
"ref_field_code_name"
)
@ApiModelProperty
(
"引用属性代码名称"
)
private
String
refFieldCodeName
;
/**
/**
* 引用关系标识
* 引用关系标识
*/
*/
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaRelationshipModel.java
浏览文件 @
d669ef18
...
@@ -69,6 +69,13 @@ public class MetaRelationshipModel implements Serializable {
...
@@ -69,6 +69,13 @@ public class MetaRelationshipModel implements Serializable {
@JsonProperty
(
"entity_name"
)
@JsonProperty
(
"entity_name"
)
@ApiModelProperty
(
"实体名称"
)
@ApiModelProperty
(
"实体名称"
)
private
String
entityName
;
private
String
entityName
;
/**
* 实体代码名称
*/
@JSONField
(
name
=
"entity_code_name"
)
@JsonProperty
(
"entity_code_name"
)
@ApiModelProperty
(
"实体代码名称"
)
private
String
entityCodeName
;
/**
/**
* 引用实体标识
* 引用实体标识
*/
*/
...
@@ -83,6 +90,13 @@ public class MetaRelationshipModel implements Serializable {
...
@@ -83,6 +90,13 @@ public class MetaRelationshipModel implements Serializable {
@JsonProperty
(
"ref_entity_name"
)
@JsonProperty
(
"ref_entity_name"
)
@ApiModelProperty
(
"引用实体名称"
)
@ApiModelProperty
(
"引用实体名称"
)
private
String
refEntityName
;
private
String
refEntityName
;
/**
* 引用实体代码名称
*/
@JSONField
(
name
=
"ref_entity_code_name"
)
@JsonProperty
(
"ref_entity_code_name"
)
@ApiModelProperty
(
"引用实体代码名称"
)
private
String
refEntityCodeName
;
/**
/**
* 嵌套代码名称
* 嵌套代码名称
*/
*/
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
d669ef18
...
@@ -742,9 +742,10 @@ public class POSchema {
...
@@ -742,9 +742,10 @@ public class POSchema {
for
(
Map
.
Entry
<
String
,
String
>
entry
:
resultMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
resultMap
.
entrySet
())
{
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
entry
.
getValue
()))
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
entry
.
getValue
()))
{
{
Object
obj
=
source
.
get
(
entry
.
getKey
());
Object
obj
=
source
.
get
(
entry
.
getKey
()
.
toLowerCase
()
);
source
.
remove
(
entry
.
getKey
().
toLowerCase
());
source
.
remove
(
entry
.
getKey
().
toLowerCase
());
source
.
set
(
entry
.
getValue
().
toLowerCase
(),
obj
);
if
(
obj
!=
null
||
source
.
get
(
entry
.
getValue
().
toLowerCase
())==
null
)
source
.
set
(
entry
.
getValue
().
toLowerCase
(),
obj
);
}
}
}
}
return
source
;
return
source
;
...
@@ -769,9 +770,10 @@ public class POSchema {
...
@@ -769,9 +770,10 @@ public class POSchema {
for
(
Map
.
Entry
<
String
,
String
>
entry
:
resultMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
resultMap
.
entrySet
())
{
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
entry
.
getValue
()))
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
entry
.
getValue
()))
{
{
Object
obj
=
source
.
get
(
entry
.
getValue
());
Object
obj
=
source
.
get
(
entry
.
getValue
()
.
toLowerCase
()
);
source
.
remove
(
entry
.
getValue
().
toLowerCase
());
source
.
remove
(
entry
.
getValue
().
toLowerCase
());
source
.
set
(
entry
.
getKey
().
toLowerCase
(),
obj
);
if
(
obj
!=
null
||
source
.
get
(
entry
.
getKey
().
toLowerCase
())==
null
)
source
.
set
(
entry
.
getKey
().
toLowerCase
(),
obj
);
}
}
}
}
return
source
;
return
source
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
浏览文件 @
d669ef18
...
@@ -160,6 +160,14 @@ public class PojoOption extends DataObj
...
@@ -160,6 +160,14 @@ public class PojoOption extends DataObj
return
this
.
set
(
"ref_field_name"
,
refFieldName
);
return
this
.
set
(
"ref_field_name"
,
refFieldName
);
}
}
public
String
getRefFieldCodeName
()
{
return
this
.
getStringValue
(
"ref_field_code_name"
);
}
public
PojoOption
setRefFieldCodeName
(
String
refFieldCodeName
)
{
return
this
.
set
(
"ref_field_code_name"
,
refFieldCodeName
);
}
public
Boolean
isKeyField
()
{
public
Boolean
isKeyField
()
{
return
this
.
getBooleanValue
(
"key_field"
);
return
this
.
getBooleanValue
(
"key_field"
);
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
d669ef18
...
@@ -39,6 +39,7 @@ public class PojoSchema {
...
@@ -39,6 +39,7 @@ public class PojoSchema {
@JSONField
(
ordinal
=
1
)
@JSONField
(
ordinal
=
1
)
private
String
id
;
private
String
id
;
...
@@ -210,64 +211,102 @@ public class PojoSchema {
...
@@ -210,64 +211,102 @@ public class PojoSchema {
return
this
;
return
this
;
}
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
PojoSchema
>
references
;
private
List
<
PojoSchema
>
references
;
public
List
<
PojoSchema
>
getReferences
()
{
if
(
references
==
null
)
{
references
=
new
ArrayList
<>();
getProperties
().
values
().
forEach
(
prop
->{
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
references
.
add
(
prop
);
}
});
}
return
references
;
}
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
PojoSchema
>
getReferences
()
private
Map
<
String
,
PojoSchema
>
referenceMap
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
PojoSchema
>
getReferenceMap
()
{
{
if
(
reference
s
==
null
)
if
(
reference
Map
==
null
)
{
{
reference
s
=
new
LinkedHashMap
<>();
reference
Map
=
new
LinkedHashMap
<>();
getProperties
().
keySet
().
forEach
(
key
->{
getProperties
().
keySet
().
forEach
(
key
->{
PojoSchema
prop
=
getProperties
().
get
(
key
);
PojoSchema
prop
=
getProperties
().
get
(
key
);
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
reference
s
.
put
(
key
,
prop
);
reference
Map
.
put
(
key
,
prop
);
if
(!
key
.
equals
(
key
.
toLowerCase
()))
if
(!
key
.
equals
(
key
.
toLowerCase
()))
reference
s
.
put
(
key
.
toLowerCase
(),
prop
);
reference
Map
.
put
(
key
.
toLowerCase
(),
prop
);
reference
s
.
put
(
prop
.
getOptions
().
getRelationName
(),
prop
);
reference
Map
.
put
(
prop
.
getOptions
().
getRelationName
(),
prop
);
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getEntityName
()))
{
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getEntityName
()))
{
if
(!
reference
s
.
containsKey
(
prop
.
getOptions
().
getEntityName
()))
if
(!
reference
Map
.
containsKey
(
prop
.
getOptions
().
getEntityName
()))
reference
s
.
put
(
prop
.
getOptions
().
getEntityName
(),
prop
);
reference
Map
.
put
(
prop
.
getOptions
().
getEntityName
(),
prop
);
if
(!
reference
s
.
containsKey
(
prop
.
getOptions
().
getEntityName
().
toLowerCase
()))
if
(!
reference
Map
.
containsKey
(
prop
.
getOptions
().
getEntityName
().
toLowerCase
()))
reference
s
.
put
(
prop
.
getOptions
().
getEntityName
().
toLowerCase
(),
prop
);
reference
Map
.
put
(
prop
.
getOptions
().
getEntityName
().
toLowerCase
(),
prop
);
}
}
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getCodeName
()))
{
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getCodeName
()))
{
if
(!
reference
s
.
containsKey
(
prop
.
getOptions
().
getCodeName
()))
if
(!
reference
Map
.
containsKey
(
prop
.
getOptions
().
getCodeName
()))
reference
s
.
put
(
prop
.
getOptions
().
getCodeName
(),
prop
);
reference
Map
.
put
(
prop
.
getOptions
().
getCodeName
(),
prop
);
if
(!
reference
s
.
containsKey
(
prop
.
getOptions
().
getCodeName
().
toLowerCase
()))
if
(!
reference
Map
.
containsKey
(
prop
.
getOptions
().
getCodeName
().
toLowerCase
()))
reference
s
.
put
(
prop
.
getOptions
().
getCodeName
().
toLowerCase
(),
prop
);
reference
Map
.
put
(
prop
.
getOptions
().
getCodeName
().
toLowerCase
(),
prop
);
}
}
String
pluralize
=
Inflector
.
getInstance
().
pluralize
(
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getCodeName
())?
prop
.
getOptions
().
getEntityName
():
prop
.
getOptions
().
getCodeName
()).
toLowerCase
();
String
pluralize
=
Inflector
.
getInstance
().
pluralize
(
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getCodeName
())?
prop
.
getOptions
().
getEntityName
():
prop
.
getOptions
().
getCodeName
()).
toLowerCase
();
if
(!
reference
s
.
containsKey
(
pluralize
))
if
(!
reference
Map
.
containsKey
(
pluralize
))
reference
s
.
put
(
pluralize
,
prop
);
reference
Map
.
put
(
pluralize
,
prop
);
}
}
});
});
}
}
return
reference
s
;
return
reference
Map
;
}
}
public
PojoSchema
getRefSchema
(
String
tag
)
public
PojoSchema
getRefSchema
(
String
tag
)
{
{
if
(
getReference
s
()!=
null
)
if
(
getReference
Map
()!=
null
)
{
{
return
this
.
getReference
s
().
get
(
tag
);
return
this
.
getReference
Map
().
get
(
tag
);
}
}
return
null
;
return
null
;
}
}
public
Map
<
String
,
PojoSchema
>
getRefProperties
()
{
Map
<
String
,
PojoSchema
>
refProperties
=
new
LinkedHashMap
<>();
if
(
this
.
getOwner
()!=
null
&&
Type
.
object
.
getCode
().
equalsIgnoreCase
(
this
.
getType
())&&
this
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
this
.
getOptions
().
getRelationName
())))
{
this
.
getOwner
().
getProperties
().
entrySet
().
forEach
(
entry
->
{
String
key
=
entry
.
getKey
();
if
(
key
.
equals
(
this
.
getName
()))
return
;
PojoSchema
prop
=
entry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
this
.
getOptions
().
getRelationName
()))
{
refProperties
.
put
(
key
,
prop
);
}
});
}
return
refProperties
;
}
public
Map
<
String
,
PojoSchema
>
getRefProperties
(
String
tag
)
public
Map
<
String
,
PojoSchema
>
getRefProperties
(
String
tag
)
{
{
Map
<
String
,
PojoSchema
>
refProperties
=
new
LinkedHashMap
<>();
Map
<
String
,
PojoSchema
>
refProperties
=
new
LinkedHashMap
<>();
PojoSchema
refSchema
=
this
.
getRefSchema
(
tag
);
PojoSchema
refSchema
=
this
.
getRefSchema
(
tag
);
if
(
refSchema
!=
null
)
if
(
refSchema
!=
null
)
{
{
getProperties
().
keySet
().
forEach
(
key
->
{
getProperties
().
entrySet
().
forEach
(
entry
->
{
String
key
=
entry
.
getKey
();
if
(
key
.
equals
(
refSchema
.
getName
()))
if
(
key
.
equals
(
refSchema
.
getName
()))
return
;
return
;
PojoSchema
prop
=
getProperties
().
get
(
key
);
PojoSchema
prop
=
entry
.
getValue
(
);
if
(
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
refSchema
.
getOptions
().
getRelationName
()))
if
(
prop
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
refSchema
.
getOptions
().
getRelationName
()))
{
{
refProperties
.
put
(
key
,
prop
);
refProperties
.
put
(
key
,
prop
);
...
@@ -565,7 +604,7 @@ public class PojoSchema {
...
@@ -565,7 +604,7 @@ public class PojoSchema {
if
(
unionKeys
.
size
()!=
keys
.
length
&&
keyMap
.
size
()>
1
)
if
(
unionKeys
.
size
()!=
keys
.
length
&&
keyMap
.
size
()>
1
)
return
null
;
return
null
;
if
(
unionKeys
.
size
()
!
=
keys
.
length
)
if
(
unionKeys
.
size
()
=
=
keys
.
length
)
{
{
int
i
=
0
;
int
i
=
0
;
for
(
PojoSchema
keySchema:
unionKeys
.
values
())
for
(
PojoSchema
keySchema:
unionKeys
.
values
())
...
@@ -592,36 +631,68 @@ public class PojoSchema {
...
@@ -592,36 +631,68 @@ public class PojoSchema {
public
BaseData
fillParentKey
(
BaseData
data
)
public
BaseData
fillParentKey
(
BaseData
data
)
{
{
if
(
ObjectUtils
.
isEmpty
(
data
.
getParentData
()))
this
.
getReferences
().
forEach
(
refSchema
->{
Object
obj
=
data
.
get
(
refSchema
.
getName
().
toLowerCase
());
if
(
obj
!=
null
&&
obj
instanceof
Map
)
{
data
.
addParentData
(
refSchema
.
getName
(),(
Map
)
obj
);
}
});
if
(
ObjectUtils
.
isEmpty
(
data
.
getParentDatas
()))
{
{
return
data
;
return
data
;
}
}
data
.
getParentData
().
entrySet
().
forEach
(
entry
->{
Map
<
String
,
BaseData
>
parentDatas
=
new
LinkedHashMap
();
String
refSchema
=
entry
.
getKey
();
data
.
getParentDatas
().
entrySet
().
forEach
(
entry
->{
BaseData
parent
=
entry
.
getValue
();
String
refSchemaKey
=
entry
.
getKey
();
for
(
Map
.
Entry
<
String
,
PojoSchema
>
keyset:
this
.
getRefProperties
(
refSchema
).
entrySet
())
PojoSchema
refSchema
=
this
.
getRefSchema
(
refSchemaKey
);
if
(
refSchema
!=
null
)
{
{
PojoSchema
prop
=
keyset
.
getValue
();
BaseData
parent
=
entry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
)
if
(
parent
.
keySet
().
size
()==
0
)
return
;
Map
<
String
,
PojoSchema
>
refProperties
=
refSchema
.
getRefProperties
();
for
(
Map
.
Entry
<
String
,
PojoSchema
>
entrySet:
refProperties
.
entrySet
())
{
{
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
PojoSchema
prop
=
entrySet
.
getValue
();
data
.
set
(
keyset
.
getKey
().
toLowerCase
(),
parent
.
getKey
());
if
(
prop
.
getOptions
()!=
null
)
break
;
{
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
if
(!
ObjectUtils
.
isEmpty
(
parent
.
getKey
()))
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
getKey
());
if
(
parent
.
keySet
().
size
()==
1
)
break
;
}
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parent
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
get
(
refFieldCodeName
.
toLowerCase
()));
}
}
}
}
}
if
(
refProperties
.
size
()>
1
)
{
if
(!
parentDatas
.
containsKey
(
refSchema
.
getName
()))
parentDatas
.
put
(
refSchema
.
getName
(),
parent
);
else
parentDatas
.
get
(
refSchema
.
getName
()).
setAll
(
parent
);
}
}
});
});
data
.
setParentDatas
(
parentDatas
);
return
data
;
return
data
;
}
}
public
FilterData
fillParentFilter
(
FilterData
data
)
public
FilterData
fillParentFilter
(
FilterData
data
)
{
{
if
(
ObjectUtils
.
isEmpty
(
data
.
getParentData
()))
if
(
ObjectUtils
.
isEmpty
(
data
.
getParentData
s
()))
{
{
return
data
;
return
data
;
}
}
data
.
getParentData
().
entrySet
().
forEach
(
entry
->{
data
.
getParentData
s
().
entrySet
().
forEach
(
entry
->{
String
refSchema
=
entry
.
getKey
();
String
refSchema
=
entry
.
getKey
();
BaseData
parent
=
entry
.
getValue
();
BaseData
parent
=
entry
.
getValue
();
for
(
Map
.
Entry
<
String
,
PojoSchema
>
keyset:
this
.
getRefProperties
(
refSchema
).
entrySet
())
for
(
Map
.
Entry
<
String
,
PojoSchema
>
keyset:
this
.
getRefProperties
(
refSchema
).
entrySet
())
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
d669ef18
...
@@ -323,6 +323,106 @@ public class TransUtils {
...
@@ -323,6 +323,106 @@ public class TransUtils {
public
static
POSchema
PojoSchema2DocumentPO
(
PojoSchema
pojoSchema
)
{
POSchema
poSchema
=
new
POSchema
().
setName
(
pojoSchema
.
getCodeName
().
toLowerCase
()).
setDefaultDataSource
(
pojoSchema
.
getDefaultDataSoruce
())
.
setRemarks
(
pojoSchema
.
getTitle
()).
setLogicVal
(
pojoSchema
.
getOptions
().
getLogicVal
()).
setLogicDelVal
(
pojoSchema
.
getOptions
().
getLogicDelVal
());
for
(
String
name:
pojoSchema
.
getProperties
().
keySet
())
{
PojoSchema
sub
=
pojoSchema
.
getProperties
().
get
(
name
);
String
dataType
=
sub
.
getOptions
().
getDataType
();
Integer
length
=
sub
.
getOptions
().
getDataLength
();
Integer
precision
=
sub
.
getOptions
().
getDataPreci
();
POSchema
.
Column
column
=
new
POSchema
.
Column
().
setName
(
name
).
setAlias
(
name
).
setRemarks
(
sub
.
getTitle
()).
setDefaultValue
(
sub
.
getOptions
().
getDefaultValue
()).
setPredefined
(
sub
.
getOptions
().
getPredefined
()).
setLength
(
length
);
if
(
PojoSchema
.
Type
.
object
.
getCode
().
equals
(
sub
.
getType
())||
PojoSchema
.
Type
.
array
.
getCode
().
equals
(
sub
.
getType
()))
{
if
(!
sub
.
getOptions
().
isPhysicalField
())
continue
;
if
(
StringUtils
.
isEmpty
(
dataType
))
dataType
=
"TEXT"
;
column
.
setType
(
dataType
);
column
.
setLength
(
null
);
}
else
if
(
PojoSchema
.
Type
.
string
.
getCode
().
equals
(
sub
.
getType
())&&(!
StringUtils
.
isEmpty
(
sub
.
getFormat
())))
{
if
(
StringUtils
.
isEmpty
(
dataType
)&&(
sub
.
getFormat
().
indexOf
(
"date"
)>=
0
))
dataType
=
"DATETIME"
;
else
dataType
=
"VARCHAR"
;
column
.
setType
(
dataType
);
}
else
if
(
PojoSchema
.
Type
.
integer
.
getCode
().
equals
(
sub
.
getType
())
)
{
if
(
StringUtils
.
isEmpty
(
dataType
))
dataType
=
"INT"
;
column
.
setType
(
dataType
);
}
else
if
(
PojoSchema
.
Type
.
number
.
getCode
().
equals
(
sub
.
getType
())
)
{
if
(
StringUtils
.
isEmpty
(
dataType
))
dataType
=
"NUMBER"
;
column
.
setType
(
dataType
);
}
else
{
if
(
StringUtils
.
isEmpty
(
dataType
))
dataType
=
"VARCHAR"
;
column
.
setType
(
dataType
);
}
if
(
column
.
isNumber
())
column
.
setPrecision
(
precision
);
if
((
pojoSchema
.
getRequired
()!=
null
&&
pojoSchema
.
getRequired
().
contains
(
name
))||(!
pojoSchema
.
getOptions
().
isNullable
()))
column
.
getConstraints
(
true
).
setNullable
(
false
);
if
(
pojoSchema
.
getKeyMap
()!=
null
&&
pojoSchema
.
getKeyMap
().
containsKey
(
column
.
getName
()))
{
String
primaryKeyName
=
"PK_"
+
poSchema
.
getName
().
toUpperCase
()+
"_"
+
column
.
getName
().
toUpperCase
();
column
.
getConstraints
(
true
).
setPrimaryKey
(
true
).
setPrimaryKeyName
(
primaryKeyName
);
}
if
(
sub
.
getOptions
().
isLogicValidField
())
{
if
(!
StringUtils
.
isEmpty
(
pojoSchema
.
getOptions
().
getLogicVal
()))
column
.
setDefaultValue
(
pojoSchema
.
getOptions
().
getLogicVal
());
else
column
.
setDefaultValue
(
"1"
);
}
if
(!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getSearchModes
()))
column
.
putSearchModes
(
sub
.
getOptions
().
getSearchModes
());
if
(
"PICKUP"
.
equals
(
sub
.
getOptions
().
getFieldType
())&&
sub
.
getOptions
().
isPhysicalField
())
{
PojoSchema
relationshipModel
=
pojoSchema
.
getRefSchema
(
sub
.
getOptions
().
getRelationName
());
String
fkName
=
sub
.
getOptions
().
getRelationName
().
toUpperCase
();
if
((!
StringUtils
.
isEmpty
(
relationshipModel
.
getOptions
().
getRefTableName
()))&&(!
StringUtils
.
isEmpty
(
fkName
)))
{
column
.
getConstraints
(
true
).
setReferencedTableName
(
relationshipModel
.
getOptions
().
getRefTableName
()).
setReferencedColumnNames
(
sub
.
getOptions
().
getRefFieldName
()).
setForeignKeyName
(
fkName
);
poSchema
.
addForeignKeyConstraint
(
new
POSchema
.
ForeignKeyConstraint
().
setConstraintName
(
fkName
).
setBaseTableName
(
poSchema
.
getName
()).
setBaseColumnNames
(
column
.
getName
()).
setReferencedTableName
(
relationshipModel
.
getOptions
().
getRefTableName
()).
setReferencedColumnNames
(
sub
.
getOptions
().
getRefFieldName
()));
}
}
else
if
((!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getRelationName
())))
{
PojoSchema
relationshipModel
=
pojoSchema
.
getRefSchema
(
sub
.
getOptions
().
getRelationName
());
if
(
relationshipModel
!=
null
&&(!
StringUtils
.
isEmpty
(
relationshipModel
.
getOptions
().
getTableName
())))
{
column
.
getConstraints
(
true
).
setReferencedTableName
(
relationshipModel
.
getOptions
().
getTableName
())
.
setReferencedColumnNames
(
sub
.
getOptions
().
getRefFieldName
());
}
}
if
(!
sub
.
getOptions
().
isPhysicalField
())
poSchema
.
addTransient
(
column
.
setComputed
(
true
));
else
poSchema
.
addColumn
(
column
);
}
String
defaultQueryScript
=
pojoSchema
.
getOptions
().
getDefaultQueryScript
();
if
(!
StringUtils
.
isEmpty
(
defaultQueryScript
))
poSchema
.
setDefaultQueryScriptSQL
(
defaultQueryScript
);
return
poSchema
;
}
public
static
POSchema
EntityModelModel2PO
(
EntityModel
entityModel
,
String
dsType
)
{
public
static
POSchema
EntityModelModel2PO
(
EntityModel
entityModel
,
String
dsType
)
{
final
String
dataSourceType
=
dsType
.
toLowerCase
();
final
String
dataSourceType
=
dsType
.
toLowerCase
();
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/mongodb/DynamicMongoContextHolder.java
浏览文件 @
d669ef18
...
@@ -15,12 +15,11 @@ import java.util.HashMap;
...
@@ -15,12 +15,11 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
@Component
public
class
DynamicMongoContextHolder
public
class
DynamicMongoContextHolder
{
{
p
rivate
static
final
Map
<
String
,
MongoDbFactory
>
MONGO_CLIENT_DB_FACTORY_MAP
=
new
HashMap
<>();
p
ublic
static
final
Map
<
String
,
MongoDbFactory
>
MONGO_CLIENT_DB_FACTORY_MAP
=
new
HashMap
<>();
p
rivate
static
final
ThreadLocal
<
MongoDbFactory
>
MONGO_DB_FACTORY_THREAD_LOCAL
=
p
ublic
static
final
ThreadLocal
<
MongoDbFactory
>
MONGO_DB_FACTORY_THREAD_LOCAL
=
new
ThreadLocal
<>();
new
ThreadLocal
<>();
public
static
MongoDbFactory
getMongoDbFactory
()
{
public
static
MongoDbFactory
getMongoDbFactory
()
{
...
@@ -50,27 +49,6 @@ public class DynamicMongoContextHolder
...
@@ -50,27 +49,6 @@ public class DynamicMongoContextHolder
MONGO_CLIENT_DB_FACTORY_MAP
.
remove
(
ds
);
MONGO_CLIENT_DB_FACTORY_MAP
.
remove
(
ds
);
}
}
@Value
(
"${spring.data.mongodb.uri:mongodb://localhost:27017/admin}"
)
private
String
uri
;
@PostConstruct
public
void
init
()
{
if
(!
StringUtils
.
isEmpty
(
uri
))
{
addFactory
(
"master"
,
uri
);
}
}
@Bean
(
name
=
"mongoTemplate"
)
@Lazy
(
true
)
public
DynamicMongoTemplate
dynamicMongoTemplate
()
{
Iterator
<
MongoDbFactory
>
iterator
=
MONGO_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
new
DynamicMongoTemplate
(
iterator
.
next
());
}
@Bean
(
name
=
"mongoDbFactory"
)
@Lazy
(
true
)
public
MongoDbFactory
mongoDbFactory
()
{
Iterator
<
MongoDbFactory
>
iterator
=
MONGO_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
iterator
.
next
();
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/
mongodb
/MongoDataRepository.java
→
ibzdata-core/src/main/java/cn/ibizlab/core/data/
repository
/MongoDataRepository.java
浏览文件 @
d669ef18
package
cn
.
ibizlab
.
core
.
data
.
mongodb
;
package
cn
.
ibizlab
.
core
.
data
.
repository
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
@@ -19,26 +21,34 @@ import org.springframework.data.mongodb.core.query.Criteria;
...
@@ -19,26 +21,34 @@ import org.springframework.data.mongodb.core.query.Criteria;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.PostConstruct
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.*
;
import
java.util.*
;
@Slf4j
@Slf4j
@Component
@Component
public
abstract
class
MongoDataRepository
{
public
class
MongoDataRepository
{
@Autowired
@Autowired
@Lazy
@Lazy
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
/**
/**
* 反射获取泛型类型
* 反射获取泛型类型
*
*
* @return
* @return
*/
*/
protected
abstract
Class
<
BaseData
>
getEntityClass
();
protected
Class
<
BaseData
>
getEntityClass
()
{
return
BaseData
.
class
;
}
/**
/**
...
@@ -112,12 +122,12 @@ public abstract class MongoDataRepository {
...
@@ -112,12 +122,12 @@ public abstract class MongoDataRepository {
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
this
.
mongoTemplate
.
save
(
data
,
schema
.
getName
());
this
.
mongoTemplate
.
save
(
data
,
schema
.
getName
());
return
1
;
return
1
;
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
...
@@ -125,31 +135,31 @@ public abstract class MongoDataRepository {
...
@@ -125,31 +135,31 @@ public abstract class MongoDataRepository {
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
this
.
mongoTemplate
.
insert
(
list
,
schema
.
getName
());
this
.
mongoTemplate
.
insert
(
list
,
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
int
updateData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
int
updateData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Update
update
=
getUpdateByObject
(
data
);
Update
update
=
getUpdateByObject
(
data
);
return
(
int
)
this
.
mongoTemplate
.
updateFirst
(
query
,
update
,
schema
.
getName
()).
getModifiedCount
();
return
(
int
)
this
.
mongoTemplate
.
updateFirst
(
query
,
update
,
schema
.
getName
()).
getModifiedCount
();
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
void
updateBathData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
public
void
updateBathData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
list
.
forEach
(
data
->
{
list
.
forEach
(
data
->
{
Query
query
=
getKeyQuery
(
schema
,
data
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Update
update
=
getUpdateByObject
(
data
);
Update
update
=
getUpdateByObject
(
data
);
...
@@ -157,49 +167,49 @@ public abstract class MongoDataRepository {
...
@@ -157,49 +167,49 @@ public abstract class MongoDataRepository {
});
});
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
int
removeData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
int
removeData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
(
int
)
this
.
mongoTemplate
.
remove
(
getKeyQuery
(
schema
,
data
),
schema
.
getName
()).
getDeletedCount
();
return
(
int
)
this
.
mongoTemplate
.
remove
(
getKeyQuery
(
schema
,
data
),
schema
.
getName
()).
getDeletedCount
();
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
int
removeBathData
(
String
ds
,
POSchema
schema
,
List
list
){
public
int
removeBathData
(
String
ds
,
POSchema
schema
,
List
list
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
(
int
)
mongoTemplate
.
remove
(
getKeyQuery
(
schema
,
list
),
schema
.
getName
()).
getDeletedCount
();
return
(
int
)
mongoTemplate
.
remove
(
getKeyQuery
(
schema
,
list
),
schema
.
getName
()).
getDeletedCount
();
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
int
saveData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
int
saveData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Update
update
=
getUpdateByObject
(
data
);
Update
update
=
getUpdateByObject
(
data
);
return
(
int
)
this
.
mongoTemplate
.
upsert
(
query
,
update
,
schema
.
getName
()).
getModifiedCount
();
return
(
int
)
this
.
mongoTemplate
.
upsert
(
query
,
update
,
schema
.
getName
()).
getModifiedCount
();
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
void
saveBatchData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
public
void
saveBatchData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
list
.
forEach
(
data
->
{
list
.
forEach
(
data
->
{
Query
query
=
getKeyQuery
(
schema
,
data
);
Query
query
=
getKeyQuery
(
schema
,
data
);
Update
update
=
getUpdateByObject
(
data
);
Update
update
=
getUpdateByObject
(
data
);
...
@@ -207,40 +217,40 @@ public abstract class MongoDataRepository {
...
@@ -207,40 +217,40 @@ public abstract class MongoDataRepository {
});
});
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
int
countData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
int
countData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
(
int
)
mongoTemplate
.
count
(
getQueryByObject
(
data
),
schema
.
getName
());
return
(
int
)
mongoTemplate
.
count
(
getQueryByObject
(
data
),
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
List
<
BaseData
>
getData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
List
<
BaseData
>
getData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
mongoTemplate
.
find
(
getKeyQuery
(
schema
,
data
),
getEntityClass
(),
schema
.
getName
());
return
mongoTemplate
.
find
(
getKeyQuery
(
schema
,
data
),
getEntityClass
(),
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
List
<
BaseData
>
getBatchData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
public
List
<
BaseData
>
getBatchData
(
String
ds
,
POSchema
schema
,
List
<
BaseData
>
list
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
mongoTemplate
.
find
(
getKeyQuery
(
schema
,
list
),
getEntityClass
(),
schema
.
getName
());
return
mongoTemplate
.
find
(
getKeyQuery
(
schema
,
list
),
getEntityClass
(),
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
...
@@ -249,18 +259,18 @@ public abstract class MongoDataRepository {
...
@@ -249,18 +259,18 @@ public abstract class MongoDataRepository {
public
List
<
BaseData
>
selectData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
public
List
<
BaseData
>
selectData
(
String
ds
,
POSchema
schema
,
BaseData
data
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
return
mongoTemplate
.
find
(
getQueryByObject
(
data
),
getEntityClass
(),
schema
.
getName
());
return
mongoTemplate
.
find
(
getQueryByObject
(
data
),
getEntityClass
(),
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
Page
<
BaseData
>
selectData
(
String
ds
,
POSchema
schema
,
BaseData
data
,
Pageable
page
){
public
Page
<
BaseData
>
selectData
(
String
ds
,
POSchema
schema
,
BaseData
data
,
Pageable
page
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
if
(
page
==
null
)
if
(
page
==
null
)
page
=
PageRequest
.
of
(
0
,
20
,
Sort
.
unsorted
());
page
=
PageRequest
.
of
(
0
,
20
,
Sort
.
unsorted
());
Query
query
=
getQueryByObject
(
data
);
Query
query
=
getQueryByObject
(
data
);
...
@@ -269,26 +279,26 @@ public abstract class MongoDataRepository {
...
@@ -269,26 +279,26 @@ public abstract class MongoDataRepository {
return
new
PageImpl
<
BaseData
>(
list
,
page
,
total
);
return
new
PageImpl
<
BaseData
>(
list
,
page
,
total
);
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
List
<
BaseData
>
queryData
(
String
ds
,
POSchema
schema
,
String
sql
,
FilterData
context
){
public
List
<
BaseData
>
queryData
(
String
ds
,
POSchema
schema
,
String
sql
,
FilterData
context
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
Query
query
=
new
BasicQuery
(
context
.
getQueryBuilder
().
get
().
toString
());
Query
query
=
new
BasicQuery
(
context
.
getQueryBuilder
().
get
().
toString
());
return
mongoTemplate
.
find
(
query
,
BaseData
.
class
,
schema
.
getName
());
return
mongoTemplate
.
find
(
query
,
BaseData
.
class
,
schema
.
getName
());
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
public
Page
<
BaseData
>
queryData
(
String
ds
,
POSchema
schema
,
String
sql
,
FilterData
context
,
Pageable
page
){
public
Page
<
BaseData
>
queryData
(
String
ds
,
POSchema
schema
,
String
sql
,
FilterData
context
,
Pageable
page
){
try
try
{
{
Dynamic
DataSource
ContextHolder
.
push
(
ds
);
Dynamic
Mongo
ContextHolder
.
push
(
ds
);
if
(
page
==
null
)
if
(
page
==
null
)
page
=
context
.
getPageable
();
page
=
context
.
getPageable
();
else
else
...
@@ -299,7 +309,7 @@ public abstract class MongoDataRepository {
...
@@ -299,7 +309,7 @@ public abstract class MongoDataRepository {
return
new
PageImpl
<
BaseData
>(
list
,
page
,
total
);
return
new
PageImpl
<
BaseData
>(
list
,
page
,
total
);
}
}
finally
{
finally
{
Dynamic
DataSource
ContextHolder
.
poll
();
Dynamic
Mongo
ContextHolder
.
poll
();
}
}
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/DataResource.java
浏览文件 @
d669ef18
...
@@ -6,26 +6,29 @@ import cn.ibizlab.core.data.dto.RequestData;
...
@@ -6,26 +6,29 @@ import cn.ibizlab.core.data.dto.RequestData;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.*
;
import
java.util.Map
;
@Slf4j
@Slf4j
@Api
(
tags
=
{
"数据"
})
@Api
(
tags
=
{
"数据"
})
@RestController
(
"api-data"
)
@RestController
(
"api-data"
)
@RequestMapping
({
"/ibiz-repository/{system}/{scope}"
,
"/ibiz-repo/{system}"
,
@RequestMapping
({
"/ibiz-repository/{system}/{scope}"
,
"/ibiz-repo/{system}"
,
"/ibiz-repository/{system}/{scope}/{parentEntity}/{parentKey}"
,
"/ibiz-repo/{system}/parentEntity}/{parentKey}"
,
"/ibiz-repository/{system}/{scope}/{parentEntity}/{parentKey}"
,
"/ibiz-repo/{system}/
{
parentEntity}/{parentKey}"
,
"/ibiz-repository/{system}/{scope}/{parentEntity}/{parentKey}/{parentEntity2}/{parentKey2}"
,
"/ibiz-repo/{system}/{parentEntity}/{parentKey}/{parentEntity2}/{parentKey2}"
})
"/ibiz-repository/{system}/{scope}/{parentEntity}/{parentKey}/{parentEntity2}/{parentKey2}"
,
"/ibiz-repo/{system}/{parentEntity}/{parentKey}/{parentEntity2}/{parentKey2}"
})
public
class
DataResource
public
class
DataResource
{
{
...
@@ -599,5 +602,47 @@ public class DataResource
...
@@ -599,5 +602,47 @@ public class DataResource
}
}
@Value
(
"${ibiz.enablePermissionValid:false}"
)
boolean
enablePermissionValid
;
//是否开启权限校验
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/appdata"
})
public
ResponseEntity
<
JSONObject
>
getAppData
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
systemId
)
{
JSONObject
appData
=
new
JSONObject
()
;
Set
<
String
>
appMenu
=
new
HashSet
();
Set
<
String
>
uniRes
=
new
HashSet
();
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
if
(
enablePermissionValid
){
Collection
<
GrantedAuthority
>
authorities
=
curUser
.
getAuthorities
();
Iterator
it
=
authorities
.
iterator
();
while
(
it
.
hasNext
())
{
GrantedAuthority
authority
=
(
GrantedAuthority
)
it
.
next
();
String
strAuthority
=
authority
.
getAuthority
();
if
(
strAuthority
.
startsWith
(
"UNIRES_"
+
systemId
))
{
uniRes
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
8
));
}
else
if
(
strAuthority
.
startsWith
(
"APPMENU_"
+
systemId
)){
appMenu
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
9
));
}
}
}
Map
<
String
,
Object
>
context
=
new
HashMap
<>();
context
.
putAll
(
curUser
.
getSessionParams
());
context
.
put
(
"srfusername"
,
curUser
.
getPersonname
());
appData
.
put
(
"context"
,
context
);
appData
.
put
(
"unires"
,
uniRes
);
appData
.
put
(
"appmenu"
,
appMenu
);
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
if
(
curUser
.
getSuperuser
()==
1
){
appData
.
put
(
"enablepermissionvalid"
,
false
);
}
else
{
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
appData
);
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
d669ef18
...
@@ -3,12 +3,14 @@ package cn.ibizlab.core.data.service.impl;
...
@@ -3,12 +3,14 @@ package cn.ibizlab.core.data.service.impl;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.dto.*
;
import
cn.ibizlab.core.data.dto.*
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
...
@@ -18,6 +20,7 @@ import org.springframework.util.StringUtils;
...
@@ -18,6 +20,7 @@ import org.springframework.util.StringUtils;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 实体[业务实体] 无存储服务对象接口实现
* 实体[业务实体] 无存储服务对象接口实现
...
@@ -37,6 +40,7 @@ public class BaseDataService implements IDataService {
...
@@ -37,6 +40,7 @@ public class BaseDataService implements IDataService {
private
DbDataServiceImpl
dbProxyService
;
private
DbDataServiceImpl
dbProxyService
;
@Autowired
@Autowired
@Lazy
private
MongoDataServiceImpl
mongoProxyService
;
private
MongoDataServiceImpl
mongoProxyService
;
@Autowired
@Autowired
...
@@ -212,7 +216,48 @@ public class BaseDataService implements IDataService {
...
@@ -212,7 +216,48 @@ public class BaseDataService implements IDataService {
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
{
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
return
getProxyService
(
datasource
).
getDraft
(
model
,
scope
,
datasource
,
et
);
model
.
fillParentKey
(
et
);
if
(!
ObjectUtils
.
isEmpty
(
et
.
getParentDatas
()))
{
et
.
getParentDatas
().
entrySet
().
forEach
(
entry
->{
String
refSchemaKey
=
entry
.
getKey
();
BaseData
parent
=
entry
.
getValue
();
if
(
parent
.
keySet
().
size
()==
0
)
return
;
PojoSchema
refSchema
=
model
.
getSchema
().
getRefSchema
(
refSchemaKey
);
Map
<
String
,
PojoSchema
>
refProperties
=
refSchema
.
getRefProperties
();
if
(
refProperties
.
size
()<=
1
)
return
;
if
((!
StringUtils
.
isEmpty
(
refSchema
.
getName
()))&&(!
StringUtils
.
isEmpty
(
parent
.
getKey
())))
{
String
system
=
StringUtils
.
isEmpty
(
refSchema
.
getSystem
())?
model
.
getSystemId
():
refSchema
.
getSystem
();
try
{
BaseData
parentData
=
this
.
getByMap
(
system
,
scope
,
refSchema
.
getOptions
().
getEntityName
(),
""
,
parent
);
if
(
parentData
!=
null
)
{
refProperties
.
entrySet
().
forEach
(
propEntry
->{
PojoSchema
prop
=
propEntry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
)
{
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parentData
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
et
.
set
(
propEntry
.
getKey
().
toLowerCase
(),
parentData
.
get
(
refFieldCodeName
.
toLowerCase
()));
}
});
}
}
catch
(
Exception
ex
){
log
.
error
(
"填充上级数据失败"
+
refSchema
.
getOptions
().
getEntityName
());}
}
});
}
return
et
;
}
}
@Override
@Override
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
d669ef18
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.*;
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.*;
import
cn.ibizlab.core.data.mapper.DbDataMapper
;
import
cn.ibizlab.core.data.mapper.DbDataMapper
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.core.data.service.ModelService
;
...
@@ -248,6 +249,28 @@ public class DbDataServiceImpl implements IDataService {
...
@@ -248,6 +249,28 @@ public class DbDataServiceImpl implements IDataService {
@Override
@Override
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
public
BaseData
getDraft
(
DOModel
model
,
String
scope
,
String
datasource
,
BaseData
et
)
{
{
model
.
fillParentKey
(
et
);
if
(!
ObjectUtils
.
isEmpty
(
et
.
getParentDatas
()))
{
et
.
getParentDatas
().
entrySet
().
forEach
(
entry
->{
String
refSchemaKey
=
entry
.
getKey
();
BaseData
parent
=
entry
.
getValue
();
if
(
parent
.
keySet
().
size
()==
0
)
return
;
PojoSchema
refSchema
=
model
.
getSchema
().
getRefSchema
(
refSchemaKey
);
Map
<
String
,
PojoSchema
>
refProperties
=
refSchema
.
getRefProperties
();
if
(
refProperties
.
size
()<=
1
)
return
;
if
((!
StringUtils
.
isEmpty
(
refSchema
.
getName
()))&&(!
StringUtils
.
isEmpty
(
parent
.
getKey
())))
{
}
});
}
return
et
;
return
et
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoDataServiceImpl.java
浏览文件 @
d669ef18
...
@@ -7,16 +7,14 @@ import cn.ibizlab.core.data.dto.RequestData;
...
@@ -7,16 +7,14 @@ import cn.ibizlab.core.data.dto.RequestData;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.DSLink
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.
mongodb
.MongoDataRepository
;
import
cn.ibizlab.core.data.
repository
.MongoDataRepository
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -24,9 +22,7 @@ import org.springframework.util.StringUtils;
...
@@ -24,9 +22,7 @@ import org.springframework.util.StringUtils;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 实体[业务实体] 无存储服务对象接口实现
* 实体[业务实体] 无存储服务对象接口实现
...
@@ -38,7 +34,6 @@ public class MongoDataServiceImpl implements IDataService
...
@@ -38,7 +34,6 @@ public class MongoDataServiceImpl implements IDataService
@Autowired
@Autowired
@Lazy
private
MongoDataRepository
mongoDataRepository
;
private
MongoDataRepository
mongoDataRepository
;
...
@@ -184,7 +179,7 @@ public class MongoDataServiceImpl implements IDataService
...
@@ -184,7 +179,7 @@ public class MongoDataServiceImpl implements IDataService
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
List
<
BaseData
>
list
=
mongoDataRepository
.
getData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
List
<
BaseData
>
list
=
mongoDataRepository
.
getData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
return
poSchema
.
trans
(
list
.
get
(
0
));
return
poSchema
.
trans
(
list
.
get
(
0
));
...
@@ -223,7 +218,7 @@ public class MongoDataServiceImpl implements IDataService
...
@@ -223,7 +218,7 @@ public class MongoDataServiceImpl implements IDataService
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
List
<
BaseData
>
list
=
mongoDataRepository
.
getData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
List
<
BaseData
>
list
=
mongoDataRepository
.
getData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
if
(
ObjectUtils
.
isEmpty
(
list
)||
list
.
size
()>
1
)
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
throw
new
BadRequestAlertException
(
"未找到数据"
,
model
.
getName
(),
key
.
toString
());
return
poSchema
.
trans
(
list
.
get
(
0
));
return
poSchema
.
trans
(
list
.
get
(
0
));
...
@@ -245,7 +240,7 @@ public class MongoDataServiceImpl implements IDataService
...
@@ -245,7 +240,7 @@ public class MongoDataServiceImpl implements IDataService
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
int
cnt
=
mongoDataRepository
.
countData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
int
cnt
=
mongoDataRepository
.
countData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
));
return
cnt
==
1
;
return
cnt
==
1
;
}
}
...
@@ -300,7 +295,7 @@ public class MongoDataServiceImpl implements IDataService
...
@@ -300,7 +295,7 @@ public class MongoDataServiceImpl implements IDataService
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
if
(
StringUtils
.
isEmpty
(
datasource
))
datasource
=
model
.
getDefaultDataSource
();
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
DSLink
link
=
dsSettingService
.
getDataSource
(
datasource
);
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
POSchema
poSchema
=
model
.
getPOSchema
(
link
.
getType
());
Page
<
BaseData
>
pages
=
mongoDataRepository
.
selectData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
),
pageable
);
Page
<
BaseData
>
pages
=
mongoDataRepository
.
selectData
(
link
.
getName
(),
poSchema
,
poSchema
.
trans2PO
(
et
),
pageable
);
poSchema
.
trans
(
pages
.
getContent
());
poSchema
.
trans
(
pages
.
getContent
());
return
pages
;
return
pages
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
浏览文件 @
d669ef18
package
cn
.
ibizlab
.
core
.
util
.
config
;
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoContextHolder
;
import
cn.ibizlab.core.data.mongodb.DynamicMongoTemplate
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.core.convert.*
;
import
org.springframework.data.mongodb.core.convert.*
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.PostConstruct
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.time.*
;
import
java.time.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
@Configuration
@Configuration
public
class
MongoDBConfig
{
public
class
MongoDBConfig
{
@Value
(
"${spring.data.mongodb.uri:mongodb://localhost:27017/admin}"
)
private
String
uri
;
@Bean
@Bean
public
MongoCustomConversions
customConversions
()
{
public
MongoCustomConversions
customConversions
()
{
List
<
Converter
<?,
?>>
converterList
=
new
ArrayList
<>();
List
<
Converter
<?,
?>>
converterList
=
new
ArrayList
<>();
...
@@ -25,6 +38,22 @@ public class MongoDBConfig {
...
@@ -25,6 +38,22 @@ public class MongoDBConfig {
return
new
MongoCustomConversions
(
converterList
);
return
new
MongoCustomConversions
(
converterList
);
}
}
@Bean
(
name
=
"mongoTemplate"
)
@Lazy
public
DynamicMongoTemplate
mongoTemplate
()
{
if
(
DynamicMongoContextHolder
.
MONGO_CLIENT_DB_FACTORY_MAP
.
size
()==
0
)
DynamicMongoContextHolder
.
addFactory
(
"master"
,
uri
);
Iterator
<
MongoDbFactory
>
iterator
=
DynamicMongoContextHolder
.
MONGO_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
new
DynamicMongoTemplate
(
iterator
.
next
());
}
@Bean
(
name
=
"mongoDbFactory"
)
@Lazy
public
MongoDbFactory
mongoDbFactory
()
{
Iterator
<
MongoDbFactory
>
iterator
=
DynamicMongoContextHolder
.
MONGO_CLIENT_DB_FACTORY_MAP
.
values
().
iterator
();
return
iterator
.
next
();
}
public
static
class
JSR310DateConverters
{
public
static
class
JSR310DateConverters
{
private
JSR310DateConverters
()
{
private
JSR310DateConverters
()
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/util/security/AuthenticationUser.java
浏览文件 @
d669ef18
package
cn
.
ibizlab
.
util
.
security
;
package
cn
.
ibizlab
.
util
.
security
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
...
@@ -239,6 +240,10 @@ public class AuthenticationUser implements UserDetails
...
@@ -239,6 +240,10 @@ public class AuthenticationUser implements UserDetails
if
(
userDetails
instanceof
AuthenticationUser
)
{
if
(
userDetails
instanceof
AuthenticationUser
)
{
authuserdetail
=
(
AuthenticationUser
)
userDetails
;
authuserdetail
=
(
AuthenticationUser
)
userDetails
;
}
}
else
if
(
userDetails
!=
null
)
{
authuserdetail
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
userDetails
),
AuthenticationUser
.
class
);
}
else
{
else
{
authuserdetail
=
new
AuthenticationUser
();
authuserdetail
=
new
AuthenticationUser
();
}
}
...
...
ibzdata-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
已删除
100644 → 0
浏览文件 @
58416c04
此差异已折叠。
点击以展开。
ibzdata-util/src/main/java/cn/ibizlab/util/rest/AppController.java
已删除
100644 → 0
浏览文件 @
58416c04
package
cn
.
ibizlab
.
util
.
rest
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.service.IBZConfigService
;
import
com.alibaba.fastjson.JSONObject
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
java.util.*
;
@RestController
@RequestMapping
(
value
=
""
)
public
class
AppController
{
@Value
(
"${ibiz.enablePermissionValid:false}"
)
boolean
enablePermissionValid
;
//是否开启权限校验
@Value
(
"${ibiz.systemid:ibzdata}"
)
private
String
systemId
;
@Autowired
private
AuthenticationUserService
userDetailsService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/ibiz-repository/{system}/{scope}/appdata"
,
"/ibiz-repo/{system}/appdata"
,
"/appdata"
})
public
ResponseEntity
<
JSONObject
>
getAppData
()
{
JSONObject
appData
=
new
JSONObject
()
;
Set
<
String
>
appMenu
=
new
HashSet
();
Set
<
String
>
uniRes
=
new
HashSet
();
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
if
(
enablePermissionValid
){
Collection
<
GrantedAuthority
>
authorities
=
curUser
.
getAuthorities
();
Iterator
it
=
authorities
.
iterator
();
while
(
it
.
hasNext
())
{
GrantedAuthority
authority
=
(
GrantedAuthority
)
it
.
next
();
String
strAuthority
=
authority
.
getAuthority
();
if
(
strAuthority
.
startsWith
(
"UNIRES_"
+
systemId
))
{
uniRes
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
8
));
}
else
if
(
strAuthority
.
startsWith
(
"APPMENU_"
+
systemId
)){
appMenu
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
9
));
}
}
}
Map
<
String
,
Object
>
context
=
new
HashMap
<>();
context
.
putAll
(
curUser
.
getSessionParams
());
context
.
put
(
"srfusername"
,
curUser
.
getPersonname
());
appData
.
put
(
"context"
,
context
);
appData
.
put
(
"unires"
,
uniRes
);
appData
.
put
(
"appmenu"
,
appMenu
);
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
if
(
curUser
.
getSuperuser
()==
1
){
appData
.
put
(
"enablepermissionvalid"
,
false
);
}
else
{
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
}
fillAppData
(
appData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
appData
);
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"${ibiz.auth.logoutpath:v7/logout}"
)
public
void
logout
()
{
if
(
AuthenticationUser
.
getAuthenticationUser
()!=
null
){
userDetailsService
.
resetByUsername
(
AuthenticationUser
.
getAuthenticationUser
().
getUsername
());
}
}
@Autowired
private
IBZConfigService
ibzConfigService
;
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
"/configs/{configType}/{targetType}"
)
public
ResponseEntity
<
Boolean
>
saveConfig
(
@PathVariable
(
"configType"
)
String
configType
,
@PathVariable
(
"targetType"
)
String
targetType
,
@RequestBody
JSONObject
config
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
)){
throw
new
BadRequestAlertException
(
"保存配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
}
return
ResponseEntity
.
ok
(
ibzConfigService
.
saveConfig
(
configType
,
targetType
,
userId
,
config
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/configs/{configType}/{targetType}"
)
public
ResponseEntity
<
JSONObject
>
getConfig
(
@PathVariable
(
"configType"
)
String
configType
,
@PathVariable
(
"targetType"
)
String
targetType
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
)){
throw
new
BadRequestAlertException
(
"获取配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
}
return
ResponseEntity
.
ok
(
ibzConfigService
.
getConfig
(
configType
,
targetType
,
userId
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/configs/share/{id}"
)
public
ResponseEntity
<
JSONObject
>
getShareConfig
(
@PathVariable
(
"id"
)
String
id
)
{
JSONObject
jo
=
ibzConfigService
.
getShareConfig
(
id
);
if
(
jo
==
null
)
{
throw
new
BadRequestAlertException
(
"无效的共享配置数据"
,
"IBZConfig"
,
id
);
}
return
ResponseEntity
.
ok
(
jo
);
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/configs/share/{configType}/{targetType}"
)
public
ResponseEntity
<
String
>
shareConfig
(
@PathVariable
(
"configType"
)
String
configType
,
@PathVariable
(
"targetType"
)
String
targetType
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
{
throw
new
BadRequestAlertException
(
"分享配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
}
String
id
=
IdWorker
.
get32UUID
();
ibzConfigService
.
saveShareConfig
(
id
,
configType
,
targetType
,
userId
);
return
ResponseEntity
.
ok
(
id
);
}
/**
* 应用参数扩展
* @param appData
*/
protected
void
fillAppData
(
JSONObject
appData
){
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录