diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/redis/RedisController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/redis/RedisController.java index 500261cd5..013145b96 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/redis/RedisController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/redis/RedisController.java @@ -43,7 +43,7 @@ public class RedisController { } @GetMapping("/get-key-list") - @ApiOperation("获得 Redis Key 列表") + @ApiOperation("获得 Redis Key 模板列表") @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") public CommonResult> getKeyList() { List keyDefines = RedisKeyRegistry.list(); @@ -51,37 +51,40 @@ public class RedisController { } @GetMapping("/get-key/{keyDefine}") - @ApiOperation("获得 Redis Key") -// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") + @ApiOperation("获得 Redis keys 键名列表") + @PreAuthorize("@ss.hasPermission('infra:redis:get-key-define')") public CommonResult> getKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { Set Keys = stringRedisTemplate.keys(keyDefine + "*"); return success(Keys); } @DeleteMapping("/clear-key/{keyDefine}") - @ApiOperation("获得 Redis Key") -// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") + @ApiOperation("删除 Redis Key 根据模板") + @PreAuthorize("@ss.hasPermission('infra:redis:clear-key-define')") public CommonResult clearKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { stringRedisTemplate.delete(Objects.requireNonNull(stringRedisTemplate.keys(keyDefine + "*"))); return success(Boolean.TRUE); } -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") - @GetMapping("/get-key/{cacheName}/{cacheKey}") - public CommonResult getKeyValue(@PathVariable("cacheName") String cacheName, @PathVariable("cacheKey") String cacheKey) { + @GetMapping("/get-key/{keyDefine}/{cacheKey}") + @ApiOperation("获得 Redis key 内容") + @PreAuthorize("@ss.hasPermission('infra:redis:get-key-value')") + public CommonResult getKeyValue(@PathVariable("keyDefine") String keyDefine, @PathVariable("cacheKey") String cacheKey) { String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey); - return success(new RedisValuesRespVO(cacheName, cacheKey, cacheValue)); + return success(new RedisValuesRespVO(keyDefine, cacheKey, cacheValue)); } -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") - @DeleteMapping("/clearCacheKey/{cacheKey}") + @DeleteMapping("/clear-key/{cacheKey}") + @ApiOperation("删除 Redis Key 根据key") + @PreAuthorize("@ss.hasPermission('infra:redis:clear-key-value')") public CommonResult clearCacheKey(@PathVariable String cacheKey) { stringRedisTemplate.delete(cacheKey); return success(Boolean.TRUE); } -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") - @DeleteMapping("/clearCacheAll") + @DeleteMapping("/clear-cache-all") + @ApiOperation(value="删除 所有缓存", notes="不使用该接口") + @PreAuthorize("@ss.hasPermission('infra:redis:clear-cache-all')") public CommonResult clearCacheAll() { Collection cacheKeys = stringRedisTemplate.keys("*"); stringRedisTemplate.delete(cacheKeys); diff --git a/yudao-ui-admin/src/api/infra/redis.js b/yudao-ui-admin/src/api/infra/redis.js index a4ea1b63c..2064dfc68 100644 --- a/yudao-ui-admin/src/api/infra/redis.js +++ b/yudao-ui-admin/src/api/infra/redis.js @@ -35,7 +35,7 @@ export function getKeyValue(keyDefine, key) { // 根据键名删除缓存 export function clearCacheKey(key) { return request({ - url: '/infra/redis/clearCacheKey/' + key, + url: '/infra/redis/clear-key/' + key, method: 'delete' }) } diff --git a/yudao-ui-admin/src/views/infra/redis/index.vue b/yudao-ui-admin/src/views/infra/redis/index.vue index 53abf17b2..763f605ed 100644 --- a/yudao-ui-admin/src/views/infra/redis/index.vue +++ b/yudao-ui-admin/src/views/infra/redis/index.vue @@ -93,7 +93,7 @@