Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
2aa2dc28
提交
2aa2dc28
编写于
1月 05, 2021
作者:
tangyaolong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【dst模型初始化导入导出】第三版
上级
156edbc8
变更
3
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
203 行增加
和
73 行删除
+203
-73
MetaModelExService.java
...n/ibizlab/core/extensions/service/MetaModelExService.java
+75
-62
RelationshipModel.java
...bizlab/core/lite/extensions/domain/RelationshipModel.java
+3
-0
LiteModelService.java
...bizlab/core/lite/extensions/service/LiteModelService.java
+125
-11
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/MetaModelExService.java
浏览文件 @
2aa2dc28
此差异已折叠。
点击以展开。
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/RelationshipModel.java
浏览文件 @
2aa2dc28
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaRelationship
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -27,4 +28,6 @@ public class RelationshipModel {
private
String
entityId
;
private
MetaRelationship
relation
;
}
ibzdst-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteModelService.java
浏览文件 @
2aa2dc28
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
service
;
import
cn.ibizlab.core.lite.domain.*
;
import
cn.ibizlab.core.extensions.domain.AssembleModel
;
import
cn.ibizlab.core.extensions.service.MetaModelExService
;
import
cn.ibizlab.core.lite.domain.DstApp
;
import
cn.ibizlab.core.lite.domain.DstSystem
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.domain.MetaModel
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.FieldModel
;
import
cn.ibizlab.core.lite.extensions.domain.RelationshipModel
;
import
cn.ibizlab.core.lite.extensions.model.DataModel
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
cn.ibizlab.core.lite.filter.MetaEntitySearchContext
;
import
cn.ibizlab.core.lite.filter.MetaFieldSearchContext
;
import
cn.ibizlab.core.lite.service.*
;
import
cn.ibizlab.util.domain.FileItem
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.InternalServerErrorException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
Array
;
import
com.alibaba.fastjson.JSON
Object
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.
bind.annotation.PathVariab
le
;
import
org.springframework.web.
multipart.MultipartFi
le
;
import
javax.annotation.PostConstruct
;
import
java.
sql.Wrapper
;
import
java.
util.ArrayList
;
import
java.util.
LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.
io.*
;
import
java.
nio.file.Files
;
import
java.util.
*
;
import
static
cn
.
ibizlab
.
util
.
service
.
SimpleFileService
.
getExtensionName
;
@Service
public
class
LiteModelService
{
...
...
@@ -91,7 +99,7 @@ public class LiteModelService {
EntityModel
entityModel
=
new
EntityModel
();
entityModel
.
setEntity
(
entity
);
entityModel
.
setDataSets
(
metaDataSetService
.
selectByEntityId
(
entity
.
getEntityId
()
));
entityModel
.
setDataSets
(
metaDataSetService
.
selectByEntityId
(
entity
!=
null
?
entity
.
getEntityId
()
:
null
));
Map
<
String
,
RelationshipModel
>
parentSet
=
new
LinkedHashMap
();
List
<
RelationshipModel
>
references
=
new
ArrayList
<>();
...
...
@@ -100,6 +108,7 @@ public class LiteModelService {
RelationshipModel
model
=
new
RelationshipModel
();
MetaEntity
parentEntity
=
LiteStorage
.
getMetaEntity
(
item
.
getRefEntityId
());
if
(
parentEntity
!=
null
){
model
.
setRelation
(
item
);
model
.
setCodeName
(
item
.
getCodeName
());
model
.
setDataSourceName
(
parentEntity
.
getDsName
());
model
.
setEntityCodeName
(
parentEntity
.
getCodeName
());
...
...
@@ -120,6 +129,7 @@ public class LiteModelService {
RelationshipModel
model
=
new
RelationshipModel
();
MetaEntity
subEntity
=
LiteStorage
.
getMetaEntity
(
item
.
getEntityId
());
if
(
subEntity
!=
null
){
model
.
setRelation
(
item
);
model
.
setCodeName
(
StringUtils
.
isEmpty
(
item
.
getNestedName
())?
item
.
getCodeName
()+
"_"
+
item
.
getEntityName
():
item
.
getNestedName
());
model
.
setDataSourceName
(
subEntity
.
getDsName
());
model
.
setEntityCodeName
(
subEntity
.
getCodeName
());
...
...
@@ -195,6 +205,11 @@ public class LiteModelService {
@Lazy
private
IDstSystemService
dstSystemService
;
@Value
(
"${ibiz.filePath:/app/file/}"
)
private
String
fileRoot
;
@Autowired
private
MetaModelExService
metaModelExService
;
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:all-dst-apps'"
)
public
LinkedHashMap
<
String
,
DstApp
>
getApps
()
{
...
...
@@ -247,4 +262,103 @@ public class LiteModelService {
return
list
;
}
public
FileItem
uploadFile
(
MultipartFile
multipartFile
)
{
FileItem
item
=
null
;
// 获取文件名
String
fileName
=
multipartFile
.
getOriginalFilename
();
// 获取文件后缀
String
extname
=
"."
+
getExtensionName
(
fileName
);
try
{
String
fileid
=
DigestUtils
.
md5DigestAsHex
(
multipartFile
.
getInputStream
());
String
fileFullPath
=
this
.
fileRoot
+
"ibizutil"
+
File
.
separator
+
File
.
separator
+
fileName
;
File
file
=
new
File
(
fileFullPath
);
File
parent
=
new
File
(
file
.
getParent
());
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
FileCopyUtils
.
copy
(
multipartFile
.
getInputStream
(),
Files
.
newOutputStream
(
file
.
toPath
()));
item
=
new
FileItem
(
fileid
,
fileName
,
fileid
,
fileName
,
(
int
)
multipartFile
.
getSize
(),
extname
);
}
catch
(
IOException
e
)
{
throw
new
InternalServerErrorException
(
"文件上传失败,"
+
e
);
}
return
item
;
}
public
String
saveFile
(
String
jsonObject
)
{
// 获取文件名
String
fileName
=
"packageModel_"
+
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toUpperCase
();
// 获取文件后缀
String
extname
=
".json"
;
try
{
String
fileFullPath
=
this
.
fileRoot
+
"ibizutil"
+
File
.
separator
+
fileName
+
extname
;
File
file
=
new
File
(
fileFullPath
);
File
parent
=
new
File
(
file
.
getParent
());
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
writeFile
(
fileFullPath
,
jsonObject
);
}
catch
(
Exception
e
)
{
throw
new
InternalServerErrorException
(
"文件上传失败,"
+
e
);
}
return
fileName
+
extname
;
}
public
File
getFile
(
String
fileId
)
{
String
dirpath
=
this
.
fileRoot
+
"ibizutil"
+
File
.
separator
+
fileId
;
File
parent
=
new
File
(
dirpath
);
if
(
parent
.
exists
())
{
return
parent
;
}
throw
new
InternalServerErrorException
(
"文件未找到"
);
}
public
static
void
writeFile
(
String
filePath
,
String
sets
)
throws
IOException
{
FileWriter
fw
=
new
FileWriter
(
filePath
);
PrintWriter
out
=
new
PrintWriter
(
fw
);
out
.
write
(
sets
);
out
.
println
();
fw
.
close
();
out
.
close
();
}
public
String
exportFile
(
List
<
MetaModel
>
model
){
List
<
AssembleModel
>
temp
=
new
ArrayList
<>();
for
(
MetaModel
metaModel
:
model
)
{
temp
.
add
(
null
);
}
String
json
=
JSON
.
toJSONString
(
temp
);
String
fileName
=
this
.
saveFile
(
json
);
return
fileName
;
}
public
List
<
AssembleModel
>
translateFile
(
MultipartFile
file
){
BufferedReader
reader
=
null
;
String
ans
=
""
;
try
{
Reader
read
=
new
InputStreamReader
(
file
.
getInputStream
(),
"utf-8"
);
reader
=
new
BufferedReader
(
read
);
String
tmpString
=
null
;
while
((
tmpString
=
reader
.
readLine
())
!=
null
){
ans
+=
tmpString
;
}
if
(
StringUtils
.
isEmpty
(
ans
)){
throw
new
BadRequestAlertException
(
"文件内容为空"
,
""
,
""
);
}
List
<
AssembleModel
>
assembleModel
=
JSONObject
.
parseArray
(
ans
,
AssembleModel
.
class
);
return
assembleModel
;
}
catch
(
Exception
e
){
return
null
;
}
finally
{
if
(
reader
!=
null
){
try
{
reader
.
close
();
}
catch
(
IOException
ee
){
ee
.
printStackTrace
();
}
}
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录