¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.utils.CacheUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.yssh.entity.Location; |
| | | import com.yssh.service.LocationService; |
| | | import com.yssh.utils.Result; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Api(tags="ååºçç¹ç¹ä½") |
| | | @RestController |
| | | @RequestMapping("/location") |
| | | @SuppressWarnings("rawtypes") |
| | | public class LocationController { |
| | | @Resource |
| | | private LocationService locationService; |
| | | |
| | | @ApiOperation(value = "æ¡ä»¶æ¥è¯¢ç¹ä½æ°æ®", notes = "æ ¹æ®åç§°åå
¶ç±»åæ¥è¯¢ç¹ä½è¯¦ç»ä¿¡æ¯") |
| | | @GetMapping("/query") |
| | | public Result query( |
| | | @RequestParam(value = "name", required = false) String name, |
| | | @RequestParam(value = "type", required = false) String type) { |
| | | List<Location> data = locationService.query(name, type); |
| | | return Result.OK(data); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "æ¥è¯¢ææç¹ä½æ°æ®", notes = "æ¥è¯¢ææååºçç¹ç¹ä½æ°æ®") |
| | | public Result list() { |
| | | //List<Location> list = locationService.getAll(); |
| | | String key = "locationService.getAll"; |
| | | List<Location> list = CacheUtils.getListByKey(key); |
| | | if (null == list) { |
| | | list = locationService.getAll(); |
| | | CacheUtils.putListByKey(key, list); |
| | | } |
| | | |
| | | return Result.OK(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°å¢ç¹ä½æ°æ®", notes = "æ°å¢ç¹ä½è¯¦æ
æ°æ®") |
| | | @PostMapping |
| | | public Result insertLocation(@RequestBody Location location) { |
| | | int i = locationService.insertLocation(location); |
| | | if (i == 0) { |
| | | return Result.error("æå
¥å¤±è´¥"); |
| | | } |
| | | return Result.OK("æå
¥æå"); |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤ç¹ä½æ°æ®", notes = "å é¤ç¹ä½è¯¦æ
æ°æ®") |
| | | @DeleteMapping("/{id}") |
| | | public Result deleteLocation(@PathVariable String id) { |
| | | int i = locationService.deleteLocation(id); |
| | | if (i == 0) { |
| | | return Result.error("å é¤å¤±è´¥"); |
| | | } |
| | | return Result.OK("å 餿å"); |
| | | } |
| | | } |