Exemplo n.º 1
0
 public static String browseToItem(ModelSearch modelSearch, String name) {
   ItemSearch itemSearch = new ItemSearch();
   if (modelSearch.getCategoryId() != null && !modelSearch.getCategoryId().trim().equals("")) {
     itemSearch.setCategoryIds(new ArrayList<String>());
     itemSearch.getCategoryIds().add(modelSearch.getCategoryId());
   }
   itemSearch.setKeyword(modelSearch.getKeyword());
   itemSearch.setManufacturerIds(modelSearch.getManufacturerIds());
   itemSearch.setProperties(modelSearch.getProperties());
   return UrlUtils.browseUrl(itemSearch, name);
 }
Exemplo n.º 2
0
  /**
   * built market model browse url
   *
   * @param modelSearch
   * @param name
   * @return
   */
  public static String modelBrowseUrl(ModelSearch modelSearch, String name) {
    String url;

    if (modelSearch.getCategoryId() == null) {
      url = "/tim-kiem-model.html";
    } else {
      url =
          "/mua-ban/model/"
              + modelSearch.getCategoryId()
              + "/"
              + TextUtils.createAlias(name)
              + ".html";
    }
    String search = "";
    String keyword = modelSearch.getKeyword();
    int pageIndex = modelSearch.getPageIndex();
    if ((modelSearch.getManufacturerIds() != null && !modelSearch.getManufacturerIds().isEmpty())
        || modelSearch.getOrderBy() > 0
        || (modelSearch.getProperties() != null && !modelSearch.getProperties().isEmpty())) {
      modelSearch.setKeyword(null);
      modelSearch.setPageIndex(0);
      search =
          "filter="
              + Base64.encodeBase64String(StringUtils.getBytesUtf8(new Gson().toJson(modelSearch)));
    }

    if (keyword != null && !keyword.equals("")) {
      url += "?keyword=" + keyword.replaceAll("\\s+", "\\+");
      url = pageIndex <= 1 ? url : url + "&page=" + pageIndex;
      return search.equals("") ? url : url + "&" + search;
    } else {
      return search.equals("")
          ? (pageIndex <= 1 ? url : url + "?page=" + pageIndex)
          : ((pageIndex <= 1 ? (url + "?") : (url + "?page=" + pageIndex + "&")) + search);
    }
  }