ToolController.java
859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.viontech.storage.controller;
import cn.hutool.json.JSONObject;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* .
*
* @author 谢明辉
* @date 2021/12/15
*/
@RestController
@RequestMapping("/tool")
public class ToolController {
@Resource
private JdbcTemplate jdbcTemplate;
@PostMapping("execSQL")
public Object execSQL(@RequestBody JSONObject jsonObject) {
String sql = jsonObject.getStr("sql");
jdbcTemplate.execute(sql);
return "sdfsd";
}
@GetMapping("select")
public List<Map<String, Object>> select(@RequestBody JSONObject jsonObject) {
String sql = jsonObject.getStr("sql");
return jdbcTemplate.queryForList(sql);
}
}