【问题标题】:Java RestApi for Country ,State and city国家、州和城市的 Java Rest Api
【发布时间】:2017-11-11 02:31:42
【问题描述】:

我正在寻找三天以上,但我cnt得到任何解决方案。我需要一个java的restapi for country州和城市,就像我选择国家它给了我状态,并且当陈述时,它给了我所有的它下的城市。但是伙计们,我不想在这种情况下使用 GoogleApi。任何人都可以帮助我解决这个问题。我需要一个策略。

【问题讨论】:

  • 如果你需要自己写API,先做你的工作,在这里寻求帮助。你可能想检查这个以前的问题stackoverflow.com/questions/28495929/…
  • 我已经为单个表创建了用于创建和读取数据操作的 api,但为此我认为我需要一些表的连接操作。
  • 如果您编写了代码,那么您应该对该代码提出质疑并说明您面临的问题。你不应该要求完整的解决方案。

标签: java


【解决方案1】:
@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;
    }
}

【讨论】:

    猜你喜欢
    • 2017-10-20
    • 2011-01-14
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多