分页写法1
public IPage runPageSqlTF(Page page, String sqlStr) {
IPage dataList = baseMapper.runPageSql(page, sqlStr);
//返回数据
List<HashMap> queryResultList = null;
queryResultList = hashmapList2Hump(dataList.getRecords());
dataList.setRecords(queryResultList);
return dataList;
https://www.cnblogs.com/linhan8888/p/17877390.html
防止Sql注入函数
String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\\b(select|if|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
parameters = parameters.replaceAll(reg, " ");
1前台
export function getTaskPageList(query) {
return request({
url: '/XXX/getTaskPageList',
method: 'post',
data: query
})
}
2.control
@PostMapping("/getTaskPageList")
public R getTaskPageList(Page page, @RequestBody Map<String, String> paramMap) {
return R.ok(socialworkWhistleTaskService.getTaskPageList(page, paramMap));
}
3.
@Override
public IPage getTaskPageList(Page page, Map<String, String> paramMap){
String sSql = "";
long size = Long.parseLong(paramMap.get("size").toString());
long current = Long.parseLong(paramMap.get("current").toString());
page.setSize(size);
page.setCurrent(current);
IPage ip = new Page();
ip = customSqlService.runPageSql(page, sSql);
List<Map<String,Object>> lst = new ArrayList<>();
lst = ip.getRecords();
ip.setRecords(lst.stream().map(MapUtil::toCamelCaseMap).collect(Collectors.toList()));
return ip;
}
择善人而交,择善书而读,择善言而听,择善行而从。