Esempio n. 1
0
  // 产品搜索
  @WebMethod
  public ModelAndView searchGoods(Page<Map> page, String name, Integer uid) {
    ModelAndView mv = new ModelAndView();
    StringBuilder sql =
        new StringBuilder(
            "select goods.id as id , goods.title as title , img.path as img , goods.spec as spec , goods.vender as vender , goods.price as price from Goods goods , Image img  where goods.imgId=img.id ");
    List<Object> params = new ArrayList<Object>();
    if (StringUtils.isNotEmpty(name)) {
      System.out.println(name);
      sql.append(" and title like ?");
      params.add("%" + name + "%");
    }
    page.order = "desc";
    page.orderBy = "addtime";
    page.setPageSize(10);
    page = dao.findPage(page, sql.toString(), true, params.toArray());

    if (StringUtils.isNotEmpty(name)) {
      SearchHistory search = new SearchHistory();
      search.uid = uid;
      search.text = name;
      dao.saveOrUpdate(search);
    }

    mv.data.put("page", JSONHelper.toJSON(page));
    mv.data.put(
        "imgUrl", "http://" + ConfigCache.get("image_host", "localhost") + "/article_image_path");
    mv.data.put(
        "goodsDetailUrl",
        "https://" + ConfigCache.get("app_host", "localhost") + "/goods/view.jsp");
    return mv;
  }
Esempio n. 2
0
  /**
   * 扫描历史记录
   *
   * @param page
   * @param uid
   * @param type
   * @param device
   * @return
   */
  @WebMethod
  public ModelAndView listScanRecord(Page<Map> page, Integer uid, Integer type, String device) {
    ModelAndView mv = new ModelAndView();
    StringBuilder hql =
        new StringBuilder(
            "select p.id as id, p.title as title , p.vender as vender , p.spec as spec,record.addtime as addtime , img.path as img,record.id as scanId from Product p ,ScanRecord record , Image img where record.productId=p.id and p.imgId=img.id ");
    List<Object> params = new ArrayList<Object>();

    hql.append(" and record.type=? ");
    params.add(type);

    hql.append(" and (record.device=? ");

    params.add(device);
    if (uid != null) {
      hql.append(" or record.uid=? ");
      params.add(uid);
    }
    hql.append(")");
    LogUtil.info(
        "listScanRecord uid=" + uid + ",device=" + device + ",type=" + type + ",hql=" + hql);
    page = dao.findPage(page, hql.toString(), true, params.toArray());
    mv.data.put("page", JSONHelper.toJSON(page));
    mv.data.put(
        "productDetailUrl",
        "https://" + ConfigCache.get("app_host", "localhost") + "/product/view.jsp");
    mv.data.put(
        "imgUrl", "http://" + ConfigCache.get("image_host", "localhost") + "/article_image_path");
    return mv;
  }