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
d31e06ab
Commit
d31e06ab
authored
Dec 08, 2023
by
chenzai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit 一级导出
parent
6b3a780f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
6 deletions
+72
-6
ToolLibraryResource.java
...yeejoin/amos/api/tool/controller/ToolLibraryResource.java
+1
-1
StudioResourceService.java
...oin/amos/api/tool/face/service/StudioResourceService.java
+1
-0
ToolLibraryService.java
...eejoin/amos/api/tool/face/service/ToolLibraryService.java
+39
-5
SqlExportUtils.java
.../java/com/yeejoin/amos/api/tool/utils/SqlExportUtils.java
+31
-0
No files found.
src/main/java/com/yeejoin/amos/api/tool/controller/ToolLibraryResource.java
View file @
d31e06ab
...
@@ -55,7 +55,7 @@ public class ToolLibraryResource {
...
@@ -55,7 +55,7 @@ public class ToolLibraryResource {
@GetMapping
(
value
=
"/export/{id}"
)
@GetMapping
(
value
=
"/export/{id}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"导出"
,
notes
=
"导出"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"导出"
,
notes
=
"导出"
)
public
void
generateSQL
(
@PathVariable
String
id
,
HttpServletResponse
httpServletResponse
){
public
void
generateSQL
(
@PathVariable
String
id
,
HttpServletResponse
httpServletResponse
){
toolLibraryService
.
generate
SQL
(
id
,
httpServletResponse
);
toolLibraryService
.
exportDesigner
SQL
(
id
,
httpServletResponse
);
}
}
}
}
src/main/java/com/yeejoin/amos/api/tool/face/service/StudioResourceService.java
View file @
d31e06ab
...
@@ -70,6 +70,7 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
...
@@ -70,6 +70,7 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
private
static
String
DISABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 0;\r\n"
;
private
static
String
DISABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 0;\r\n"
;
private
static
String
ABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 1;\r\n"
;
private
static
String
ABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 1;\r\n"
;
private
static
String
DELIMITER
=
"###################################"
;
private
static
String
DELIMITER
=
"###################################"
;
@Autowired
@Autowired
JdbcTemplate
jdbcTemplate
;
JdbcTemplate
jdbcTemplate
;
@Autowired
@Autowired
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/ToolLibraryService.java
View file @
d31e06ab
package
com
.
yeejoin
.
amos
.
api
.
tool
.
face
.
service
;
package
com
.
yeejoin
.
amos
.
api
.
tool
.
face
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryDetailModel
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryDetailModel
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryModel
;
import
com.yeejoin.amos.api.tool.face.model.ToolLibraryModel
;
...
@@ -8,8 +9,14 @@ import com.yeejoin.amos.api.tool.face.orm.dao.ToolLibraryMapper;
...
@@ -8,8 +9,14 @@ import com.yeejoin.amos.api.tool.face.orm.dao.ToolLibraryMapper;
import
com.yeejoin.amos.api.tool.face.orm.entity.TableColumn
;
import
com.yeejoin.amos.api.tool.face.orm.entity.TableColumn
;
import
com.yeejoin.amos.api.tool.face.orm.entity.ToolLibrary
;
import
com.yeejoin.amos.api.tool.face.orm.entity.ToolLibrary
;
import
com.yeejoin.amos.api.tool.utils.DataBaseUtils
;
import
com.yeejoin.amos.api.tool.utils.DataBaseUtils
;
import
com.yeejoin.amos.api.tool.utils.DateUtils
;
import
com.yeejoin.amos.api.tool.utils.SqlExportUtils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -18,6 +25,7 @@ import java.sql.Connection;
...
@@ -18,6 +25,7 @@ import java.sql.Connection;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,6 +44,9 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
...
@@ -36,6 +44,9 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
@Value
(
"${toolLibrary.passWord}"
)
@Value
(
"${toolLibrary.passWord}"
)
private
String
passWord
;
private
String
passWord
;
@Autowired
private
EmqKeeper
emqKeeper
;
public
List
<
ToolLibraryTreeModel
>
queryForComponentList
(
String
designer
)
throws
ClassNotFoundException
,
SQLException
{
public
List
<
ToolLibraryTreeModel
>
queryForComponentList
(
String
designer
)
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
className
);
Class
.
forName
(
className
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
userName
,
passWord
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
userName
,
passWord
);
...
@@ -135,7 +146,7 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
...
@@ -135,7 +146,7 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
}
}
public
void
generate
SQL
(
String
id
,
HttpServletResponse
httpServletResponse
)
{
public
void
exportDesigner
SQL
(
String
id
,
HttpServletResponse
httpServletResponse
)
{
try
{
try
{
Class
.
forName
(
className
);
Class
.
forName
(
className
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
userName
,
passWord
);
Connection
connection
=
DriverManager
.
getConnection
(
url
,
userName
,
passWord
);
...
@@ -144,15 +155,38 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
...
@@ -144,15 +155,38 @@ public class ToolLibraryService extends BaseService<ToolLibraryModel, ToolLibrar
" where DESIGNER_TYPE='"
+
id
+
"') as t\n"
+
" where DESIGNER_TYPE='"
+
id
+
"') as t\n"
+
" 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
morphic_widget
=
DataBaseUtils
.
getInsertSQL
(
resultMaps
,
tableColumn
,
"morphic_widget"
);
StringBuffer
insertSql
=
DataBaseUtils
.
getInsertSQL
(
resultMaps
,
tableColumn
,
"morphic_widget"
);
// download(httpServletResponse,);
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
();
writer
.
flush
();
writer
.
close
();
download
(
httpServletResponse
,
fileName
,
sqlFilePath
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
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
));
...
...
src/main/java/com/yeejoin/amos/api/tool/utils/SqlExportUtils.java
0 → 100644
View file @
d31e06ab
package
com
.
yeejoin
.
amos
.
api
.
tool
.
utils
;
public
class
SqlExportUtils
{
/**
* 数据库备份路径
*/
public
static
final
String
BACKUP_PATH
=
"/db/"
;
/**
* 数据库备份文本前缀
*/
public
static
String
ONESQL_PREFIX
=
""
;
public
static
String
SUFFIX
=
"sql"
;
public
static
String
BR
=
"\r\n"
;
public
static
String
SLASH
=
"/"
;
public
static
String
BRANCH
=
";"
;
public
static
String
SPLIT
=
"`"
;
public
static
String
SPACE
=
" "
;
public
static
String
INSERT_INTO
=
" INSERT INTO "
;
public
static
String
CREATE_INTO
=
" CREATE TABLE "
;
public
static
String
VALUES
=
"VALUES"
;
public
static
String
LEFTBRACE
=
"("
;
public
static
String
RIGHTBRACE
=
")"
;
public
static
String
QUOTES
=
"'"
;
public
static
String
COMMA
=
","
;
public
static
String
DISABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 0;\r\n"
;
public
static
String
ABLEFOREIGN
=
"SET FOREIGN_KEY_CHECKS = 1;\r\n"
;
public
static
String
DELIMITER
=
"###################################"
;
}
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