package org.spring.springboot.controller;
import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 城市 Controller 实现 Restful HTTP 服务
*
* Created by bysocket on 07/02/2017.
*/
@RestController
public class CityRestController {
@Autowired
private CityService cityService;
@RequestMapping(value = "/api/city/{id}", method = RequestMethod.GET)
public City findOneCity(@PathVariable("id") Long id) {
return cityService.findCityById(id);
}
@RequestMapping(value = "/api/city", method = RequestMethod.GET)
public List<City> findAllCity() {
return cityService.findAllCity();
}
@RequestMapping(value = "/api/city", method = RequestMethod.POST)
public void createCity(@RequestBody City city) {
cityService.saveCity(city);
}
@RequestMapping(value = "/api/city", method = RequestMethod.PUT)
public void modifyCity(@RequestBody City city) {
cityService.updateCity(city);
}
@RequestMapping(value = "/api/city/{id}", method = RequestMethod.DELETE)
public void modifyCity(@PathVariable("id") Long id) {
cityService.deleteCity(id);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springboot-restful.zip (25个子文件)
springboot-restful
src
main
resources
application.properties 368B
mapper
CityMapper.xml 2KB
java
org
spring
springboot
dao
CityDao.java 586B
domain
City.java 984B
controller
CityRestController.java 1KB
service
CityService.java 809B
impl
CityServiceImpl.java 969B
Application.java 797B
.classpath 1KB
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.core.resources.prefs 124B
org.eclipse.jdt.core.prefs 243B
pom.xml 2KB
target
classes
META-INF
MANIFEST.MF 487B
maven
springboot
springboot-restful
pom.properties 258B
pom.xml 2KB
org
spring
springboot
dao
CityDao.class 579B
domain
City.class 1KB
controller
CityRestController.class 2KB
Application.class 795B
service
CityService.class 487B
impl
CityServiceImpl.class 1KB
application.properties 368B
mapper
CityMapper.xml 2KB
test-classes
.project 570B
共 25 条
- 1
资源评论
博亦正能量
- 粉丝: 6
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功