/** * 活动专题 * * @param dto * @param model * @return */ @RequestMapping("/famousTopics") public String toFamousTopics(YouSearchDto dto, Model model) { dto.setCurrPageNo(4); if (StringUtils.isNotBlank(dto.getBtmSource())) { YouTopicMain main = goodsService.findActivityTopicMain(dto.getBtmSource()); if (main != null) { List<YouTopicBar> listBar = goodsService.findActivityTopicBar(main.getId()); for (YouTopicBar taoTopicBar : listBar) { if (taoTopicBar.getTitle().indexOf(" ") > -1) { taoTopicBar.setTitle(taoTopicBar.getTitle().replaceAll(" ", "")); } dto.setKeyWords(main.getName() + "_" + taoTopicBar.getTitle() + "_"); // logger.info("------toFamousTopics------" + main.getName() + "_" + // taoTopicBar.getTitle() + "_"); taoTopicBar.setTopics(hotelService.findTopicYouHotels(dto)); } model.addAttribute("listBar", listBar); } else { return taoError(dto, model); } model.addAttribute("topicMain", main); } else { return taoError(dto, model); } model.addAttribute("searchDto", dto); model.addAttribute("dataSource", Constants.DATA_SOURCE); logger.info("------查找名品专题----专题数据------famousTopics------"); return "activityTemplate"; }
/** * ajax 获取地图酒店数据 * * @param dto * @param model * @param request * @param response * @return */ @RequestMapping("/getHotelsForMapByAjax") public String getHotelsForMapByAjax( YouSearchDto dto, Model model, HttpServletRequest request, HttpServletResponse response) { String keyWords = (String) request.getParameter("keyword"); String city = (String) request.getParameter("city"); String currPageNo = (String) request.getParameter("currPageNo"); String level = (String) request.getParameter("level"); String callback = request.getParameter("callback"); String noResult = ""; dto.setKeyWords(keyWords); // 0表示不在列表中,1表示在列表中 String isKeyWordInMap = "0"; if (StringUtils.isNotBlank(city)) { dto.setSelectedCityId(city); } if (StringUtils.isNotBlank(currPageNo)) { dto.setCurrPageNo(Integer.parseInt(currPageNo)); } if (StringUtils.isNotBlank(level)) { dto.setHotelStar(level); } else { dto.setHotelStar(""); } PrintWriter out = null; try { dto.setPageMode("map"); dto.setPageSize(10); // 城市中心坐标 String cityCenterPoints = hotelService.getCityCenterLatAndLong(dto); noResult = "{\"all\": [],\"status\":\"-1\",\"cityCenter\":\"" + cityCenterPoints + "\"}"; B5MPageList<YouHotel> hotelList = hotelService.getYouHotelList(dto); Gson gson = new Gson(); logger.info( "getHotelsForMap--->" + city + "---" + keyWords + "---" + hotelList.getAll().size()); out = response.getWriter(); String result = gson.toJson(hotelList); if (dto.isKeyWordInMap()) { isKeyWordInMap = "1"; } result = result.substring(0, result.length() - 1) + ",\"latitude\":" + dto.getLatitude() + ",\"longitude\":" + dto.getLongitude() + ",\"status\":\"" + 0 + "\",\"inmap\":\"" + isKeyWordInMap + "\",\"cityCenter\":\"" + cityCenterPoints + "\"}"; // 下拉框 关键字 无结果页的情况:1、总页数小于1 2、无中心点 boolean flag1 = (dto.getLatitude() == null || dto.getLongitude() == null || hotelList.getTotalPages() < 1) && dto.isKeyWordInMap(); // 非下拉框 关键字 无结果情况 boolean flag2 = hotelList.getTotalPages() < 1 && !dto.isKeyWordInMap(); if (callback != null) { if (flag1 || flag2) { out.print(callback + "(" + noResult + ")"); logger.info( "--getHotelsForMapByAjax-noResult----fl->" + flag1 + "--f2-->" + flag2 + "---->" + dto.isKeyWordInMap() + "---" + hotelList.getTotalPages()); } else { out.print(callback + "(" + result + ")"); } } else { if (flag1 || flag2) { out.print(noResult); logger.info( "--getHotelsForMapByAjax-noResult----fl->" + flag1 + "--f2-->" + flag2 + "---->" + dto.isKeyWordInMap() + "---" + hotelList.getTotalPages()); } else { out.print(result); } } out.flush(); } catch (Exception e) { out.print(noResult); out.flush(); } finally { if (out != null) { out.close(); } } return null; }