From 2f55cebbad3dea187a5f91d16ec80a9677dab699 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 13 十一月 2024 11:16:53 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/controller/LocationController.java |   52 ++++++++++++++++++++++++++--------------------------
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/yssh/controller/LocationController.java b/src/main/java/com/yssh/controller/LocationController.java
index f3e727e..3d839ae 100644
--- a/src/main/java/com/yssh/controller/LocationController.java
+++ b/src/main/java/com/yssh/controller/LocationController.java
@@ -1,11 +1,11 @@
 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.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -16,48 +16,48 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import com.yssh.entity.Location;
-import com.yssh.service.ILocationService;
+import com.yssh.service.LocationService;
 import com.yssh.utils.Result;
 
-/**
- * @author wMeng
- * @ClassName YsshLocationController
- * @Description YsshLocationController
- * @date 2022/10/30 13:21
- * @Version 1.0
- */
+import javax.annotation.Resource;
+
 @Api(tags="鍘傚尯鐑偣鐐逛綅")
 @RestController
 @RequestMapping("/location")
 @SuppressWarnings("rawtypes")
 public class LocationController {
-	
-    @Autowired
-    private ILocationService locationService;
+    @Resource
+    private LocationService locationService;
 
-	@ApiOperation(value = "鏉′欢鏌ヨ鐐逛綅鏁版嵁", notes = "鏍规嵁鍚嶇О鍙婂叾绫诲瀷鏌ヨ鐐逛綅璇︾粏淇℃伅")
+    @ApiOperation(value = "鏉′欢鏌ヨ鐐逛綅鏁版嵁", notes = "鏍规嵁鍚嶇О鍙婂叾绫诲瀷鏌ヨ鐐逛綅璇︾粏淇℃伅")
     @GetMapping("/query")
     public Result query(
-    		@RequestParam(value = "name", required = false) String name,
-    		@RequestParam(value = "type", required = true) String type){
-        List<Location>  data = locationService.query(name, type);
+            @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();
+    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){
+    public Result insertLocation(@RequestBody Location location) {
         int i = locationService.insertLocation(location);
-        if(i == 0){
+        if (i == 0) {
             return Result.error("鎻掑叆澶辫触");
         }
         return Result.OK("鎻掑叆鎴愬姛");
@@ -65,9 +65,9 @@
 
     @ApiOperation(value = "鍒犻櫎鐐逛綅鏁版嵁", notes = "鍒犻櫎鐐逛綅璇︽儏鏁版嵁")
     @DeleteMapping("/{id}")
-    public Result deleteLocation(@PathVariable String id){
+    public Result deleteLocation(@PathVariable String id) {
         int i = locationService.deleteLocation(id);
-        if(i == 0){
+        if (i == 0) {
             return Result.error("鍒犻櫎澶辫触");
         }
         return Result.OK("鍒犻櫎鎴愬姛");

--
Gitblit v1.9.3