@RequestMapping public ModelAndView findAllCities(String proId) { ModelAndView mv = new ModelAndView("area/city_list"); Province province = areaService.findProvince(new ObjectId(proId)); mv.addObject("province", province); mv.addObject("cityList", province.getCities()); return mv; }
@RequestMapping public ModelAndView findAllAreas(String cityId) { ModelAndView mv = new ModelAndView("area/area_list"); City city = areaService.findCity(new ObjectId(cityId)); mv.addObject("areaList", city.getAreas()); mv.addObject("city", city); return mv; }
@RequestMapping @ResponseBody public List<Province> findProvinces() { List<Province> provinces = areaService.findAllProvince(); for (Province p : provinces) { p.setCities(null); } return provinces; }
@RequestMapping public ModelAndView create_start_area(String cityId) { ModelAndView mv = new ModelAndView("area/create_area"); if (StringUtil.isEmpty(cityId)) { return mv; } City city = areaService.findCity(new ObjectId(cityId)); mv.addObject("city", city); return mv; }
@RequestMapping public ModelAndView create_start_city(String proId) { ModelAndView mv = new ModelAndView("area/create_city"); if (StringUtil.isEmpty(proId)) { return mv; } Province province = areaService.findProvince(new ObjectId(proId)); mv.addObject("province", province); return mv; }
@RequestMapping public ModelAndView create_province(String name) { ModelAndView mv = new ModelAndView(); Province province = areaService.createProvince(name); if (province == null) { } else { mv.setViewName("forward:findAll.do"); } return mv; }
@ResponseBody @RequestMapping public List<Area> findAreas(String cityId) { City city = areaService.findCity(new ObjectId(cityId)); List<Area> areaList = new ArrayList<Area>(); for (Area area : city.getAreas()) { area.setCity(null); areaList.add(area); } return areaList; }
@ResponseBody @RequestMapping public List<City> findCities(String proId) { Province province = areaService.findProvince(new ObjectId(proId)); List<City> cities = new ArrayList<City>(); for (City city : province.getCities()) { city.setProvince(null); city.setAreas(null); cities.add(city); } return cities; }
@RequestMapping public ModelAndView create_city(String proId, String name) { ModelAndView mv = new ModelAndView(); if (StringUtil.isEmpty(proId) || StringUtil.isEmpty(name)) { return mv; } City city = areaService.createCity(new ObjectId(proId), name); if (city == null) { } else { mv.setViewName("forward:findAllCities.do?proId=" + proId); } return mv; }
@RequestMapping public ModelAndView create_area(String cityId, String name) { ModelAndView mv = new ModelAndView(); if (StringUtil.isEmpty(cityId) || StringUtil.isEmpty(name)) { return mv; } Area area = areaService.createArea(new ObjectId(cityId), name); if (area == null) { } else { mv.setViewName("forward:findAllAreas.do?cityId=" + cityId); } return mv; }
@RequestMapping public ModelAndView findAll() { ModelAndView mv = new ModelAndView("area/province_list"); mv.addObject("provinceList", areaService.findAllProvince()); return mv; }