/** * 商家大全 * * @return */ @RequestMapping(value = "/company.htm") public ModelAndView company( ModelAndView mav, TravelCompanyQuery query, Integer page, Integer pagesize) { mav.setViewName("cms/1409/company"); query.setPageSize(pagesize = Argument.isNotPositive(pagesize) ? 20 : pagesize); query.setNowPageIndex(page = Argument.isNotPositive(page) ? 0 : page - 1); query.setcType(CompanyTypeEnum.ACCOUNT.getValue()); query.setcState(CompanyStateEnum.NORMAL.getValue()); PaginationList<TravelCompanyDO> list = companyService.showCompanyPagination(query); PagesPagination pagination = PaginationParser.getPaginationList( page, pagesize, query.getAllRecordNum(), new IPageUrl() { @Override public String parsePageUrl(Object... objs) { return "/company.htm?page=" + (Integer) objs[1]; } }); mav.addObject("list", list); mav.addObject("pagination", pagination); return mav; }
/** * 根据条件查询公司 * * @return */ @RequestMapping(value = "/queryCompanyByConditions.htm", produces = "application/json") @ResponseBody public JsonResult queryCompanyByConditions(TravelCompanyQuery query, Integer limit) { List<TravelCompanyDO> list = companyService.listQuery(query); List<Map<String, ?>> mapList = CollectionUtils.toMapList(list, "cId", "cName", "cSpell"); // StringBuilder sb = new StringBuilder(); String cond = query.getQ() == null ? StringUtils.EMPTY : query.getQ(); cond = cond.toLowerCase(); // String temp; int maxSize = getLimit(limit); int size = 0; List<Map<String, ?>> result = new LinkedList<Map<String, ?>>(); String property = cond.matches("[a-zA-Z]+") ? "cSpell" : "cName"; for (Map<String, ?> map : mapList) { Object cName = null; for (Entry<String, ?> entry : map.entrySet()) { if (StringUtils.equals(entry.getKey(), property)) { cName = entry.getValue(); } } if (cond.matches("[a-zA-Z]+") ? StringUtils.startsWith((String) cName, cond) : StringUtils.containsIgnoreCase((String) cName, cond)) { result.add(map); size++; if (size > maxSize) { break; } } } return JsonResultUtils.success(result); }