jeecg 高级筛选拼接场景

//@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);
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值