Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-tool
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tool
amos-tool
Commits
da7628f0
Commit
da7628f0
authored
Dec 08, 2023
by
Gwofoo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二级组件的导出
parent
d31e06ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
25 deletions
+86
-25
ToolLibraryResource.java
...yeejoin/amos/api/tool/controller/ToolLibraryResource.java
+13
-0
ToolLibraryService.java
...eejoin/amos/api/tool/face/service/ToolLibraryService.java
+73
-25
No files found.
src/main/java/com/yeejoin/amos/api/tool/controller/ToolLibraryResource.java
View file @
da7628f0
...
@@ -58,4 +58,17 @@ public class ToolLibraryResource {
...
@@ -58,4 +58,17 @@ public class ToolLibraryResource {
toolLibraryService
.
exportDesignerSQL
(
id
,
httpServletResponse
);
toolLibraryService
.
exportDesignerSQL
(
id
,
httpServletResponse
);
}
}
/**
* 导出SQL脚本 二级功能
* @param sequenceNbr 组件在数据库表中的键
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/export/component"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"导出"
,
notes
=
"导出二级组件中的所有工具的SQL"
)
public
void
exportComponentSQL
(
@RequestParam
(
value
=
"sequenceNbr"
)
String
sequenceNbr
,
HttpServletResponse
httpServletResponse
)
throws
SQLException
,
ClassNotFoundException
{
toolLibraryService
.
exportComponentSQL
(
sequenceNbr
,
httpServletResponse
);
}
}
}
src/main/java/com/yeejoin/amos/api/tool/face/service/ToolLibraryService.java
View file @
da7628f0
...
@@ -156,37 +156,44 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
...
@@ -156,37 +156,44 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
" inner join morphic_widget mw on mw.group_id=t.SEQUENCE_NBR"
,
connection
);
" inner join morphic_widget mw on mw.group_id=t.SEQUENCE_NBR"
,
connection
);
List
<
TableColumn
>
tableColumn
=
DataBaseUtils
.
getTableColumn
(
"morphic_widget"
,
connection
);
List
<
TableColumn
>
tableColumn
=
DataBaseUtils
.
getTableColumn
(
"morphic_widget"
,
connection
);
StringBuffer
insertSql
=
DataBaseUtils
.
getInsertSQL
(
resultMaps
,
tableColumn
,
"morphic_widget"
);
StringBuffer
insertSql
=
DataBaseUtils
.
getInsertSQL
(
resultMaps
,
tableColumn
,
"morphic_widget"
);
File
directory
=
new
File
(
""
);
// 参数为空
String
coursePath
=
directory
.
getCanonicalPath
();
File
parentFile
=
new
File
(
coursePath
).
getParentFile
();
String
backPath
=
parentFile
.
getCanonicalPath
()
+
SqlExportUtils
.
BACKUP_PATH
;
File
sqlDirectory
=
new
File
(
backPath
);
if
(!
sqlDirectory
.
exists
())
{
sqlDirectory
.
mkdir
();
}
// 备份文件路径名称
String
fileName
=
id
+
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMddHHmmss"
)
+
"."
+
SqlExportUtils
.
SUFFIX
;
String
sqlFilePath
=
backPath
+
SqlExportUtils
.
SLASH
+
fileName
;
File
file
=
new
File
(
sqlFilePath
);
FileOutputStream
out
=
new
FileOutputStream
(
file
);
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
out
,
"utf8"
);
if
(
insertSql
.
length
()
>
0
)
{
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
writer
.
write
(
"/**"
+
SqlExportUtils
.
BR
+
"* 资源数据"
+
SqlExportUtils
.
BR
+
"**/"
+
SqlExportUtils
.
BR
);
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
writer
.
write
(
insertSql
.
toString
());
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
}
connection
.
close
();
connection
.
close
();
writer
.
flush
();
writer
.
close
();
download
(
httpServletResponse
,
fileName
,
sqlFilePath
);
prepareDownload
(
id
,
insertSql
,
httpServletResponse
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
public
void
prepareDownload
(
String
id
,
StringBuffer
insertSql
,
HttpServletResponse
httpServletResponse
)
throws
IOException
{
File
directory
=
new
File
(
""
);
// 参数为空
String
coursePath
=
directory
.
getCanonicalPath
();
File
parentFile
=
new
File
(
coursePath
).
getParentFile
();
String
backPath
=
parentFile
.
getCanonicalPath
()
+
SqlExportUtils
.
BACKUP_PATH
;
File
sqlDirectory
=
new
File
(
backPath
);
if
(!
sqlDirectory
.
exists
())
{
sqlDirectory
.
mkdir
();
}
// 备份文件路径名称
String
fileName
=
id
+
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMddHHmmss"
)
+
"."
+
SqlExportUtils
.
SUFFIX
;
String
sqlFilePath
=
backPath
+
SqlExportUtils
.
SLASH
+
fileName
;
File
file
=
new
File
(
sqlFilePath
);
FileOutputStream
out
=
new
FileOutputStream
(
file
);
OutputStreamWriter
writer
=
new
OutputStreamWriter
(
out
,
"utf8"
);
if
(
insertSql
.
length
()
>
0
)
{
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
writer
.
write
(
"/**"
+
SqlExportUtils
.
BR
+
"* 资源数据"
+
SqlExportUtils
.
BR
+
"**/"
+
SqlExportUtils
.
BR
);
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
writer
.
write
(
insertSql
.
toString
());
writer
.
write
(
SqlExportUtils
.
BR
+
SqlExportUtils
.
BR
+
SqlExportUtils
.
DELIMITER
+
SqlExportUtils
.
BR
);
}
writer
.
flush
();
writer
.
close
();
download
(
httpServletResponse
,
fileName
,
sqlFilePath
);
}
public
void
download
(
HttpServletResponse
response
,
String
fileName
,
String
sqlFilePath
)
throws
IOException
{
public
void
download
(
HttpServletResponse
response
,
String
fileName
,
String
sqlFilePath
)
throws
IOException
{
File
f
=
new
File
(
sqlFilePath
);
File
f
=
new
File
(
sqlFilePath
);
BufferedInputStream
br
=
new
BufferedInputStream
(
new
FileInputStream
(
f
));
BufferedInputStream
br
=
new
BufferedInputStream
(
new
FileInputStream
(
f
));
...
@@ -202,5 +209,46 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
...
@@ -202,5 +209,46 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
out
.
close
();
out
.
close
();
}
}
/**
* 导出组件中的工具的SQL(二级)
* @param sequenceNbr
* @param httpServletResponse
*/
public
void
exportComponentSQL
(
String
sequenceNbr
,
HttpServletResponse
httpServletResponse
)
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
className
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
userName
,
passWord
);
// 先查当前节点的parent,看是不是0,从而判断在叶子节点还是父节点
List
<
Map
<
String
,
Object
>>
clickedNodeMaps
=
DataBaseUtils
.
getMaps
(
"select SEQUENCE_NBR, parent, DESIGNER_TYPE, display_name "
+
"from morphic_widget_group "
+
"where is_delete != 1 and SEQUENCE_NBR = "
+
sequenceNbr
,
connection
);
String
parent
=
clickedNodeMaps
.
get
(
0
).
get
(
"parent"
).
toString
();
List
<
Map
<
String
,
Object
>>
displayTools
=
new
ArrayList
<>();
String
sql
;
if
(
parent
.
equals
(
"0"
))
{
// 父节点
sql
=
"SELECT * FROM morphic_widget\n"
+
"WHERE is_delete != 1 and group_id IN (\n"
+
"\tSELECT SEQUENCE_NBR\n"
+
"\tFROM morphic_widget_group\n"
+
"\twhere is_delete != 1 and parent = "
+
sequenceNbr
+
");"
;
}
else
{
// 叶子节点
sql
=
"SELECT * FROM morphic_widget\n"
+
"WHERE is_delete!=1 AND group_id = "
+
sequenceNbr
+
";"
;
}
List
<
Map
<
String
,
Object
>>
resultMaps
=
DataBaseUtils
.
getMaps
(
sql
,
connection
);
List
<
TableColumn
>
tableColumn
=
DataBaseUtils
.
getTableColumn
(
"morphic_widget"
,
connection
);
StringBuffer
insertSql
=
DataBaseUtils
.
getInsertSQL
(
resultMaps
,
tableColumn
,
"morphic_widget"
);
connection
.
close
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment