Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
b457b716
提交
b457b716
编写于
8月 19, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
e94fd7f2
变更
14
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
612 行增加
和
138 行删除
+612
-138
pom.xml
ibzdata-core/pom.xml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+1
-1
DstSystemModel.java
...c/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
+143
-0
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+193
-33
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+9
-1
LiteModelFeignClient.java
.../java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
+2
-2
LiteStorage.java
.../src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
+21
-4
MetaDataSetModel.java
...main/java/cn/ibizlab/core/data/lite/MetaDataSetModel.java
+76
-0
MetaEntityModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
+28
-0
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+36
-0
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+50
-6
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+36
-1
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+8
-42
DTOModelServiceImpl.java
...n/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
+8
-47
未找到文件。
ibzdata-core/pom.xml
浏览文件 @
b457b716
...
...
@@ -100,7 +100,7 @@
<dependency>
<groupId>
net.ibizsys.model
</groupId>
<artifactId>
ibizlab-model
</artifactId>
<version>
1.2.
2
</version>
<version>
1.2.
4
</version>
</dependency>
</dependencies>
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
b457b716
...
...
@@ -237,7 +237,7 @@ public class DOModel extends EntityBase implements Serializable {
else
if
(
keyMap
.
size
()>
1
)
{
String
key
=
DataObject
.
getStringValue
(
keyValue
,
""
);
String
[]
keys
=
key
.
split
(
"
|
|"
);
String
[]
keys
=
key
.
split
(
"
\\|\\
|"
);
if
(
keyMap
.
size
()!=
keys
.
length
)
return
null
;
int
i
=
0
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Getter
@Setter
...
...
@@ -21,10 +38,136 @@ public class DstSystemModel {
@JSONField
(
name
=
"pssystemid"
)
@JsonProperty
(
"pssystemid"
)
private
String
pssystemid
;
/**
* 系统名称
*/
@JSONField
(
name
=
"pssystemname"
)
@JsonProperty
(
"pssystemname"
)
private
String
pssystemname
;
/**
* 结构
*/
@JSONField
(
name
=
"sysstructure"
)
@JsonProperty
(
"sysstructure"
)
private
Map
sysstructure
;
/**
* 应用
*/
@JSONField
(
name
=
"apps"
)
@JsonProperty
(
"apps"
)
private
List
<
App
>
apps
;
public
DstSystemModel
addApp
(
App
app
)
{
if
(
apps
==
null
)
apps
=
new
ArrayList
<>();
apps
.
add
(
app
.
setSystemid
(
this
.
pssystemid
));
return
this
;
}
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
static
class
App
{
private
String
id
;
private
String
label
;
private
String
systemid
;
private
String
fullname
;
private
String
type
;
private
String
group
;
private
String
icon
;
private
Integer
visabled
;
private
String
addr
;
}
/**
* 校验
*/
@JSONField
(
name
=
"md5check"
)
@JsonProperty
(
"md5check"
)
private
String
md5check
;
/**
* 排序
*/
@JSONField
(
name
=
"showorder"
)
@JsonProperty
(
"showorder"
)
private
Integer
showorder
;
private
Map
<
String
,
Object
>
extensionparams
;
public
DstSystemModel
setDynamicModelPath
(
String
dynamic_model_path
)
{
if
(
extensionparams
==
null
)
extensionparams
=
new
HashMap
<
String
,
Object
>();
extensionparams
.
put
(
"dynamic_model_path"
,
dynamic_model_path
);
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getDynamicModelPath
()
{
if
(
extensionparams
!=
null
&&
extensionparams
.
get
(
"dynamic_model_path"
)!=
null
)
return
extensionparams
.
get
(
"dynamic_model_path"
).
toString
();
return
null
;
}
public
DstSystemModel
setLastModify
(
Long
lastModify
)
{
if
(
extensionparams
==
null
)
extensionparams
=
new
HashMap
<
String
,
Object
>();
extensionparams
.
put
(
"last_modify"
,
lastModify
);
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
Long
getLastModify
()
{
if
(
extensionparams
!=
null
&&
extensionparams
.
get
(
"last_modify"
)!=
null
)
return
DataObject
.
getLongValue
(
extensionparams
.
get
(
"last_modify"
),
0L
);
return
0L
;
}
public
DstSystemModel
fromPath
(
Path
path
)
{
try
{
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"DstSystem"
,
path
.
toString
());
JSONObject
jo
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
path
),
StandardCharsets
.
UTF_8
));
this
.
setPssystemid
(
jo
.
getString
(
"codeName"
));
this
.
setPssystemname
(
jo
.
getString
(
"logicName"
));
this
.
setLastModify
(
path
.
toFile
().
lastModified
());
if
(
jo
.
containsKey
(
"getAllPSApps"
))
{
JSONArray
array
=
jo
.
getJSONArray
(
"getAllPSApps"
);
array
.
forEach
(
obj
->{
JSONObject
app
=(
JSONObject
)
obj
;
String
appPath
=
app
.
getString
(
"path"
);
if
(!
StringUtils
.
isEmpty
(
appPath
))
{
String
[]
args
=
appPath
.
split
(
"/"
);
if
(
args
.
length
==
3
)
{
String
appId
=
args
[
1
];
this
.
addApp
(
new
App
().
setId
(
appId
).
setLabel
(
appId
));
}
}
});
}
this
.
setDynamicModelPath
(
path
.
getParent
().
toAbsolutePath
().
toString
());
}
catch
(
IOException
e
)
{
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"DstSystem"
,
path
.
toString
());
}
return
this
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
b457b716
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
浏览文件 @
b457b716
...
...
@@ -58,7 +58,15 @@ public class EntityModel {
private
MetaEntityModel
entity
;
private
List
<
Map
>
dataSets
;
private
List
<
MetaDataSetModel
>
dataSets
;
public
EntityModel
addDataSet
(
MetaDataSetModel
dataSet
)
{
if
(
dataSets
==
null
)
dataSets
=
new
ArrayList
<>();
dataSets
.
add
(
dataSet
);
return
this
;
}
private
List
<
FieldModel
>
fields
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
浏览文件 @
b457b716
...
...
@@ -19,11 +19,11 @@ public interface LiteModelFeignClient {
String
defaultToken
=
"Bearer eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpYnphZG1pbiIsImV4cCI6MTkzMzI0MTkzNywiaWF0IjoxNjE3ODgxOTM3fQ.dFmy-Sx0SlKQcDhbbAs9_bPkbAfy8eRLlGdtl-YZhfU82bCuS4n56ESK8fE0xQqqNJJM87X7U9CnWxRk9z9Xh_dqch-GW8qPj5s25cFsR96V2Ke-6XirCnS-fTRfY9ZIcqVT2gvFUE1MiSbEC-7SPgxcGrNZv0bLzmlW3drlSyQ"
;
@GetMapping
(
"/lite/{system}/entit
y
s/{entity}"
)
@GetMapping
(
"/lite/{system}/entit
ie
s/{entity}"
)
@Cacheable
(
value
=
"entitymodel"
,
key
=
"'row:'+#p0+'.'+#p1"
)
EntityModel
getProxyEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
);
@GetMapping
(
"/lite/{system}/entit
y
s"
)
@GetMapping
(
"/lite/{system}/entit
ie
s"
)
List
<
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
);
@GetMapping
(
"/lite/sysapps"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.io.File
;
@Component
public
class
LiteStorage
{
public
static
String
MODEL_PATH
;
private
static
LiteModelFeignClient
liteModelFeignClient
;
private
static
DynamicModelService
dynamicModelService
;
...
...
@@ -18,6 +23,11 @@ public class LiteStorage {
LiteStorage
.
dynamicModelService
=
service
;
}
public
static
DynamicModelService
getDynamicModelService
()
{
return
dynamicModelService
;
}
public
static
void
setLiteModelService
(
LiteModelFeignClient
service
)
{
if
(
LiteStorage
.
liteModelFeignClient
==
null
)
...
...
@@ -29,10 +39,6 @@ public class LiteStorage {
return
liteModelFeignClient
;
}
public
static
DynamicModelService
getDynamicModelService
()
{
return
dynamicModelService
;
}
public
static
EntityModel
getEntityModel
(
String
system
,
String
entity
)
{
...
...
@@ -59,10 +65,21 @@ public class LiteStorage {
private
DynamicModelService
dynamicService
;
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
public
String
getModelPath
()
{
if
(
modelPath
.
equals
(
File
.
separator
))
return
modelPath
.
substring
(
0
,
modelPath
.
length
()-
1
);
return
modelPath
;
}
@PostConstruct
public
void
init
(){
LiteStorage
.
setLiteModelService
(
liteService
);
LiteStorage
.
setDynamicModelService
(
dynamicService
);
LiteStorage
.
MODEL_PATH
=
getModelPath
();
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaDataSetModel.java
0 → 100644
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
/**
* 实体[数据集]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
@ApiModel
(
"数据集"
)
public
class
MetaDataSetModel
{
/**
* 标识
*/
@JSONField
(
name
=
"dataset_id"
)
@JsonProperty
(
"dataset_id"
)
@ApiModelProperty
(
"标识"
)
private
String
datasetId
;
/**
* 名称
*/
@JSONField
(
name
=
"dataset_name"
)
@JsonProperty
(
"dataset_name"
)
@ApiModelProperty
(
"名称"
)
private
String
datasetName
;
/**
* 实体标识
*/
@JSONField
(
name
=
"entity_id"
)
@JsonProperty
(
"entity_id"
)
@ApiModelProperty
(
"实体标识"
)
private
String
entityId
;
/**
* 实体
*/
@JSONField
(
name
=
"entity_name"
)
@JsonProperty
(
"entity_name"
)
@ApiModelProperty
(
"实体"
)
private
String
entityName
;
/**
* 代码名称
*/
@JSONField
(
name
=
"code_name"
)
@JsonProperty
(
"code_name"
)
@ApiModelProperty
(
"代码名称"
)
private
String
codeName
;
/**
* 代码
*/
@JSONField
(
name
=
"ds_code"
)
@JsonProperty
(
"ds_code"
)
@ApiModelProperty
(
"代码"
)
private
String
dsCode
;
/**
* 模型
*/
@JSONField
(
name
=
"ds_model"
)
@JsonProperty
(
"ds_model"
)
@ApiModelProperty
(
"模型"
)
private
String
dsModel
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
...
...
@@ -10,6 +13,9 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 实体[实体]
...
...
@@ -116,8 +122,30 @@ public class MetaEntityModel{
private
Timestamp
updatedate
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Map
<
String
,
Object
>
extensionparams
;
public
Object
get
(
String
key
)
{
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
extParams
);
return
extensionparams
.
get
(
key
);
}
public
MetaEntityModel
set
(
String
key
,
Object
value
)
{
if
(
value
==
null
)
return
this
;
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
extParams
);
extensionparams
.
put
(
key
,
value
);
List
<
Setting
>
settingList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
settingList
.
add
(
new
Setting
().
setProperty
(
key
).
setValue
(
DataObject
.
getStringValue
(
value
,
""
)));
return
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -12,6 +15,9 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 实体[属性]
...
...
@@ -260,7 +266,37 @@ public class MetaFieldModel {
private
Timestamp
updatedate
;
/**
* 扩展参数
*/
@JSONField
(
name
=
"ext_params"
)
@JsonProperty
(
"ext_params"
)
private
String
extParams
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Map
<
String
,
Object
>
extensionparams
;
public
Object
get
(
String
key
)
{
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
extParams
);
return
extensionparams
.
get
(
key
);
}
public
MetaFieldModel
set
(
String
key
,
Object
value
)
{
if
(
value
==
null
)
return
this
;
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
extParams
);
extensionparams
.
put
(
key
,
value
);
List
<
Setting
>
settingList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
settingList
.
add
(
new
Setting
().
setProperty
(
key
).
setValue
(
DataObject
.
getStringValue
(
value
,
""
)));
return
setExtParams
(
JSON
.
toJSONString
(
settingList
));
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
...
...
@@ -12,7 +13,11 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardOpenOption
;
import
java.util.*
;
@Getter
...
...
@@ -128,6 +133,28 @@ public class PojoSchema {
@JsonIgnore
public
PojoSchema
build
()
{
if
((!
built
)&&
Type
.
object
.
getCode
().
equalsIgnoreCase
(
this
.
getType
()))
{
if
(
properties
!=
null
)
{
properties
.
values
().
forEach
(
prop
->{
PojoSchema
item
=
null
;
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&(!
StringUtils
.
isEmpty
(
prop
.
getRef
())))
item
=
prop
;
else
if
(
Type
.
array
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())
&&
prop
.
getItems
()!=
null
&&
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getItems
().
getType
())
&&(!
StringUtils
.
isEmpty
(
prop
.
getItems
().
getRef
())))
item
=
prop
.
getItems
();
else
return
;
});
}
built
=
true
;
}
return
this
;
}
...
...
@@ -279,14 +306,31 @@ public class PojoSchema {
private
Integer
multipleOf
;
public
PojoSchema
writeTo
(
Path
path
)
{
return
writeTo
(
this
,
path
);
}
public
static
PojoSchema
fromPath
(
Path
path
)
{
try
{
if
(!
Files
.
exists
(
path
))
throw
new
BadRequestAlertException
(
"读取文件失败"
,
"PojoSchema"
,
path
.
toString
());
return
JSON
.
parseObject
(
Files
.
readAllBytes
(
path
),
PojoSchema
.
class
);
public
static
void
main
(
String
[]
args
)
{
PojoSchema
schema
=
new
PojoSchema
().
setType
(
"object"
).
setRef
(
"#/definitions/entity"
);
PojoSchema
def
=
new
PojoSchema
();
def
.
setType
(
"object"
).
setTitle
(
"部门"
).
addProperty
(
"deptCode"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门编码"
))
.
addProperty
(
"deptName"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门名称"
)).
addProperty
(
"parent"
,
def
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"解析文件失败"
,
"PojoSchema"
,
path
.
toString
());
}
}
System
.
out
.
println
(
JSON
.
toJSONString
(
schema
));
public
static
PojoSchema
writeTo
(
PojoSchema
pojoSchema
,
Path
path
)
{
try
{
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
pojoSchema
),
StandardOpenOption
.
CREATE
);
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"保存文件失败"
,
"PojoSchema"
,
path
.
toString
());
}
return
pojoSchema
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
b457b716
...
...
@@ -116,7 +116,7 @@ public class TransUtils {
return
pojoModel
;
}
public
static
PojoSchema
Lite
EntityModelModel2Schema
(
EntityModel
entityModel
)
public
static
PojoSchema
EntityModelModel2Schema
(
EntityModel
entityModel
)
{
PojoSchema
pojoSchema
=
new
PojoSchema
().
setName
(
entityModel
.
getEntityName
()).
setType
(
"object"
).
setTitle
(
entityModel
.
getLogicName
()).
setId
(
entityModel
.
getEntityId
())
.
setOptions
(
new
PojoOption
().
setLogicValid
(
entityModel
.
isLogicValid
()).
setLogicVal
(
entityModel
.
getLogicVal
()).
setLogicDelVal
(
entityModel
.
getLogicDelVal
()));
...
...
@@ -294,6 +294,41 @@ public class TransUtils {
return
poSchema
;
}
//
// public static PojoSchema EntityModelModel2PO(EntityModel entityModel,String dbType) {
//
// POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()).setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal());
//
//
// PojoSchema pojoSchema = new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
// .setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
// pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity())));
//
// int order = 1;
//
// for (FieldModel fieldModel : entityModel.getFields()) {
// String propType = fieldModel.getPropType();
// PojoSchema sub = null;
// if ("date".equals(propType))
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date");
// else if ("date-time".equals(propType))
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time");
// else
// sub = new PojoSchema().setType(propType);
// sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order).setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField()))));
// if ("PICKUP".equals(fieldModel.getField().getFieldType()) && fieldModel.isPhysicalField()) {
// if (!StringUtils.isEmpty(sub.getOptions().getRelationCodeName())) {
// RelationshipModel relationshipModel = entityModel.getRefMaps().get(sub.getOptions().getRelationCodeName());
// if (relationshipModel != null && (!StringUtils.isEmpty(relationshipModel.getTableName())))
// sub.getOptions().setRefTableName(relationshipModel.getTableName());
// }
//
// }
// pojoSchema.addProperty(sub.getName(), sub);
// order++;
// }
//
// }
public
static
void
main
(
String
[]
args
)
{
String
str
=
"{\"code\":\"CaseInfo\",\"name\":\"案件基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_id\",\"name\":\"请求ID标识\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"req_type\",\"name\":\"业务请求类型\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajbh\",\"name\":\"公共案件编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajmc\",\"name\":\"公共案件名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ab\",\"name\":\"案由代码\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"案由\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"gajgysrdh\",\"name\":\"移送人电话\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"case_status\",\"name\":\"案件状态\",\"required\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"CaseSuspect_List\",\"name\":\"嫌疑人自然人信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSuspect\",\"name\":\"嫌疑人自然人信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"rybh\",\"name\":\"人员编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"rybs\",\"name\":\"公安人员标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"xm\",\"name\":\"姓名\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"SuspectCoercive_List\",\"name\":\"嫌疑人强制措施信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCoercive\",\"name\":\"嫌疑人强制措施信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"cslb\",\"name\":\"强制措施种类代码\",\"required\":false,\"uniqueKeys\":true,\"dict\":\"强制措施种类\",\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}],\"extensions\":{}}},{\"code\":\"SuspectCompany_List\",\"name\":\"涉案单位信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCompany\",\"name\":\"涉案人单位信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"dwmc\",\"name\":\"单位名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSHR_List\",\"name\":\"受害人列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSHR\",\"name\":\"受害人基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"xm\",\"name\":\"姓名\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSAWP_List\",\"name\":\"涉案物品列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSAWP\",\"name\":\"涉案物品信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"sawpmc\",\"name\":\"名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseStatus_List\",\"name\":\"案件移送记录列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"object\",\"model\":{\"code\":\"CaseStatus\",\"name\":\"提请逮捕移送记录\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_dept\",\"name\":\"发送部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_deptname\",\"name\":\"发送部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_dept\",\"name\":\"接收部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_deptname\",\"name\":\"接收部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_time\",\"name\":\"发送时间\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"date\"},{\"code\":\"send_type\",\"name\":\"移送状态\",\"required\":true,\"uniqueKeys\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_type_zh\",\"name\":\"移送状态名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh_zh\",\"name\":\"文书名称\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh\",\"name\":\"移送文书文号\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}]}"
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Map
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Collection
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
...
...
@@ -25,13 +14,9 @@ import cn.ibizlab.core.data.model.TransUtils;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cglib.beans.BeanCopier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -40,9 +25,6 @@ import cn.ibizlab.core.data.domain.DOModel;
import
cn.ibizlab.core.data.filter.DOModelSearchContext
;
import
cn.ibizlab.core.data.service.IDOModelService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
/**
* 实体[业务实体] 无存储服务对象接口实现
...
...
@@ -87,42 +69,26 @@ public class DOModelServiceImpl implements IDOModelService {
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
entity
=
args
[
2
];
File
domainDir
=
new
File
(
modelPath
+
system
+
File
.
separator
+
"domain"
);
if
(!
domainDir
.
exists
())
domainDir
.
mkdirs
();
File
schemaJson
=
new
File
(
domainDir
,
entity
+
".json"
);
if
(!
schemaJson
.
exists
())
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
"domain"
,
entity
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
);
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
if
(
schema
!=
null
)
schema
.
writeTo
(
storePath
);
}
}
else
{
try
{
String
schemaJSON
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
entity
+
".json"
)),
StandardCharsets
.
UTF_8
);
schema
=
JSON
.
parseObject
(
schemaJSON
,
PojoSchema
.
class
);
}
catch
(
IOException
e
)
{
schema
=
PojoSchema
.
fromPath
(
storePath
);
}
}
if
(
schema
!=
null
)
{
doModel
.
setSchema
(
schema
);
try
{
Files
.
write
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
entity
+
".json"
),
JSON
.
toJSONString
(
schema
).
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
}
catch
(
IOException
e
)
{
}
}
else
{
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
}
return
doModel
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
浏览文件 @
b457b716
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Map
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Collection
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cglib.beans.BeanCopier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Lazy
;
import
cn.ibizlab.core.data.domain.DTOModel
;
import
cn.ibizlab.core.data.filter.DTOModelSearchContext
;
import
cn.ibizlab.core.data.service.IDTOModelService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
/**
* 实体[数据传输对象] 无存储服务对象接口实现
...
...
@@ -89,46 +67,29 @@ public class DTOModelServiceImpl implements IDTOModelService {
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
dto
=
args
[
2
];
File
domainDir
=
new
File
(
modelPath
+
system
+
File
.
separator
+
"dto"
);
if
(!
domainDir
.
exists
())
domainDir
.
mkdirs
();
File
schemaJson
=
new
File
(
domainDir
,
dto
+
".json"
);
if
(!
schemaJson
.
exists
(
))
Path
storePath
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
system
,
"repo"
,
"dto"
,
dto
+
".json"
);
if
(!
Files
.
exists
(
storePath
))
{
String
entity
=
dto
;
if
(
entity
.
endsWith
(
"DTO"
))
entity
=
entity
.
substring
(
0
,
entity
.
length
()-
3
);
EntityModel
entityModel
=
LiteStorage
.
getEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
)),
PojoSchema
.
class
);
schema
=
TransUtils
.
EntityModelModel2Schema
(
entityModel
);
schema
.
setName
(
dto
);
schema
.
setId
(
key
);
if
(
schema
!=
null
)
schema
.
writeTo
(
storePath
);
}
}
else
{
try
{
String
schemaJSON
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
dto
+
".json"
)),
StandardCharsets
.
UTF_8
);
schema
=
JSON
.
parseObject
(
schemaJSON
,
PojoSchema
.
class
);
}
catch
(
IOException
e
)
{
}
}
schema
=
PojoSchema
.
fromPath
(
storePath
);
if
(
schema
!=
null
)
{
dtoModel
.
setSchema
(
schema
);
try
{
Files
.
write
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
dto
+
".json"
),
JSON
.
toJSONString
(
schema
).
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
}
catch
(
IOException
e
)
{
}
}
else
{
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
}
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DTOModel"
,
key
);
return
dtoModel
;
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录