前端傳入 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 語句。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM