예제 #1
0
  /**
   * 根据条件查询公司
   *
   * @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);
  }
예제 #2
0
 @RequestMapping(value = "/company/column/{id}.htm")
 public ModelAndView companyColumn(@PathVariable("id") Long id, ModelAndView mav) {
   mav.setViewName("cms/1409/company");
   List<TravelLineColumnDO> columnList = siteService.list(id, null);
   if (columnList == null || columnList.size() == 0) {
     return mav;
   }
   List<Long> cIdList = CollectionUtils.getLongValues(columnList, "cId");
   if (cIdList == null || cIdList.size() == 0) {
     return mav;
   }
   PaginationList<TravelCompanyDO> list =
       companyService.showCompanyPagination(
           new TravelCompanyQuery(cIdList.toArray(new Long[cIdList.size()])),
           new DefaultIpageUrl());
   mav.addObject("list", list);
   mav.addObject("pagination", list.getQuery());
   return mav;
 }