mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-14 22:23:54 +08:00
Spring Boot 整合 Redis 实现缓存操作
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user