@ApiOperation(value = "带条件及翻页查询") @RequestMapping(value = "page", method = RequestMethod.GET) @ResponseBody public AjaxPage data(@ModelAttribute @Valid PageParam param) { List<SpecificationCondition> conditions = new ArrayList<SpecificationCondition>(); if (StringUtils.isNotBlank(param.channelName)) conditions.add(SpecificationCondition.eq("id.channelId", param.channelName.split("-")[0])); if (StringUtils.isNotBlank(param.categoryName)) conditions.add(SpecificationCondition.eq("id.text", param.categoryName.split("-")[0])); if (StringUtils.isNotBlank(param.textType)) conditions.add(SpecificationCondition.eq("textType", param.textType)); if (StringUtils.isNotBlank(param.text)) conditions.add( SpecificationCondition.equalOrLikeIgnoreCase("id.text", "%" + param.text.trim() + "%")); if (StringUtils.isNotBlank(param.textState)) conditions.add(SpecificationCondition.eq("textState", param.textState)); List<String> sortNames = new ArrayList<String>(); if ("id.spId".equals(param.getSortName()) || "id.spServiceCode".equals(param.getSortName())) { sortNames.add("id.spId"); sortNames.add("id.spServiceCode"); } else sortNames.add(param.getSortName()); SpecificationHelper<ChannelTextFilter> sh = new SpecificationHelper<ChannelTextFilter>(conditions, param.getSortOrder(), sortNames); Page<ChannelTextFilter> p = ctfService.page(new PageRequest(param), sh.createSpecification()); List<ChannelTextFilter> list = p.getContent(); Integer category = FiltrationType.CATEGORY.getValue().intValue(); for (ChannelTextFilter ctf : list) { ctf.getId().setChannelId(channelService.findOneMatch(ctf.getId().getChannelId())); if (category.equals(ctf.getTextType())) ctf.getId().setText(tftypeService.findOneMatch(ctf.getId().getText())); } return AjaxPageUtil.toAjaxPage(p.getTotalElements(), list); }
@ApiOperation(value = "带条件及翻页查询") @RequestMapping(value = "page", method = RequestMethod.POST) @ResponseBody public AjaxPage page(@ModelAttribute @Valid PageParam param) { List<SpecificationCondition> conditions = new ArrayList<SpecificationCondition>(); conditions.add( SpecificationCondition.equalOrLikeIgnoreCase( "textFilterPattern", param.getTextFilterPattern())); SpecificationHelper<TextFilter> sh = new SpecificationHelper<TextFilter>(conditions, param); Page<TextFilter> p = textFilterService.page(new PageRequest(param), sh.createSpecification()); List<esms.etonenet.boss1069.web.decorate.TextFilter> list = new ArrayList<>(); for (TextFilter textFilter : p.getContent()) { esms.etonenet.boss1069.web.decorate.TextFilter textFilters = new esms.etonenet.boss1069.web.decorate.TextFilter(); List<Integer> inte = CheckBoxUtil.findx2Value(textFilter.getTextFilterCategoryFlag().intValue()); textFilters.setTextFilterPattern(textFilter.getTextFilterPattern()); StringBuffer sb = new StringBuffer(); for (Integer integer : inte) { if (integer != null) sb.append(ContentFilterCategoryFlag.toDisplayMap().get(String.valueOf(integer))); sb.append(" "); } textFilters.setTextFilterCategoryFlagName(sb.toString().trim()); list.add(textFilters); } return AjaxPageUtil.toAjaxPage(p.getTotalElements(), list); }