// 生活帮 @WebMethod public ModelAndView tips(Page<Map> page) { ModelAndView mv = new ModelAndView(); page.setPageSize(3); page = dao.findPage( page, "select art.id as id, art.title as title , art.isAd as isTop, art.conts as conts, img.path as img from Article art , Image img where img.id=art.imgId" + " and art.leibie='tips' and art.publishFlag=1 order by art.setTopTime desc, art.id desc ", true, new Object[] {}); // make abstract for (Map art : page.getResult()) { String conts = art.get("conts").toString(); conts = HTMLSpirithHelper.delHTMLTag(conts); if (conts.length() > 70) { conts = conts.substring(0, 70); } art.put("conts", conts); } mv.data.put("tips", JSONHelper.toJSONArray(page.getResult())); mv.data.put( "imgUrl", "http://" + ConfigCache.get("image_host", "localhost") + "/article_image_path"); mv.data.put( "tipsDetailUrl", "https://" + ConfigCache.get("app_host", "localhost") + "/article/view.jsp"); return mv; }
// 产品搜索 @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; }
/** * 扫描历史记录 * * @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; }
// 首页初始化 @WebMethod public ModelAndView init(String tel) { // https://localhost:8181/c/app/init ModelAndView mv = new ModelAndView(); // 新闻 Page<Map> page = new Page<Map>(); page.setPageSize(2); page = dao.findPage( page, "select art.id as id, art.title as title , art.conts as conts, img.path as img from Article art , Image img where img.id=art.imgId and art.publishFlag=1" + " and art.leibie='news' order by art.setTopTime desc, art.id desc ", true, new Object[] {}); // make abstract for (Map art : page.getResult()) { String conts = art.get("conts").toString(); conts = HTMLSpirithHelper.delHTMLTag(conts); if (conts.length() > 70) { conts = conts.substring(0, 70); } art.put("conts", conts); } mv.data.put("news", JSONHelper.toJSONArray(page.getResult())); page = dao.findPage( page, "select product.id as id, product.title as title , img.path as img from Product product , Image img where img.id=product.imgId and product.isAd=1", true, new Object[] {}); mv.data.put("products", JSONHelper.toJSONArray(page.getResult())); mv.data.put( "imgUrl", "http://" + ConfigCache.get("image_host", "localhost") + "/article_image_path"); mv.data.put( "productDetailUrl", "https://" + ConfigCache.get("app_host", "localhost") + "/product/view.jsp"); mv.data.put( "goodsDetailUrl", "https://" + ConfigCache.get("app_host", "localhost") + "/goods/view.jsp"); mv.data.put( "newsDetailUrl", "https://" + ConfigCache.get("app_host", "localhost") + "/article/view.jsp"); return mv; }