// example /itembase/itemSimilarity/abc/def,efg,123
  @RequestMapping(
      value = "/itembase/itemSimilarity/{toItemId}/{params}",
      method = RequestMethod.GET)
  public ModelAndView getItemSimilarity(
      @PathVariable("toItemId") String toItemId, @PathVariable("params") String params)
      throws SuggestEngineException {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("home");

    HashMap<String, String> map = new HashMap<String, String>();
    StringBuilder url_param = new StringBuilder();

    String[] itemId = params.split(",");

    logger.info("Id num " + itemId.length);

    url_param.append("{toItemId}/");
    map.put("toItemId", toItemId);

    for (int i = 0; i < itemId.length; i++) {

      logger.info("itemId: " + itemId[i]);

      url_param.append("{itemId_" + i + "}/");

      map.put("itemId_" + i, itemId[i]);
    }

    String[] items = itemService.similarityToItem(url_param.toString(), map);

    mav.addObject("list", items);

    return mav;
  }
  // example /itembase/mostPopular?count=20
  @RequestMapping(value = "/itembase/mostPopular", method = RequestMethod.GET)
  public ModelAndView findMostPopularItems(
      @RequestParam(value = "count", required = false) Integer count)
      throws SuggestEngineException {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("home");

    HashMap<String, String> map = new HashMap<String, String>();

    if (null != count) map.put("size", String.valueOf(count));
    else map.put("size", PropertiesUtil.getRecommendListDefalutCount());

    RecommendList list = itemService.mostPopularItems(map); // throw exception

    RecommandResponse recommandResponse = new RecommandResponse();
    List<RecommandItem> reclist = new ArrayList<RecommandItem>();

    for (ArrayList<String> temp : list.getList()) {
      RecommandItem recommandItem = new RecommandItem();
      recommandItem.setId(temp.get(0));
      recommandItem.setScore(temp.get(1));
      reclist.add(recommandItem);
    }

    recommandResponse.setStatus("200");
    //		recommandResponse.setCount(map.get("size"));
    //		recommandResponse.setCki(map.get("cki"));
    recommandResponse.setRecommandlist(reclist);

    mav.addObject("responseList", recommandResponse);

    return mav;
  }
  // example /itembase/similarItems/abc,bcd,efg
  @RequestMapping(value = "/itembase/similarItems/{params}", method = RequestMethod.GET)
  public ModelAndView findSimilarItems(
      @PathVariable("params") String params,
      @RequestParam(value = "count", required = false) Integer count)
      throws SuggestEngineException {
    ModelAndView mav = new ModelAndView();
    mav.setViewName("home");

    HashMap<String, String> map = new HashMap<String, String>();
    StringBuilder url_param = new StringBuilder();

    String[] itemId = params.split(",");

    logger.info("Id num " + itemId.length);

    map.put("item_count", String.valueOf(itemId.length));

    for (int i = 0; i < itemId.length; i++) {

      logger.info("itemId: " + itemId[i]);

      url_param.append("{itemId_" + i + "}/");

      map.put("itemId_" + i, itemId[i]);
    }

    if (null != count) map.put("size", String.valueOf(count));
    else map.put("size", PropertiesUtil.getRecommendListDefalutCount());

    logger.info("count " + count);

    RecommendList list = itemService.mostSimilarItems(url_param.toString(), map); // throw exception

    RecommandResponse recommandResponse = new RecommandResponse();
    List<RecommandItem> reclist = new ArrayList<RecommandItem>();

    for (ArrayList<String> temp : list.getList()) {
      RecommandItem recommandItem = new RecommandItem();
      recommandItem.setId(temp.get(0));
      recommandItem.setScore(temp.get(1));
      reclist.add(recommandItem);
    }

    recommandResponse.setStatus("200");
    recommandResponse.setCount(map.get("size"));
    //		recommandResponse.setCki(map.get("cki"));
    recommandResponse.setRecommandlist(reclist);

    mav.addObject("responseList", recommandResponse);

    return mav;
  }