@ResponseBody @RequestMapping("/getByQueryParams") public List<DemandSupplyVO> getByQueryParams(@ModelAttribute DSQueryForm form) { // 如果产品类别为空,字段全部在一个对象里统一封装处理,否则做对比过滤 Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("type", form.getType()); queryMap.put("timeSearch", form.getTimeSearch()); queryMap.put("priceSearch", form.getPriceSearch()); queryMap.put("attentionSearch", form.getAttentionSearch()); // 得到所有供需信息 List<DemandSupplyInfo> infos = demandSupplyInfoService.getByQueryParams(queryMap); // convert List<DemandSupplyVO> tmps = new ArrayList<DemandSupplyVO>(); for (DemandSupplyInfo info : infos) { tmps.add(convertVO(info)); } List<DemandSupplyVO> vos = new ArrayList<DemandSupplyVO>(); String categoryId = form.getCategoryId(); if (StringUtils.isNoneBlank(categoryId)) { // exclude if (vos.size() > 0) { for (DemandSupplyVO vo : tmps) { Product product = productService.getById(vo.getProductId()); if (StringUtils.equals(product.getCategory().getId(), categoryId)) { vos.add(vo); } } } } else { vos.addAll(tmps); } return vos; }