Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 @RequestMapping
 @ResponseBody
 public List<Province> findProvinces() {
   List<Province> provinces = areaService.findAllProvince();
   for (Province p : provinces) {
     p.setCities(null);
   }
   return provinces;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }