ToolController.java 859 Bytes
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);
    }


}