Пример #1
0
  public CityTrl[] getCityList(String value) {
    // System.out.println("bgn");
    if (!DwrPrivilegeFilter.isView(this.getClass().getName())) {
      return null;
    }
    if (value == null) value = "";
    Map param = new HashMap();
    WebContext webContext = WebContextFactory.get();
    HttpServletRequest request = webContext.getHttpServletRequest();
    UserResource ur = (UserResource) request.getSession().getAttribute("resource");
    param.put(
        "accessString",
        "language='"
            + ur.getLocale().toString()
            + "' and name like '%"
            + value.trim()
            + "%'   and id in (SELECT  id FROM base_city where levelint>=3)");
    List<CityTrl> list = cityTrlService.selectByExample(param);
    if (list != null) {

      if (list.size() > 10) {
        list = list.subList(0, 10);
      }
      CityTrl[] cityTrlArray = new CityTrl[list.size()];
      list.toArray(cityTrlArray);
      // System.out.println("comp");
      return cityTrlArray;
    }
    return null;
  }
Пример #2
0
  public CityTrl[] getCityCityList(String value, String countryId, String provinceId) {
    // System.out.println("bgn");
    if (!DwrPrivilegeFilter.isView(this.getClass().getName())) {
      return null;
    }
    if (value == null) value = "";
    Map param = new HashMap();
    WebContext webContext = WebContextFactory.get();
    HttpServletRequest request = webContext.getHttpServletRequest();
    UserResource ur = (UserResource) request.getSession().getAttribute("resource");
    StringBuilder sb = new StringBuilder("");
    if (StringUtil.isNotEmpty(provinceId)) {
      sb.append("and parent_id=").append(provinceId);
    } else if (StringUtil.isNotEmpty(countryId)) {
      sb.append("and parent_id in (select id from base_city where parent_id=")
          .append(countryId)
          .append(")");
    }

    param.put(
        "accessString",
        "language='"
            + ur.getLocale().toString()
            + "' and  ((name like '%"
            + value.trim()
            + "%') or (remark like '%"
            + value.trim()
            + "%'))  and  city_id in( select id from base_city where levelint=3 "
            + sb.toString()
            + ")");
    List<CityTrl> list = cityTrlService.selectByExample(param);
    if (list != null) {

      if (list.size() > 10) {
        list = list.subList(0, 10);
      }
      CityTrl[] cityTrlArray = new CityTrl[list.size()];
      list.toArray(cityTrlArray);
      // System.out.println("comp");
      return cityTrlArray;
    }
    return null;
  }