//@AutoLog(value = "患者表-分页列表查询")
@ApiOperation(value="患者表-分页列表查询", notes="患者表-分页列表查询, sceneId: 拼接查询条件")
@GetMapping(value = "/list")
public Result<IPage<Patient>> queryPageList(Patient patient,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="20") Integer pageSize,
@RequestParam(name="sceneId", required=false) String sceneId,
HttpServletRequest req) {
// 获取查询条件(前台传递的查询参数)
Map<String, String[]> parameterMap = new HashMap<>(req.getParameterMap());
// 打印 req 参数
//System.out.println("HttpServletRequest 参数:");
//parameterMap.forEach((key, value) -> System.out.println(key + ": " + String.join(",", value)));
// 判断是否传递了 sceneId
if (sceneId != null && !sceneId.trim().isEmpty()) {
// 根据 sceneId 添加查询条件
Scene sceneById = sceneService.getById(sceneId);
System.out.println("-- 获取sceneById内容" + sceneById);
String sceneData = sceneById != null ? sceneById.getData() : null;
System.out.println("-- 获取sceneData内容" + sceneData);
if (sceneData != null) {
// 解析 sceneData,转换为查询参数
try {
JSONArray jsonArray = JSONArray.parseArray(sceneData);
JSONArray superQueryParamsArray = new JSONArray();
// 获取现有的superQueryParams
if (parameterMap.containsKey("superQueryParams")) {
String[] superQueryParams = parameterMap.get("superQueryParams");
if (superQueryParams != null && superQueryParams.length > 0) {
superQueryParamsArray = JSONArray.parseArray(URLDecoder.decode(superQueryParams[0], StandardCharsets.UTF_8.name()));
}
}
// 合并新条件到superQueryParams
superQueryParamsArray.addAll(jsonArray);
// 将合并后的查询条件放回parameterMap中
parameterMap.put("superQueryParams", new String[]{superQueryParamsArray.toJSONString()});
System.out.println("-- 获取superQueryParams内容" + superQueryParamsArray);
} catch (Exception e) {
e.printStackTrace();
return Result.error("解析筛选条件失败:" + e.getMessage());
}
}
}
QueryWrapper<Patient> queryWrapper = QueryGenerator.initQueryWrapper(patient, parameterMap);
System.out.println("-- SQL打印: " + queryWrapper.getCustomSqlSegment()); //打印查询条件
Page<Patient> page = new Page<Patient>(pageNo, pageSize);
IPage<Patient> pageList = patientService.page(page, queryWrapper);
return Result.OK(pageList);
}
11-16
12-14
08-30
3216
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)