| | |
| | | package com.ruoyi.web.controller.common; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.project.domain.BaseAnnextype; |
| | |
| | | private IApiService service; |
| | | @ApiOperation("API->api查询列表") |
| | | @PostMapping("/{path}") |
| | | public AjaxResult getApiList(@PathVariable("path") String path, @RequestBody ApiDTO DTO){ |
| | | List<Map<String,Object>> lists=new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(path)) { |
| | | GiApi tempSql= service.getCode(path); |
| | | if(tempSql!=null&&ObjectUtils.isNotEmpty(tempSql.getApiSql())) { |
| | | public AjaxResult getApiList(@PathVariable("path") String path, @RequestBody ApiDTO DTO) { |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | if (ObjectUtils.isNotEmpty(path)) { |
| | | GiApi tempSql = service.getCode(path); |
| | | if (tempSql != null && ObjectUtils.isNotEmpty(tempSql.getApiSql())) { |
| | | String SQL_REG_EXP = ".*(\\b(insert|into|update|delete|trancate" + |
| | | "|drop|execute|grant|use)\\b).*"; |
| | | if (tempSql.getApiSql().toLowerCase().matches(SQL_REG_EXP)) { |
| | | return AjaxResult.error("sql中有非法字符,只应许select"); |
| | | } |
| | | return AjaxResult.success(service.getListSql(tempSql.getApiSql(),DTO)); |
| | | }else |
| | | lists = service.getListSql(tempSql.getApiSql(), DTO); |
| | | return AjaxResult.success(JSON.toJSON(lists)); |
| | | } else |
| | | return AjaxResult.error("sql代码没有对应的sql请核对"); |
| | | }else { |
| | | } else { |
| | | return AjaxResult.error("表名不能为空"); |
| | | } |
| | | } |
| | |
| | | return AjaxResult.error("表名不能为空"); |
| | | } |
| | | } |
| | | |
| | | } |