Commit a7067ea6fd872e114640acb8ef949700436394b1
1 parent
797be107
feature(Redis监控): 添加缓存列表
Showing
3 changed files
with
18 additions
and
15 deletions
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 { |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | @GetMapping("/get-key-list") |
| 46 | - @ApiOperation("获得 Redis Key 列表") | |
| 46 | + @ApiOperation("获得 Redis Key 模板列表") | |
| 47 | 47 | @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") |
| 48 | 48 | public CommonResult<List<RedisKeyRespVO>> getKeyList() { |
| 49 | 49 | List<RedisKeyDefine> keyDefines = RedisKeyRegistry.list(); |
| ... | ... | @@ -51,37 +51,40 @@ public class RedisController { |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | @GetMapping("/get-key/{keyDefine}") |
| 54 | - @ApiOperation("获得 Redis Key") | |
| 55 | -// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") | |
| 54 | + @ApiOperation("获得 Redis keys 键名列表") | |
| 55 | + @PreAuthorize("@ss.hasPermission('infra:redis:get-key-define')") | |
| 56 | 56 | public CommonResult<Set<String>> getKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { |
| 57 | 57 | Set<String> Keys = stringRedisTemplate.keys(keyDefine + "*"); |
| 58 | 58 | return success(Keys); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | @DeleteMapping("/clear-key/{keyDefine}") |
| 62 | - @ApiOperation("获得 Redis Key") | |
| 63 | -// @PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')") | |
| 62 | + @ApiOperation("删除 Redis Key 根据模板") | |
| 63 | + @PreAuthorize("@ss.hasPermission('infra:redis:clear-key-define')") | |
| 64 | 64 | public CommonResult<Boolean> clearKeyDefineKeys(@PathVariable("keyDefine") String keyDefine) { |
| 65 | 65 | stringRedisTemplate.delete(Objects.requireNonNull(stringRedisTemplate.keys(keyDefine + "*"))); |
| 66 | 66 | return success(Boolean.TRUE); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | |
| 70 | - @GetMapping("/get-key/{cacheName}/{cacheKey}") | |
| 71 | - public CommonResult<RedisValuesRespVO> getKeyValue(@PathVariable("cacheName") String cacheName, @PathVariable("cacheKey") String cacheKey) { | |
| 69 | + @GetMapping("/get-key/{keyDefine}/{cacheKey}") | |
| 70 | + @ApiOperation("获得 Redis key 内容") | |
| 71 | + @PreAuthorize("@ss.hasPermission('infra:redis:get-key-value')") | |
| 72 | + public CommonResult<RedisValuesRespVO> getKeyValue(@PathVariable("keyDefine") String keyDefine, @PathVariable("cacheKey") String cacheKey) { | |
| 72 | 73 | String cacheValue = stringRedisTemplate.opsForValue().get(cacheKey); |
| 73 | - return success(new RedisValuesRespVO(cacheName, cacheKey, cacheValue)); | |
| 74 | + return success(new RedisValuesRespVO(keyDefine, cacheKey, cacheValue)); | |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | |
| 77 | - @DeleteMapping("/clearCacheKey/{cacheKey}") | |
| 77 | + @DeleteMapping("/clear-key/{cacheKey}") | |
| 78 | + @ApiOperation("删除 Redis Key 根据key") | |
| 79 | + @PreAuthorize("@ss.hasPermission('infra:redis:clear-key-value')") | |
| 78 | 80 | public CommonResult<Boolean> clearCacheKey(@PathVariable String cacheKey) { |
| 79 | 81 | stringRedisTemplate.delete(cacheKey); |
| 80 | 82 | return success(Boolean.TRUE); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | -// @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | |
| 84 | - @DeleteMapping("/clearCacheAll") | |
| 85 | + @DeleteMapping("/clear-cache-all") | |
| 86 | + @ApiOperation(value="删除 所有缓存", notes="不使用该接口") | |
| 87 | + @PreAuthorize("@ss.hasPermission('infra:redis:clear-cache-all')") | |
| 85 | 88 | public CommonResult<Boolean> clearCacheAll() { |
| 86 | 89 | Collection<String> cacheKeys = stringRedisTemplate.keys("*"); |
| 87 | 90 | stringRedisTemplate.delete(cacheKeys); | ... | ... |
yudao-ui-admin/src/api/infra/redis.js