前端傳入 SQL 語句 到後端執行

前端傳入 SQL 語句 到後端執行

本文運用注意事項:

(1)使用階段:測試階段,上生產前需去掉。

(2)作用:通過 系統 執行SQL,繞開權限的控制。

1. Controller 

1     @ApiOperation(value = "test")
2     @PostMapping("/executeSql")
3     public Result<List<LinkedHashMap>> executeSql(@RequestParam("sql") String sql) {
4         return popReconciliationDomain.executeSql(sql);
5     }
6  

2. Demon

1  
2     @Transactional
3     public Result<List<LinkedHashMap>> executeSql(String sql){
4         List<LinkedHashMap> integers = reconciliationPayRuleMapper.executeSql(sql);
5         return new Result(ResultCodeEnum.OK, integers);
6     }

3.Mapper.java

    List<LinkedHashMap> executeSql(String sql);

4.mapper.xml

1   <select  id="executeSql" parameterType="java.lang.String" resultType="java.util.LinkedHashMap" >
2     ${value}
3   </select>
4   

通過post 請求,參數 key:sql;value: 具體的 SQL 語句。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章