@SecurityMapping(title = "直通车商品加载", value = "/seller/ztc_goods.htm*", rtype = "seller", rname = "竞价直通车", rcode = "ztc_seller", rgroup = "促销管理") @RequestMapping({ "/seller/ztc_goods.htm" }) public void ztc_goods(HttpServletRequest request, HttpServletResponse response, String goods_name) { Map params = new HashMap(); params.put("goods_name", "%" + goods_name.trim() + "%"); params.put("goods_status", Integer.valueOf(0)); params.put("user_id", SecurityUserHolder.getCurrentUser().getId()); params.put("ztc_status", Integer.valueOf(0)); List<Goods> goods_list = this.goodsService .query("select obj from Goods obj where obj.goods_name like :goods_name and obj.goods_store.user.id=:user_id and obj.ztc_status=:ztc_status and obj.goods_status=:goods_status order by obj.addTime desc", params, -1, -1); List maps = new ArrayList(); for (Goods goods : goods_list) { Map map = new HashMap(); map.put("goods_name", goods.getGoods_name()); map.put("goods_id", goods.getId()); maps.add(map); } response.setContentType("text/plain"); response.setHeader("Cache-Control", "no-cache"); response.setCharacterEncoding("UTF-8"); try { PrintWriter writer = response.getWriter(); writer.print(Json.toJson(maps, JsonFormat.compact())); } catch (IOException e) { e.printStackTrace(); } }
@RequestMapping("/add_goods_favorite.htm") @Transactional public void add_goods_favorite(HttpServletResponse response, String id) { Map params = new HashMap(); params.put("user_id", SecurityUserHolder.getCurrentUser().getId()); params.put("goods_id", CommUtil.null2Long(id)); List<Favorite> list = this.favoriteService.query( "select obj from Favorite obj where obj.user.id=:user_id and obj.goods.id=:goods_id", params, -1, -1); int ret = 0; if (list.size() == 0) { Goods goods = this.goodsService.getObjById(CommUtil.null2Long(id)); Favorite obj = new Favorite(); obj.setAddTime(new Date()); obj.setType(0); obj.setUser(SecurityUserHolder.getCurrentUser()); obj.setGoods(goods); this.favoriteService.save(obj); goods.setGoods_collect(goods.getGoods_collect() + 1); this.goodsService.update(goods); // 更新lucene索引 elasticsearchUtil.indexUpdate( IndexName.GOODS, IndexType.GOODS, goods.getId().toString(), IndexVoTools.goodsToIndexVo(goods)); // String goods_lucene_path = ConfigContants.LUCENE_DIRECTORY // + File.separator // + "luence" + File.separator + "goods"; // File file = new File(goods_lucene_path); // if (!file.exists()) { // CommUtil.createFolder(goods_lucene_path); // } // LuceneUtil lucene = LuceneUtil.instance(); // lucene.setIndex_path(goods_lucene_path); // lucene.update(CommUtil.null2String(goods.getId()), // luceneVoTools.updateGoodsIndex(goods)); } else { ret = 1; } response.setContentType("text/plain"); response.setHeader("Cache-Control", "no-cache"); response.setCharacterEncoding("UTF-8"); PrintWriter writer; try { writer = response.getWriter(); writer.print(ret); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }