controller使用map接收参数并用POSTman测试
1.controller层
@PostMapping("/xksq/getGjclByCondition")
public ResultInfo getGjclByCondition(@RequestBody Map<String,Object> params,HttpServletRequest request){
Map<String,Object> map = new HashMap<>();
try {
Integer iPageIndex = (Integer) params.get("iPageIndex");
Integer iPageSize = (Integer) params.get("iPageSize");
PageHelper.startPage(iPageIndex!=null?iPageIndex:1,iPageSize!=null?iPageSize:10);
String username = JwtUtil.getUsername(request.getHeader("token"));
Rfgcgl user = rfgcglMapper.selectOne(new QueryWrapper<Rfgcgl>().eq("YHMC", username));
if(null==user){
return ResultInfo.fail(903,"用户不存在");
}
params.put("qynbbh",user.getQyNbBh());
List<Map<String, Object>> gjclByCondition = clxxQysqMapper.getGjclByCondition(params);
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(gjclByCondition);
map.put("total",pageInfo.getTotal());
map.put("datas",pageInfo);
return ResultInfo.ok(map);
}catch (Exception e){
e.printStackTrace();
return ResultInfo.fail(901, "列表条件查询失败");
}
}
|
使用postman测试
controller使用map接收参数时必须使用 @RequestBody接收参数,否则后台会出现接收不到的情况