From 3517a8f49440afcf7bd5b98bb4f0ba255f5f409d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 22 二月 2022 14:03:53 +0800
Subject: [PATCH] update 优化 R 默认返回 msg
---
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
index e01b542..98cca18 100644
--- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java
@@ -1,11 +1,10 @@
package com.ruoyi.demo.controller;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.RedisUtils;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.utils.redis.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
@@ -23,7 +22,7 @@
// 绫荤骇鍒� 缂撳瓨缁熶竴閰嶇疆
//@CacheConfig(cacheNames = "redissonCacheMap")
@Api(value = "spring-cache 婕旂ず妗堜緥", tags = {"spring-cache 婕旂ず妗堜緥"})
-@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/cache")
public class RedisCacheController {
@@ -45,8 +44,8 @@
@ApiOperation("娴嬭瘯 @Cacheable")
@Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test1")
- public AjaxResult<String> test1(String key, String value) {
- return AjaxResult.success("鎿嶄綔鎴愬姛", value);
+ public R<String> test1(String key, String value) {
+ return R.ok("鎿嶄綔鎴愬姛", value);
}
/**
@@ -60,8 +59,8 @@
@ApiOperation("娴嬭瘯 @CachePut")
@CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test2")
- public AjaxResult<String> test2(String key, String value) {
- return AjaxResult.success("鎿嶄綔鎴愬姛", value);
+ public R<String> test2(String key, String value) {
+ return R.ok("鎿嶄綔鎴愬姛", value);
}
/**
@@ -75,8 +74,8 @@
@ApiOperation("娴嬭瘯 @CacheEvict")
@CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test3")
- public AjaxResult<String> test3(String key, String value) {
- return AjaxResult.success("鎿嶄綔鎴愬姛", value);
+ public R<String> test3(String key, String value) {
+ return R.ok("鎿嶄綔鎴愬姛", value);
}
/**
@@ -86,7 +85,7 @@
*/
@ApiOperation("娴嬭瘯璁剧疆杩囨湡鏃堕棿")
@GetMapping("/test6")
- public AjaxResult<Boolean> test6(String key, String value) {
+ public R<Boolean> test6(String key, String value) {
RedisUtils.setCacheObject(key, value);
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
System.out.println("***********" + flag);
@@ -96,7 +95,7 @@
e.printStackTrace();
}
Object obj = RedisUtils.getCacheObject(key);
- return AjaxResult.success("鎿嶄綔鎴愬姛", value.equals(obj));
+ return R.ok(value.equals(obj));
}
}
--
Gitblit v1.9.3