Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
36744792
提交
36744792
编写于
9月 03, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tableschema 接口,模型刷新
上级
5ad47856
变更
11
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
672 行增加
和
238 行删除
+672
-238
pom.xml
ibzdata-core/pom.xml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+2
-2
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+50
-27
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+1
-1
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+1
-1
DataResource.java
...src/main/java/cn/ibizlab/core/data/rest/DataResource.java
+11
-4
PersistentResource.java
...in/java/cn/ibizlab/core/data/rest/PersistentResource.java
+354
-0
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+243
-157
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+1
-43
DbPersistentServiceImpl.java
...izlab/core/data/service/impl/DbPersistentServiceImpl.java
+4
-1
MongoPersistentServiceImpl.java
...ab/core/data/service/impl/MongoPersistentServiceImpl.java
+4
-1
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
36744792
...
...
@@ -175,7 +175,7 @@
<dependency>
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.2.
7
</version>
<version>
1.2.
9
</version>
<exclusions>
<exclusion>
<artifactId>
slf4j-simple
</artifactId>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
36744792
...
...
@@ -216,8 +216,8 @@ public class DOModel implements Serializable {
{
return
poSchemas
.
get
(
name
);
}
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
);
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equals
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
.
toLowerCase
()
);
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equals
IgnoreCase
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
return
poSchemas
.
get
(
vendorProvider
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
36744792
...
...
@@ -88,6 +88,7 @@ public class DynamicModelService {
psModelService
.
setPSModelFolderPath
(
strPSModelFolderPath
);
try
{
iPSSystem
=
psModelService
.
getPSSystem
();
if
(
iPSSystem
==
null
)
throw
new
BadRequestAlertException
(
"加载系统模型错误"
,
"DynamicSystem"
,
system
);
dynamicSystems
.
put
(
system
,
iPSSystem
);
...
...
@@ -252,10 +253,13 @@ public class DynamicModelService {
if
(
defield
.
isLinkDEField
()
&&
defield
instanceof
IPSLinkDEField
)
{
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
metaFieldModel
.
setRefFieldId
(
linkDEField
.
getRelatedPSDEField
().
getId
())
.
setRefFieldName
(
linkDEField
.
getRelatedPSDEField
().
getName
()).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
String
relfieldname
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
relfieldcodename
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
linkDEField
.
getRelatedPSDEField
();
metaFieldModel
.
setRefFieldId
(
relfieldcodename
)
.
setRefFieldName
(
relfieldname
).
setRelationId
(
linkDEField
.
getPSDER
().
getId
())
.
setRelationName
(
linkDEField
.
getPSDER
().
getName
()).
setRelationCodeName
(
linkDEField
.
getPSDER
().
getCodeName
()).
setRefEntityName
(
linkDEField
.
getPSDER
().
getMajorPSDataEntity
().
getName
())
.
setRefFieldCodeName
(
linkDEField
.
getRelatedPSDEField
().
getCodeName
()
);
.
setRefFieldCodeName
(
relfieldcodename
);
}
if
(!
ObjectUtils
.
isEmpty
(
defield
.
getAllPSDEFSearchModes
()))
...
...
@@ -309,8 +313,10 @@ public class DynamicModelService {
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
relfieldname
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
()
);
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
relfieldname
);
metaRel
.
addLookup
(
lookupModel
);
}
...
...
@@ -340,8 +346,10 @@ public class DynamicModelService {
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
relfieldname
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
MetaLookupModel
lookupModel
=
new
MetaLookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
der1n
.
getPSPickupDEField
().
getRelatedPSDEField
().
getName
()
);
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setReffieldname
(
relfieldname
);
metaRel
.
addLookup
(
lookupModel
);
}
...
...
@@ -671,35 +679,50 @@ public class DynamicModelService {
return
initDynamicSystem
(
system
.
getPssystemid
(),
system
.
getDynamicModelPath
());
}
public
Map
<
String
,
Map
<
String
,
Long
>
>
getAllDynamicModelVersion
()
public
synchronized
Map
<
String
,
Long
>
getAllDynamicModelVersion
()
{
Map
<
String
,
Map
<
String
,
Long
>>
ret
=
new
LinkedHashMap
<>();
Set
<
String
>
set
=
new
HashSet
<>();
Map
<
String
,
Long
>
ret
=
new
LinkedHashMap
<>();
this
.
findAllDynamicModel
().
values
().
forEach
(
dstSystemModel
->
{
if
(
ret
.
containsKey
(
dstSystemModel
.
getPssystemid
()))
if
(
set
.
contains
(
dstSystemModel
.
getPssystemid
()))
return
;
if
((!
systemModifyMap
.
containsKey
(
dstSystemModel
.
getPssystemid
()))||
systemModifyMap
.
get
(
dstSystemModel
.
getPssystemid
())<
dstSystemModel
.
getLastModify
())
{
reloadDynamicSystem
(
dstSystemModel
);
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
());
if
(!
dstSystemModel
.
getPssystemid
().
equals
(
dstSystemModel
.
getPssystemid
().
toLowerCase
()))
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
().
toLowerCase
());
}
systemModifyMap
.
put
(
dstSystemModel
.
getPssystemid
(),
dstSystemModel
.
getLastModify
());
Map
<
String
,
Long
>
entities
=
new
LinkedHashMap
<>();
ret
.
put
(
dstSystemModel
.
getPssystemid
(),
entities
);
try
{
this
.
getEntities
(
dstSystemModel
.
getPssystemid
()).
values
().
forEach
(
metaEntityModel
->
{
if
(
entities
.
containsKey
(
metaEntityModel
.
getEntityName
()))
return
;
entities
.
put
(
metaEntityModel
.
getEntityName
(),
dstSystemModel
.
getLastModify
());
});
}
catch
(
Exception
exception
)
{
}
ret
.
putAll
(
getDynamicModelVersion
(
dstSystemModel
));
});
return
ret
;
}
public
synchronized
Map
<
String
,
Long
>
getDynamicModelVersion
(
String
system
)
{
DstSystemModel
dstSystemModel
=
this
.
findAllDynamicModel
().
get
(
system
);
if
(
dstSystemModel
==
null
)
return
getDynamicModelVersion
(
dstSystemModel
);
return
new
LinkedHashMap
<>();
}
public
synchronized
Map
<
String
,
Long
>
getDynamicModelVersion
(
DstSystemModel
dstSystemModel
)
{
if
((!
systemModifyMap
.
containsKey
(
dstSystemModel
.
getPssystemid
()))||
systemModifyMap
.
get
(
dstSystemModel
.
getPssystemid
())<
dstSystemModel
.
getLastModify
())
{
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
());
if
(!
dstSystemModel
.
getPssystemid
().
equals
(
dstSystemModel
.
getPssystemid
().
toLowerCase
()))
this
.
getProxy
().
resetSystem
(
dstSystemModel
.
getPssystemid
().
toLowerCase
());
reloadDynamicSystem
(
dstSystemModel
);
}
systemModifyMap
.
put
(
dstSystemModel
.
getPssystemid
(),
dstSystemModel
.
getLastModify
());
Map
<
String
,
Long
>
entities
=
new
LinkedHashMap
<>();
try
{
this
.
getEntities
(
dstSystemModel
.
getPssystemid
()).
values
().
forEach
(
metaEntityModel
->
{
String
key
=
dstSystemModel
.
getPssystemid
().
concat
(
"."
).
concat
(
metaEntityModel
.
getEntityName
());
if
(
entities
.
containsKey
(
key
))
return
;
entities
.
put
(
key
,
dstSystemModel
.
getLastModify
());
});
}
catch
(
Exception
exception
)
{
}
return
entities
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
36744792
...
...
@@ -846,7 +846,7 @@ public class POSchema {
File
dir
=
path
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
)
,
StandardOpenOption
.
CREATE
);
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
poSchema
));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchema"
,
path
.
toString
());
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
36744792
...
...
@@ -514,7 +514,7 @@ public class PojoSchema {
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
)
,
StandardOpenOption
.
CREATE
);
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"PojoSchema"
,
path
.
toString
());
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/DataResource.java
浏览文件 @
36744792
...
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.FilterData;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -35,6 +36,10 @@ public class DataResource
@Autowired
public
IDataService
dataService
;
@Autowired
public
ModelService
modelService
;
@ApiOperation
(
value
=
"callMethod数据"
,
tags
=
{
"数据"
},
notes
=
"callMethod数据"
)
@RequestMapping
(
method
=
{
RequestMethod
.
GET
},
value
=
{
"/{entity}/call{method}"
,
"/{entity}/{key}/call{method}"
})
public
ResponseEntity
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
...
...
@@ -423,10 +428,9 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestParam
Map
map
)
{
FilterData
context
=
FilterData
.
fromContext
(
map
);
return
doSelect
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
dataquery
,
context
);
return
doSelect
(
system
,
scope
,
parentEntity
,
parentKey
,
parentEntity2
,
parentKey2
,
entity
,
datasource
,
context
);
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,POST,返回body<list>+header<page,total>"
)
...
...
@@ -439,7 +443,6 @@ public class DataResource
@PathVariable
(
name
=
"parentKey2"
,
required
=
false
)
String
parentKey2
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
context
.
addParent
(
parentEntity
,
parentKey
).
addParent
(
parentEntity2
,
parentKey2
);
...
...
@@ -601,7 +604,11 @@ public class DataResource
.
body
(
new
PageImpl
(
baseDatas
.
getContent
(),
context
.
getPageable
(),
baseDatas
.
getTotalElements
()));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/reload"
})
public
ResponseEntity
<
Boolean
>
reload
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
systemId
)
{
modelService
.
refreshDynamicModel
(
systemId
);
return
ResponseEntity
.
ok
(
true
);
}
@Value
(
"${ibiz.enablePermissionValid:false}"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/rest/PersistentResource.java
0 → 100644
浏览文件 @
36744792
package
cn
.
ibizlab
.
core
.
data
.
rest
;
import
cn.ibizlab.core.data.dto.BaseData
;
import
cn.ibizlab.core.data.dto.FilterData
;
import
cn.ibizlab.core.data.service.IPersistentService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
@Slf4j
@Api
(
tags
=
{
"数据"
})
@RestController
(
"api-persistent"
)
@RequestMapping
({
"/ibiz-database/{system}/{datasource}"
})
public
class
PersistentResource
{
@Autowired
public
IPersistentService
persistentService
;
@ApiOperation
(
value
=
"新建数据"
,
tags
=
{
"数据"
},
notes
=
"新建数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}"
,
"/{table}/create"
})
public
ResponseEntity
<
BaseData
>
create
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@Validated
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
create
(
system
,
table
,
datasource
,
baseData
,
get
));
}
@ApiOperation
(
value
=
"批量新建数据"
,
tags
=
{
"数据"
},
notes
=
"批量新建数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/batch"
,
"/{table}/createbatch"
})
public
ResponseEntity
<
List
<
BaseData
>>
createBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
createBatch
(
system
,
table
,
datasource
,
baseDatas
,
get
));
}
@ApiOperation
(
value
=
"获取数据"
,
tags
=
{
"数据"
},
notes
=
"获取数据"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/{table}"
,
"/{table}/{key}"
})
public
ResponseEntity
<
BaseData
>
get
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
Map
map
)
{
BaseData
baseData
=
BaseData
.
fromContext
(
map
);
return
doGet
(
system
,
table
,
datasource
,
key
,
baseData
);
}
@ApiOperation
(
value
=
"获取数据"
,
tags
=
{
"数据"
},
notes
=
"获取数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/get"
,
"/{table}/{key}/get"
})
public
ResponseEntity
<
BaseData
>
doGet
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@Validated
@RequestBody
(
required
=
false
)
BaseData
baseData
)
{
if
(
baseData
==
null
)
{
if
(
StringUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到要获取的键值信息"
,
table
,
null
);
baseData
=
new
BaseData
();
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getByMap
(
system
,
table
,
datasource
,
baseData
.
setKey
(
key
)));
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/getbatch"
})
public
ResponseEntity
<
List
<
BaseData
>>
getBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
List
datas
)
{
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ArrayList
<>());
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getByMapBatch
(
system
,
table
,
datasource
,
datas
));
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
getBatch
(
system
,
table
,
datasource
,
datas
));
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
{
"/{table}"
,
"/{table}/{key}"
})
public
ResponseEntity
<
Boolean
>
remove
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
Map
map
)
{
BaseData
baseData
=
BaseData
.
fromContext
(
map
);
return
doRemove
(
system
,
table
,
datasource
,
key
,
baseData
);
}
@ApiOperation
(
value
=
"删除数据"
,
tags
=
{
"数据"
},
notes
=
"删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/remove"
,
"/{table}/{key}/remove"
})
public
ResponseEntity
<
Boolean
>
doRemove
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestBody
(
required
=
false
)
BaseData
baseData
)
{
if
(
baseData
==
null
)
{
if
(
StringUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到要删除的键值信息"
,
table
,
null
);
baseData
=
new
BaseData
();
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeByMap
(
system
,
table
,
datasource
,
baseData
.
setKey
(
key
)));
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
{
"/{table}/batch"
})
public
ResponseEntity
<
Boolean
>
removeBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
List
datas
)
{
return
doRemoveBatch
(
system
,
table
,
datasource
,
datas
);
}
@ApiOperation
(
value
=
"批量删除数据"
,
tags
=
{
"数据"
},
notes
=
"批量删除数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/removebatch"
})
public
ResponseEntity
<
Boolean
>
doRemoveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
List
datas
)
{
if
(
ObjectUtils
.
isEmpty
(
datas
))
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
else
if
(
datas
.
get
(
0
)
instanceof
Map
)
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeByMapBatch
(
system
,
table
,
datasource
,
datas
));
else
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
removeBatch
(
system
,
table
,
datasource
,
datas
));
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
{
"/{table}"
,
"/{table}/{key}"
})
public
ResponseEntity
<
BaseData
>
update
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
BaseData
baseData
)
{
return
doUpdate
(
system
,
table
,
datasource
,
key
,
get
,
baseData
);
}
@ApiOperation
(
value
=
"更新数据"
,
tags
=
{
"数据"
},
notes
=
"更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/update"
,
"/{table}/{key}/update"
})
public
ResponseEntity
<
BaseData
>
doUpdate
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
update
(
system
,
table
,
datasource
,
baseData
.
setKey
(
key
),
get
));
}
@ApiOperation
(
value
=
"批量更新数据"
,
tags
=
{
"数据"
},
notes
=
"批量更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
{
"/{table}/batch"
})
public
ResponseEntity
<
List
<
BaseData
>>
updateBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
return
doUpdateBatch
(
system
,
table
,
datasource
,
get
,
baseDatas
);
}
@ApiOperation
(
value
=
"批量更新数据"
,
tags
=
{
"数据"
},
notes
=
"批量更新数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/updatebatch"
})
public
ResponseEntity
<
List
<
BaseData
>>
doUpdateBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
updateBatch
(
system
,
table
,
datasource
,
baseDatas
,
get
));
}
@ApiOperation
(
value
=
"检查数据"
,
tags
=
{
"数据"
},
notes
=
"检查数据"
)
@RequestMapping
(
method
=
{
RequestMethod
.
GET
},
value
=
{
"/{table}/checkkey"
,
"/{table}/{key}/checkkey"
})
public
ResponseEntity
<
Boolean
>
checkKey
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
Map
map
)
{
BaseData
baseData
=
BaseData
.
fromContext
(
map
);
return
doCheckKey
(
system
,
table
,
datasource
,
key
,
baseData
);
}
@ApiOperation
(
value
=
"检查数据"
,
tags
=
{
"数据"
},
notes
=
"检查数据"
)
@RequestMapping
(
method
=
{
RequestMethod
.
POST
},
value
=
{
"/{table}/checkkey"
,
"/{table}/{key}/checkkey"
})
public
ResponseEntity
<
Boolean
>
doCheckKey
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestBody
(
required
=
false
)
BaseData
baseData
)
{
if
(
baseData
==
null
)
{
if
(
StringUtils
.
isEmpty
(
key
))
throw
new
BadRequestAlertException
(
"未找到要检查的键值信息"
,
table
,
null
);
baseData
=
new
BaseData
();
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
checkKey
(
system
,
table
,
datasource
,
baseData
.
setKey
(
key
)));
}
@ApiOperation
(
value
=
"保存数据"
,
tags
=
{
"数据"
},
notes
=
"保存数据,自动判断插入和更新"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/save"
,
"/{table}/{key}/save"
})
public
ResponseEntity
<
BaseData
>
save
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
BaseData
baseData
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
save
(
system
,
table
,
datasource
,
baseData
.
setKey
(
key
),
get
));
}
@ApiOperation
(
value
=
"批量保存数据"
,
tags
=
{
"数据"
},
notes
=
"批量保存数据,自动判断插入和更新"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{table}/savebatch"
})
public
ResponseEntity
<
List
<
BaseData
>>
saveBatch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
(
name
=
"get"
,
required
=
false
)
boolean
get
,
@RequestBody
List
<
BaseData
>
baseDatas
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
persistentService
.
saveBatch
(
system
,
table
,
datasource
,
baseDatas
,
get
));
}
@ApiOperation
(
value
=
"Select查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"Select查询数据,GET,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
={
"/{table}/select"
})
public
ResponseEntity
<
List
<
BaseData
>>
select
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestParam
Map
map
)
{
FilterData
context
=
FilterData
.
fromContext
(
map
);
return
doSelect
(
system
,
table
,
datasource
,
context
);
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,POST,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/{table}/select"
})
public
ResponseEntity
<
List
<
BaseData
>>
doSelect
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
if
(
context
.
needPage
())
{
Page
<
BaseData
>
baseDatas
=
persistentService
.
select
(
system
,
table
,
datasource
,
context
,
context
.
getPageable
())
;
List
<
BaseData
>
list
=
baseDatas
.
getContent
();
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
.
header
(
"x-total"
,
String
.
valueOf
(
baseDatas
.
getTotalElements
()))
.
body
(
list
);
}
else
{
List
<
BaseData
>
list
=
persistentService
.
select
(
system
,
table
,
datasource
,
context
)
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
"0"
)
.
header
(
"x-per-page"
,
String
.
valueOf
(
list
.
size
()))
.
header
(
"x-total"
,
String
.
valueOf
(
list
.
size
()))
.
body
(
list
);
}
}
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"数据"
}
,
notes
=
"获取数据集,GET,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
={
"/{table}/fetch{dataset}"
})
public
ResponseEntity
<
List
<
BaseData
>>
fetch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestParam
Map
map
)
{
FilterData
context
=
FilterData
.
fromContext
(
map
);
return
doFetch
(
system
,
table
,
datasource
,
dataset
,
context
);
}
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"数据"
}
,
notes
=
"获取数据集,POST,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/{table}/fetch{dataset}"
})
public
ResponseEntity
<
List
<
BaseData
>>
doFetch
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
if
(
context
.
needPage
())
{
Page
<
BaseData
>
baseDatas
=
persistentService
.
fetch
(
system
,
table
,
datasource
,
dataset
,
context
,
context
.
getPageable
());
List
<
BaseData
>
list
=
baseDatas
.
getContent
();
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
.
header
(
"x-total"
,
String
.
valueOf
(
baseDatas
.
getTotalElements
()))
.
body
(
list
);
}
else
{
List
<
BaseData
>
list
=
persistentService
.
fetch
(
system
,
table
,
datasource
,
dataset
,
context
)
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
"0"
)
.
header
(
"x-per-page"
,
String
.
valueOf
(
list
.
size
()))
.
header
(
"x-total"
,
String
.
valueOf
(
list
.
size
()))
.
body
(
list
);
}
}
@ApiOperation
(
value
=
"获取数据集"
,
tags
=
{
"数据"
}
,
notes
=
"获取数据集,POST,返回body<page,total,list>"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/{table}/search{dataset}"
})
public
ResponseEntity
<
Page
<
BaseData
>>
search
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataset"
,
required
=
true
)
String
dataset
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
Page
<
BaseData
>
baseDatas
=
persistentService
.
fetch
(
system
,
table
,
datasource
,
dataset
,
context
,
context
.
getPageable
())
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
body
(
new
PageImpl
(
baseDatas
.
getContent
(),
context
.
getPageable
(),
baseDatas
.
getTotalElements
()));
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,GET,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
={
"/{table}/query{dataquery}"
})
public
ResponseEntity
<
List
<
BaseData
>>
query
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestParam
Map
map
)
{
FilterData
context
=
FilterData
.
fromContext
(
map
);
return
doQuery
(
system
,
table
,
datasource
,
dataquery
,
context
);
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,POST,返回body<list>+header<page,total>"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/{table}/query{dataquery}"
})
public
ResponseEntity
<
List
<
BaseData
>>
doQuery
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
if
(
context
.
needPage
())
{
Page
<
BaseData
>
baseDatas
=
persistentService
.
query
(
system
,
table
,
datasource
,
dataquery
,
context
,
context
.
getPageable
())
;
List
<
BaseData
>
list
=
baseDatas
.
getContent
();
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageNumber
()))
.
header
(
"x-per-page"
,
String
.
valueOf
(
context
.
getPageable
().
getPageSize
()))
.
header
(
"x-total"
,
String
.
valueOf
(
baseDatas
.
getTotalElements
()))
.
body
(
list
);
}
else
{
List
<
BaseData
>
list
=
persistentService
.
query
(
system
,
table
,
datasource
,
dataquery
,
context
)
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
header
(
"x-page"
,
"0"
)
.
header
(
"x-per-page"
,
String
.
valueOf
(
list
.
size
()))
.
header
(
"x-total"
,
String
.
valueOf
(
list
.
size
()))
.
body
(
list
);
}
}
@ApiOperation
(
value
=
"查询数据"
,
tags
=
{
"数据"
}
,
notes
=
"查询数据,POST,返回body<page,total,list>"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
={
"/{table}/page{dataquery}"
})
public
ResponseEntity
<
Page
<
BaseData
>>
queryPage
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"table"
,
required
=
true
)
String
table
,
@PathVariable
(
name
=
"datasource"
,
required
=
true
)
String
datasource
,
@PathVariable
(
name
=
"dataquery"
,
required
=
true
)
String
dataquery
,
@RequestBody
(
required
=
false
)
FilterData
context
)
{
if
(
context
==
null
)
context
=
new
FilterData
();
Page
<
BaseData
>
baseDatas
=
persistentService
.
fetch
(
system
,
table
,
datasource
,
dataquery
,
context
,
context
.
getPageable
())
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
)
.
body
(
new
PageImpl
(
baseDatas
.
getContent
(),
context
.
getPageable
(),
baseDatas
.
getTotalElements
()));
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
36744792
...
...
@@ -67,44 +67,7 @@ public class ModelService {
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-models'"
)
public
Map
<
String
,
DstSystemModel
>
getAllSystemModels
()
{
Map
<
String
,
DstSystemModel
>
models
=
dynamicService
.
findAllDynamicModel
();
// try
// {
// List<DstSystemModel> liteSystems=liteService.getSysApps();
// if(!ObjectUtils.isEmpty(liteSystems))
// {
// liteSystems.forEach(dstSystemModel->{
// String system=dstSystemModel.getPssystemid();
// if(!models.containsKey(system))
// models.put(system, dstSystemModel);
// if ((!system.toLowerCase().equals(system))&&(!models.containsKey(system.toLowerCase())))
// models.put(system.toLowerCase(), dstSystemModel);
// });
// }
// }
// catch (Exception ex)
// {
// log.error("dst接口访问异常",ex);
// }
getLocalSystemModels
().
values
().
forEach
(
dstSystemModel
->{
String
system
=
dstSystemModel
.
getPssystemid
();
if
(!
models
.
containsKey
(
system
))
models
.
put
(
system
,
dstSystemModel
);
if
((!
system
.
toLowerCase
().
equals
(
system
))&&(!
models
.
containsKey
(
system
.
toLowerCase
())))
models
.
put
(
system
.
toLowerCase
(),
dstSystemModel
);
});
return
models
;
}
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-local'"
)
public
Map
<
String
,
DstSystemModel
>
getLocalSystemModels
()
{
Map
<
String
,
DstSystemModel
>
models
=
null
;
...
...
@@ -123,6 +86,13 @@ public class ModelService {
}
@CacheEvict
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-local'"
)
public
void
resetLocalSystemModels
()
{
}
@CacheEvict
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-local'"
)
public
Map
<
String
,
DstSystemModel
>
LoadLocalSystemModels
()
{
Map
<
String
,
DstSystemModel
>
models
=
new
LinkedHashMap
<>();
...
...
@@ -139,7 +109,7 @@ public class ModelService {
for
(
File
entityDir:
repoDir
.
listFiles
())
{
Path
json
=
Paths
.
get
(
repoDir
.
getAbsolutePath
(),
"domain"
,
repo
Dir
.
getName
()+
".json"
);
Path
json
=
Paths
.
get
(
entityDir
.
getAbsolutePath
(),
"domain"
,
entity
Dir
.
getName
()+
".json"
);
if
(
Files
.
exists
(
json
))
{
try
{
...
...
@@ -161,7 +131,7 @@ public class ModelService {
if
(
models
.
size
()>
0
)
{
try
{
Files
.
write
(
Paths
.
get
(
modelDir
.
getAbsolutePath
(),
"SYSTEM.json"
),
JSON
.
toJSONBytes
(
models
)
,
StandardOpenOption
.
CREATE
);
Files
.
write
(
Paths
.
get
(
modelDir
.
getAbsolutePath
(),
"SYSTEM.json"
),
JSON
.
toJSONBytes
(
models
));
}
catch
(
IOException
e
)
{
}
}
...
...
@@ -172,67 +142,40 @@ public class ModelService {
@Cacheable
(
value
=
"meta-entities"
,
key
=
"'system:keymap-'+#p0"
)
public
Map
<
String
,
String
>
getEntitiyIdsBySystem
(
String
system
)
throws
Exception
{
DstSystemModel
dstSystemModel
=
proxy
.
getAllSystemModels
().
get
(
system
);
if
(
dstSystemModel
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的系统模型"
,
"DstSystem"
,
system
);
system
=
dstSystemModel
.
getPssystemid
();
Map
<
String
,
String
>
entities
=
new
HashMap
<>();
Map
<
String
,
MetaEntityModel
>
entityModels
=
dynamicService
.
getEntities
(
system
);
entityModels
.
entrySet
().
forEach
(
entity
->{
String
id
=
entity
.
getValue
().
getSystemId
().
concat
(
".domain."
).
concat
(
entity
.
getValue
().
getEntityName
());
entities
.
put
(
entity
.
getKey
(),
id
);
});
// try{
// List<MetaEntityModel> liteEntities=liteService.getEntityModel(system);
// if(!ObjectUtils.isEmpty(liteEntities))
// {
// liteEntities.forEach(metaEntityModel->{
// String id=metaEntityModel.getSystemId().concat(".domain.").concat(metaEntityModel.getEntityName());
//
// if(!entities.containsKey(metaEntityModel.getCodeName()))
// entities.put(metaEntityModel.getCodeName(),id);
// if(!entities.containsKey(metaEntityModel.getCodeName().toLowerCase()))
// entities.put(metaEntityModel.getCodeName().toLowerCase(),id);
// if(!entities.containsKey(metaEntityModel.getEntityName())) {
// entities.put(metaEntityModel.getEntityName(), id);
// }
// if(!entities.containsKey(metaEntityModel.getEntityName().toLowerCase())) {
// entities.put(metaEntityModel.getEntityName().toLowerCase(), id);
// }
// String pluralize= Inflector.getInstance().pluralize(metaEntityModel.getCodeName()).toLowerCase();
// if(!entities.containsKey(pluralize)) {
// entities.put(pluralize, id);
// }
//
// });
// }
// }
// catch (Exception ex)
// {
// log.error("dst接口访问异常",ex);
// }
File
dir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
,
"domain"
).
toFile
();
if
(
dir
.
exists
())
DstSystemModel
dstSystemModel
=
dynamicService
.
findAllDynamicModel
().
get
(
system
);
if
(
dstSystemModel
!=
null
)
{
for
(
File
file:
dir
.
listFiles
())
{
if
(!
file
.
getName
().
endsWith
(
".json"
))
continue
;
String
entityName
=
file
.
getName
().
replace
(
".json"
,
""
);
String
id
=
system
.
concat
(
".domain."
).
concat
(
entityName
);
system
=
dstSystemModel
.
getPssystemid
();
Map
<
String
,
MetaEntityModel
>
entityModels
=
dynamicService
.
getEntities
(
system
);
entityModels
.
entrySet
().
forEach
(
entry
->{
String
id
=
entry
.
getValue
().
getSystemId
().
concat
(
".domain."
).
concat
(
entry
.
getValue
().
getEntityName
());
entities
.
put
(
entry
.
getKey
(),
id
);
});
}
else
{
dstSystemModel
=
proxy
.
getLocalSystemModels
().
get
(
system
);
if
(
dstSystemModel
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的系统模型"
,
"DstSystem"
,
system
);
if
(!
entities
.
containsKey
(
entityName
.
toLowerCase
()))
{
entities
.
put
(
entityName
.
toLowerCase
(),
id
);
try
{
PojoSchema
pojoSchema
=
PojoSchema
.
fromPath
(
file
.
toPath
());
entityName
=
pojoSchema
.
getName
();
if
((
StringUtils
.
isEmpty
(
entityName
))&&(!
entities
.
containsKey
(
pojoSchema
.
getName
())))
{
entities
.
put
(
pojoSchema
.
getName
(),
id
);
system
=
dstSystemModel
.
getPssystemid
();
File
repoDir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
).
toFile
();
for
(
File
entityDir:
repoDir
.
listFiles
())
{
Path
json
=
Paths
.
get
(
entityDir
.
getAbsolutePath
(),
"domain"
,
entityDir
.
getName
()+
".json"
);
if
(
Files
.
exists
(
json
))
{
try
{
PojoSchema
pojoSchema
=
PojoSchema
.
fromPath
(
json
);
String
entityName
=
pojoSchema
.
getName
();
String
id
=
system
.
concat
(
".domain."
).
concat
(
entityName
);
entities
.
put
(
entityName
,
id
);
if
(!
entityName
.
equals
(
entityName
.
toLowerCase
()))
{
entities
.
put
(
entityName
.
toLowerCase
(),
id
);
}
String
codeName
=
pojoSchema
.
getCodeName
();
if
((
StringUtils
.
isEmpty
(
codeName
))&&(!
entities
.
containsKey
(
codeName
)))
{
...
...
@@ -244,12 +187,11 @@ public class ModelService {
entities
.
put
(
pluralize
,
id
);
}
}
}
catch
(
Exception
ex
){}
}
}
}
return
entities
;
...
...
@@ -258,26 +200,12 @@ public class ModelService {
public
EntityModel
getEntityModel
(
String
system
,
String
entity
)
{
EntityModel
entityModel
=
null
;
try
{
entityModel
=
dynamicService
.
getDynamicEntity
(
system
,
entity
);
return
dynamicService
.
getDynamicEntity
(
system
,
entity
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"loadDOModel"
,
""
);
}
// try{
// if(entityModel==null)
// entityModel = liteService.getProxyEntityModel(system,entity);
// }
// catch (Exception ex)
// {
// log.error("dst接口访问异常",ex);
// }
return
entityModel
;
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"getEntityModel"
,
""
);
}
public
DOModel
loadDOModel
(
String
system
,
String
entity
)
...
...
@@ -295,16 +223,114 @@ public class ModelService {
doModel
.
addPOSchema
(
dsType
,
poSchema
);
}
}
return
doModel
;
}
}
else
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"loadDOModel"
,
""
);
return
null
;
throw
new
BadRequestAlertException
(
"未找到实体"
+
system
+
"."
+
entity
,
"loadDOModel"
,
""
);
}
@Cacheable
(
value
=
"domodel"
,
key
=
"'row:'+#p0+'.domain.'+#p1"
)
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
doModelService
.
get
(
system
+
".domain."
+
entity
);
String
key
=
system
+
".domain."
+
entity
;
DOModel
doModel
=
null
;
PojoSchema
schema
=
null
;
Path
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
try
{
String
entityTag
=
proxy
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
if
(
StringUtils
.
isEmpty
(
entityTag
))
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
if
(!
key
.
equals
(
entityTag
))
{
String
[]
args
=
entityTag
.
split
(
"[.]"
);
system
=
args
[
0
];
entity
=
args
[
2
];
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
}
}
catch
(
Exception
exception
)
{
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
}
}
if
(!
Files
.
exists
(
storePath
))
{
doModel
=
proxy
.
loadDOModel
(
system
,
entity
);
schema
=
doModel
.
getSchema
();
if
(
schema
!=
null
)
{
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"repository"
,
doModel
.
getName
()+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
}
}
else
{
doModel
=
new
DOModel
();
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
{
doModel
.
setSchema
(
schema
);
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"repository"
,
entity
+
".json"
);
if
(
Files
.
exists
(
poPath
))
{
try
{
doModel
.
setPoSchemas
(
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
poPath
),
StandardCharsets
.
UTF_8
),
new
TypeReference
<
LinkedHashMap
<
String
,
POSchema
>>()
{
}));
}
catch
(
IOException
e
)
{
}
}
}
}
if
(
schema
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
return
doModel
;
}
@Cacheable
(
value
=
"pomodel"
,
key
=
"'row:'+#p0+'._table.'+#p1+'.'+#p2"
)
public
POSchema
getPOSchema
(
String
system
,
String
table
,
String
type
)
{
String
key
=
system
+
"._table."
+
table
.
toUpperCase
()+
"."
+
type
.
toLowerCase
();
if
(
type
.
equalsIgnoreCase
(
"mongodb"
))
{
DOModel
doModel
=
proxy
.
getDOModel
(
system
,
table
);
if
(
doModel
!=
null
&&
doModel
.
getSchema
()!=
null
)
{
return
doModel
.
getPOSchema
(
type
);
}
}
else
{
Path
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
"_table"
,
table
.
toUpperCase
(),
type
.
toUpperCase
()+
".json"
);
if
(
Files
.
exists
(
storePath
))
return
POSchema
.
fromPath
(
storePath
);
String
vendorProvider
=
POSchema
.
provider
.
get
(
type
.
toLowerCase
());
if
(!
type
.
equalsIgnoreCase
(
vendorProvider
))
{
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
"_table"
,
table
.
toUpperCase
(),
POSchema
.
provider
.
get
(
vendorProvider
)+
".json"
);
if
(
Files
.
exists
(
storePath
))
return
POSchema
.
fromPath
(
storePath
);
}
}
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
}
...
...
@@ -332,12 +358,16 @@ public class ModelService {
standardSystem
=
args
[
0
];
standardEntity
=
args
[
2
];
if
(
entry
.
getKey
().
equals
(
standardEntity
)||
entry
.
getKey
().
equals
(
entity
))
{
proxy
.
resetDOModel
(
system
.
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
if
(!
system
.
equals
(
system
.
toLowerCase
()))
proxy
.
resetDOModel
(
system
.
toLowerCase
().
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
proxy
.
resetDOModel
(
standardSystem
.
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
if
(!
standardSystem
.
equals
(
standardSystem
.
toLowerCase
()))
proxy
.
resetDOModel
(
standardSystem
.
toLowerCase
().
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
if
(!
system
.
equals
(
standardSystem
))
{
proxy
.
resetDOModel
(
system
.
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
if
(!
system
.
equals
(
system
.
toLowerCase
()))
proxy
.
resetDOModel
(
system
.
toLowerCase
().
concat
(
".domain."
).
concat
(
entry
.
getKey
()));
}
}
});
}
catch
(
Exception
exception
)
{
...
...
@@ -345,50 +375,64 @@ public class ModelService {
}
@Scheduled
(
cron
=
"0 */1 * * * ?"
)
public
synchronized
void
refreshDynamicModel
()
public
void
refreshDynamicModel
()
{
refreshDynamicModel
(
dynamicService
.
getAllDynamicModelVersion
());
}
public
void
refreshDynamicModel
(
String
system
)
{
dynamicService
.
getAllDynamicModelVersion
().
entrySet
().
forEach
(
entry
->{
String
system
=
entry
.
getKey
();
entry
.
getValue
().
entrySet
().
forEach
(
item
->{
String
entity
=
item
.
getKey
();
Long
systemModify
=
item
.
getValue
();
File
json
=
Paths
.
get
(
this
.
getModelPath
(),
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
).
toFile
();
Long
doModify
=
0L
;
if
(
json
.
exists
())
doModify
=
json
.
lastModified
();
if
(
doModify
<
systemModify
)
refreshDynamicModel
(
dynamicService
.
getDynamicModelVersion
(
system
));
}
private
synchronized
void
refreshDynamicModel
(
Map
<
String
,
Long
>
entities
)
{
Set
<
String
>
changedSystems
=
new
LinkedHashSet
<>();
entities
.
entrySet
().
forEach
(
item
->{
String
arr
[]=
item
.
getKey
().
split
(
"[.]"
);
String
system
=
arr
[
0
];
String
entity
=
arr
[
1
];
Long
systemModify
=
item
.
getValue
();
File
json
=
Paths
.
get
(
this
.
getModelPath
(),
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
).
toFile
();
Long
doModify
=
0L
;
if
(
json
.
exists
())
doModify
=
json
.
lastModified
();
if
(
doModify
<
systemModify
)
{
DOModel
doModel
=
loadDOModel
(
system
,
entity
);
if
(
doModify
==
0L
)
log
.
info
(
"新增模型["
.
concat
(
doModel
.
getName
()).
concat
(
"]"
).
concat
(
doModel
.
getTitle
()));
else
{
resetDOModel
(
system
,
entity
);
log
.
info
(
"刷新模型["
.
concat
(
doModel
.
getName
()).
concat
(
"]"
).
concat
(
doModel
.
getTitle
()).
concat
(
","
).
concat
(
doModify
.
toString
()).
concat
(
"->"
).
concat
(
systemModify
.
toString
()));
}
PojoSchema
schema
=
doModel
.
getSchema
();
if
(
schema
!=
null
)
{
DOModel
doModel
=
loadDOModel
(
system
,
entity
);
if
(
doModify
==
0L
)
log
.
info
(
"新增模型["
.
concat
(
doModel
.
getName
()).
concat
(
"]"
).
concat
(
doModel
.
getTitle
()));
else
{
resetDOModel
(
system
,
entity
);
log
.
info
(
"刷新模型["
.
concat
(
doModel
.
getName
()).
concat
(
"]"
).
concat
(
doModel
.
getTitle
()).
concat
(
","
).
concat
(
doModify
.
toString
()).
concat
(
"->"
).
concat
(
systemModify
.
toString
()));
}
PojoSchema
schema
=
doModel
.
getSchema
();
if
(
schema
!=
null
)
changedSystems
.
add
(
system
);
if
(
doModel
.
getPoSchemas
()!=
null
)
{
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"repository"
,
doModel
.
getName
()+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
doModel
.
getPoSchemas
().
values
().
forEach
(
poSchema
->{
mergeTableSchema
(
doModel
.
getSystemId
(),
poSchema
,
systemModify
);
});
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"repository"
,
doModel
.
getName
()+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()));
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
doModel
.
getPoSchemas
().
values
().
forEach
(
poSchema
->{
mergeTableSchema
(
doModel
.
getSystemId
(),
poSchema
,
systemModify
);
});
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
}
}
});
});
if
(
changedSystems
.
size
()>
0
)
{
LoadLocalSystemModels
();
}
}
public
void
mergeTableSchema
(
String
system
,
POSchema
poSchema
,
Long
timestamp
)
...
...
@@ -401,6 +445,8 @@ public class ModelService {
if
(
Files
.
exists
(
json
)&&
json
.
toFile
().
lastModified
()>
timestamp
)
{
POSchema
old
=
POSchema
.
fromPath
(
json
);
Set
<
String
>
oldex
=
new
HashSet
<>();
Set
<
String
>
newex
=
new
HashSet
<>();
if
(
old
.
getColumns
()!=
null
)
{
old
.
getColumns
().
forEach
(
column
->
{
...
...
@@ -408,6 +454,7 @@ public class ModelService {
if
(
newColumn
==
null
)
{
newSchema
.
addColumn
(
JSON
.
parseObject
(
JSON
.
toJSONString
(
column
),
POSchema
.
Column
.
class
));
oldex
.
add
(
column
.
getName
());
}
else
if
(!
ObjectUtils
.
isEmpty
(
column
.
getSearchModes
()))
{
...
...
@@ -416,6 +463,14 @@ public class ModelService {
});
}
if
(
poSchema
.
getColumns
()!=
null
)
{
poSchema
.
getColumns
().
forEach
(
column
->
{
if
(
old
.
getColumn
(
column
.
getName
())==
null
)
newex
.
add
(
column
.
getName
());
});
}
if
(
old
.
getTransients
()!=
null
)
{
old
.
getTransients
().
forEach
(
column
->
{
...
...
@@ -423,6 +478,7 @@ public class ModelService {
if
(
newColumn
==
null
)
{
newSchema
.
addTransient
(
JSON
.
parseObject
(
JSON
.
toJSONString
(
column
),
POSchema
.
Column
.
class
));
oldex
.
add
(
column
.
getName
());
}
else
if
(!
ObjectUtils
.
isEmpty
(
column
.
getSearchModes
()))
{
...
...
@@ -431,6 +487,14 @@ public class ModelService {
});
}
if
(
poSchema
.
getTransients
()!=
null
)
{
poSchema
.
getTransients
().
forEach
(
column
->
{
if
(
old
.
getColumn
(
column
.
getName
())==
null
)
newex
.
add
(
column
.
getName
());
});
}
if
(!
ObjectUtils
.
isEmpty
(
old
.
getForeignKeyConstraints
()))
{
old
.
getForeignKeyConstraints
().
forEach
(
fk
->{
...
...
@@ -449,6 +513,28 @@ public class ModelService {
});
}
if
(
oldex
.
size
()>
0
&&
newex
.
size
()==
0
)
newSchema
.
setDefaultQueryScript
(
JSON
.
parseObject
(
JSON
.
toJSONString
(
old
.
getDefaultQueryScript
()),
POSchema
.
Segment
.
class
));
else
if
(
oldex
.
size
()>
0
&&
newex
.
size
()>
0
)
{
newSchema
.
refreshColumnMaps
();
String
sql
=
"select "
;
String
cols
=
""
;
if
(
newSchema
.
getBaseColumnMap
()!=
null
)
{
cols
=
String
.
join
(
","
,
newSchema
.
getBaseColumnMap
().
keySet
());
}
else
cols
=
"t1.*"
;
sql
+=
(
cols
+
" from "
+
newSchema
.
getName
()+
" t1 "
);
if
(
newSchema
.
isLogicValid
())
{
sql
+=
" where t1."
+
newSchema
.
getLogicValidCond
();
}
newSchema
.
setDefaultQueryScriptSQL
(
sql
);
}
}
POSchema
.
writeTo
(
newSchema
,
json
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
36744792
...
...
@@ -74,49 +74,9 @@ public class DOModelServiceImpl implements IDOModelService {
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
entity
=
args
[
2
];
Path
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
try
{
String
entityId
=
modelService
.
getEntitiyIdsBySystem
(
system
).
get
(
entity
);
if
(
StringUtils
.
isEmpty
(
entityId
))
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
if
(!
key
.
equals
(
entityId
))
{
args
=
entityId
.
split
(
"[.]"
);
system
=
args
[
0
];
entity
=
args
[
2
];
storePath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
system
,
"repo"
,
entity
,
"domain"
,
entity
+
".json"
);
}
}
catch
(
Exception
exception
)
{
throw
new
BadRequestAlertException
(
"获取模型失败"
,
"DOModel"
,
key
);
}
}
if
(!
Files
.
exists
(
storePath
))
if
(
Files
.
exists
(
storePath
))
{
doModel
=
modelService
.
loadDOModel
(
system
,
entity
);
schema
=
doModel
.
getSchema
();
if
(
schema
!=
null
)
{
if
(
doModel
.
getPoSchemas
()!=
null
)
{
Path
poPath
=
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"repository"
,
doModel
.
getName
()+
".json"
);
try
{
File
dir
=
poPath
.
getParent
().
toFile
();
if
(!
dir
.
exists
())
dir
.
mkdirs
();
Files
.
write
(
poPath
,
JSON
.
toJSONBytes
(
doModel
.
getPoSchemas
()),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"POSchemas"
,
poPath
.
toString
());
}
}
schema
.
writeTo
(
Paths
.
get
(
ModelService
.
MODEL_PATH
,
doModel
.
getSystemId
(),
"repo"
,
doModel
.
getName
(),
"domain"
,
doModel
.
getName
()+
".json"
));
}
}
else
{
doModel
=
new
DOModel
();
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
{
...
...
@@ -132,8 +92,6 @@ public class DOModelServiceImpl implements IDOModelService {
}
}
}
if
(
schema
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbPersistentServiceImpl.java
浏览文件 @
36744792
...
...
@@ -7,6 +7,7 @@ import cn.ibizlab.core.data.model.DSLink;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IPersistentService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -34,6 +35,8 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Autowired
private
DbDataMapper
repository
;
@Autowired
private
ModelService
modelService
;
@Override
public
BaseData
create
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
,
boolean
bGet
)
{
...
...
@@ -345,6 +348,6 @@ public class DbPersistentServiceImpl implements IPersistentService {
@Override
public
POSchema
getSchema
(
DSLink
link
,
String
system
,
String
table
)
{
return
null
;
return
modelService
.
getPOSchema
(
system
,
table
,
link
.
getType
())
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/MongoPersistentServiceImpl.java
浏览文件 @
36744792
...
...
@@ -7,6 +7,7 @@ import cn.ibizlab.core.data.model.POSchema;
import
cn.ibizlab.core.data.repository.MongoDataRepository
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.core.data.service.IPersistentService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +29,8 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Autowired
private
MongoDataRepository
repository
;
@Autowired
private
ModelService
modelService
;
@Override
public
BaseData
create
(
DSLink
link
,
POSchema
poSchema
,
BaseData
et
,
boolean
bGet
)
{
...
...
@@ -251,6 +254,6 @@ public class MongoPersistentServiceImpl implements IPersistentService {
@Override
public
POSchema
getSchema
(
DSLink
link
,
String
system
,
String
table
)
{
return
null
;
return
modelService
.
getPOSchema
(
system
,
table
,
link
.
getType
())
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录