| | |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.yeshi.buwan.util.SystemUtil; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/hotSearch") |
| | | public class HotSearchController { |
| | | |
| | | @Resource |
| | | private SearchService searchService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | @RequestMapping("hotSearchList") |
| | | public void hotSearchList(int pageIndex,int detailsystem,String key,PrintWriter out) { |
| | | |
| | | if (pageIndex == 0) |
| | | pageIndex = 1; |
| | | @Resource |
| | | private SearchService searchService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | List<HotSearchAdmin> list = searchService.getHotSearchAdmin(key, detailsystem, pageIndex); |
| | | Gson gson =new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | long count = searchService.getHotSearchAdminCount(key, detailsystem); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("detailsystem", detailsystem + ""); |
| | | pe.setParams(map); |
| | | pe.setTotalCount((int) count); |
| | | JSONObject json =new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("hotSearchAdminList", gson.toJson(list)); |
| | | json.put("pageEntity", pe); |
| | | @RequestMapping("hotSearchList") |
| | | public void hotSearchList(int pageIndex, int detailsystem, String key, HttpSession session, PrintWriter out) { |
| | | |
| | | if (pageIndex == 0) |
| | | pageIndex = 1; |
| | | |
| | | List<HotSearchAdmin> list = searchService.getHotSearchAdmin(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem, pageIndex); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | long count = searchService.getHotSearchAdminCount(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("detailsystem", detailsystem + ""); |
| | | pe.setParams(map); |
| | | pe.setTotalCount((int) count); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("hotSearchAdminList", gson.toJson(list)); |
| | | json.put("pageEntity", pe); |
| | | // List<DetailSystem> detailSystemList = systemService.getDetailSystemList(); |
| | | // request.setAttribute("detailSystemList", detailSystemList); |
| | | System.out.println(json); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/setSearchDetailSystem", method = RequestMethod.POST) |
| | | public void set(String id, String type,String detailSystem, PrintWriter out) { |
| | | if ("add".equalsIgnoreCase(type)) {// 获取来源列表 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperHotSearch sz = new SuperHotSearch(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setHotSearch(new HotSearch(id)); |
| | | searchService.addSuperHotSearch(sz); |
| | | } |
| | | out.print("yes"); |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | searchService.deleteHotSearchAdmin(id, detailSystem); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value="deleteHotSearchList",method=RequestMethod.POST) |
| | | public void deleteHotSearchList(String ids,PrintWriter out) { |
| | | String[] idArr = ids.split(","); |
| | | for (String st : idArr) { |
| | | System.out.println("id---"+st); |
| | | searchService.deleteHotSearch(new HotSearch(st)); |
| | | } |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | System.out.println(json); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value="addHotSearch",method=RequestMethod.POST) |
| | | public void addHotSearch(String name,String beizhu,String detailsystems,PrintWriter out ) { |
| | | |
| | | System.out.println("name-"+name); |
| | | System.out.println("beizhu-"+beizhu); |
| | | System.out.println("detailsystems-"+detailsystems); |
| | | |
| | | HotSearch hotSearch = new HotSearch(); |
| | | hotSearch.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotSearch.setName(name); |
| | | hotSearch.setBeizhu(beizhu); |
| | | searchService.addHotSearch(hotSearch); |
| | | if (!StringUtil.isNullOrEmpty(detailsystems)) { |
| | | String[] idst = detailsystems.split(","); |
| | | for (String st : idst) { |
| | | SuperHotSearch sz = new SuperHotSearch(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(st)); |
| | | sz.setHotSearch(hotSearch); |
| | | searchService.addSuperHotSearch(sz); |
| | | } |
| | | } |
| | | out.print("yes"); |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value="updateHotSearch",method=RequestMethod.POST) |
| | | public void updateHotSearch(String id,String name,String beizhu,PrintWriter out) { |
| | | HotSearch hotSearch = searchService.getHotSearch(id); |
| | | hotSearch.setBeizhu(beizhu); |
| | | hotSearch.setName(name); |
| | | searchService.updateHotSearch(hotSearch); |
| | | out.print("yes"); |
| | | return ; |
| | | } |
| | | @RequestMapping(value = "/setSearchDetailSystem", method = RequestMethod.POST) |
| | | public void set(String id, String type, String detailSystem, PrintWriter out) { |
| | | if ("add".equalsIgnoreCase(type)) {// 获取来源列表 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperHotSearch sz = new SuperHotSearch(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setHotSearch(new HotSearch(id)); |
| | | searchService.addSuperHotSearch(sz); |
| | | } |
| | | out.print("yes"); |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | searchService.deleteHotSearchAdmin(id, detailSystem); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value="getHotSearch",method=RequestMethod.POST) |
| | | public void getHotSearch(String id,PrintWriter out) { |
| | | HotSearch hotSearch = searchService.getHotSearch(id); |
| | | JSONObject json=new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("hotSearch", hotSearch); |
| | | out.print(json); |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value = "deleteHotSearchList", method = RequestMethod.POST) |
| | | public void deleteHotSearchList(String ids, PrintWriter out) { |
| | | String[] idArr = ids.split(","); |
| | | for (String st : idArr) { |
| | | System.out.println("id---" + st); |
| | | searchService.deleteHotSearch(new HotSearch(st)); |
| | | } |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "addHotSearch", method = RequestMethod.POST) |
| | | public void addHotSearch(String name, String beizhu, String detailsystems, HttpSession session, PrintWriter out) { |
| | | |
| | | System.out.println("name-" + name); |
| | | System.out.println("beizhu-" + beizhu); |
| | | System.out.println("detailsystems-" + detailsystems); |
| | | |
| | | HotSearch hotSearch = new HotSearch(); |
| | | hotSearch.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotSearch.setName(name); |
| | | hotSearch.setBeizhu(beizhu); |
| | | hotSearch.setSystem(SystemUtil.getAdminSelectedSystem(session)); |
| | | searchService.addHotSearch(hotSearch); |
| | | if (!StringUtil.isNullOrEmpty(detailsystems)) { |
| | | String[] idst = detailsystems.split(","); |
| | | for (String st : idst) { |
| | | SuperHotSearch sz = new SuperHotSearch(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(st)); |
| | | sz.setHotSearch(hotSearch); |
| | | searchService.addSuperHotSearch(sz); |
| | | } |
| | | } |
| | | |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "updateHotSearch", method = RequestMethod.POST) |
| | | public void updateHotSearch(String id, String name, String beizhu, PrintWriter out) { |
| | | HotSearch hotSearch = searchService.getHotSearch(id); |
| | | hotSearch.setBeizhu(beizhu); |
| | | hotSearch.setName(name); |
| | | searchService.updateHotSearch(hotSearch); |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "getHotSearch", method = RequestMethod.POST) |
| | | public void getHotSearch(String id, PrintWriter out) { |
| | | HotSearch hotSearch = searchService.getHotSearch(id); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("hotSearch", hotSearch); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | } |