-10

I am searching for more than three days but i cnt get any solutions.I need a restApi in java for country state and city,like when i select country it gives me states ,and when select on state it gives me all the cities under it.But guys i dont want to use GoogleApi for this scenario. Can any one help me regarding this.i need a stratch.

Rajiv
  • 1
  • 2
  • 1
    If you need to write your own API, do your work first and ask for help here.You may want to check this previous question https://stackoverflow.com/questions/28495929/getting-all-states-region-cities-when-passing-country-name – Ravi Chandra Jun 09 '17 at 07:17
  • I already create api for create and read operation of data, for a single table, but for this i think i need some join operation of tables. – Rajiv Jun 09 '17 at 07:31
  • If you have written a code then you should put that code in question and state what problem you are facing. You should not ask for whole solution. – R Dhaval Jun 09 '17 at 07:59

1 Answers1

0
@RestController
@RequestMapping("Angular")
public class Rest
{
    @Autowired
    CountryRepository countryRepository;

    @RequestMapping(value="/create") //, method=RequestMethod.POST,consumes="application/json"
    public Country create(Country country){
        country.setCreatedDate(new Date());
        country = countryRepository.save(country);
        return country;
    }

    @RequestMapping(value ="/read") //, method = RequestMethod.GET, produces = "application/json" 
    public Country read(@RequestParam Long country_id){
        Country country = countryRepository.findOne(country_id);
        return country;
    }
}
Daniel Puiu
  • 962
  • 6
  • 21
  • 29
Rajiv
  • 1
  • 2