Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
qa-platform
Commits
0cd4a0f6
Commit
0cd4a0f6
authored
Aug 19, 2021
by
黎博
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into zdata
parents
9ebda78b
f2145209
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
SqlController.java
...ava/cn/qg/qaplatform/controller/common/SqlController.java
+5
-1
No files found.
src/main/java/cn/qg/qaplatform/controller/common/SqlController.java
View file @
0cd4a0f6
...
@@ -2,6 +2,7 @@ package cn.qg.qaplatform.controller.common;
...
@@ -2,6 +2,7 @@ package cn.qg.qaplatform.controller.common;
import
cn.qg.qaplatform.config.SwitchDataSource
;
import
cn.qg.qaplatform.config.SwitchDataSource
;
import
cn.qg.qaplatform.utils.JsonResult
;
import
cn.qg.qaplatform.utils.JsonResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
...
@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@CrossOrigin
@CrossOrigin
@RestController
@RestController
@RequestMapping
(
"/sql"
)
@RequestMapping
(
"/sql"
)
...
@@ -27,6 +29,7 @@ public class SqlController {
...
@@ -27,6 +29,7 @@ public class SqlController {
*/
*/
@GetMapping
(
"/execute"
)
@GetMapping
(
"/execute"
)
public
JsonResult
executeSQL
(
String
namespace
,
String
database
,
String
sql
,
String
type
)
{
public
JsonResult
executeSQL
(
String
namespace
,
String
database
,
String
sql
,
String
type
)
{
log
.
info
(
"收到sql请求,环境:{}, 数据库: {}, sql: {}, type: {}"
,
namespace
,
database
,
sql
,
type
);
try
{
try
{
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
database
);
SwitchDataSource
.
dataSourceSwitch
(
namespace
,
database
);
if
(
sql
.
startsWith
(
"select"
)
||
sql
.
startsWith
(
"SELECT"
))
{
if
(
sql
.
startsWith
(
"select"
)
||
sql
.
startsWith
(
"SELECT"
))
{
...
@@ -38,7 +41,8 @@ public class SqlController {
...
@@ -38,7 +41,8 @@ public class SqlController {
return
JsonResult
.
serverFailed
(
"暂不支持该类型!"
);
return
JsonResult
.
serverFailed
(
"暂不支持该类型!"
);
}
}
}
else
if
(
sql
.
startsWith
(
"update"
)
||
sql
.
startsWith
(
"UPDATE"
)
}
else
if
(
sql
.
startsWith
(
"update"
)
||
sql
.
startsWith
(
"UPDATE"
)
||
sql
.
startsWith
(
"delete"
)
||
sql
.
startsWith
(
"DELETE"
))
{
||
sql
.
startsWith
(
"delete"
)
||
sql
.
startsWith
(
"DELETE"
)
||
sql
.
startsWith
(
"insert"
)
||
sql
.
startsWith
(
"INSERT"
))
{
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
return
JsonResult
.
success
();
return
JsonResult
.
success
();
}
else
{
}
else
{
...
...
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