예제 #1
0
 @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;
 }
예제 #2
0
 @RequestMapping
 @ResponseBody
 public List<Province> findProvinces() {
   List<Province> provinces = areaService.findAllProvince();
   for (Province p : provinces) {
     p.setCities(null);
   }
   return provinces;
 }
예제 #3
0
 @Override
 public Province createProvince(String name) {
   if (StringUtil.isEmpty(name)) {
     return null;
   }
   Province province = new Province();
   province.setName(name);
   dao.save(province);
   return province;
 }
예제 #4
0
 @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;
 }
예제 #5
0
 @Override
 public City createCity(ObjectId proId, String name) {
   if (proId == null || StringUtil.isEmpty(name)) {
     return null;
   }
   Province province = findProvince(proId);
   if (province == null) {
     return null;
   }
   City city = new City();
   city.setName(name);
   city.setProvince(province);
   dao.save(city);
   province.getCities().add(city);
   dao.save(province);
   return city;
 }