Commit 0cd4a0f6 authored by 黎博's avatar 黎博

Merge branch 'master' into zdata

parents 9ebda78b f2145209
...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment