正在显示
18 个修改的文件
包含
522 行增加
和
69 行删除
| @@ -6,12 +6,13 @@ import java.util.concurrent.TimeUnit; | @@ -6,12 +6,13 @@ import java.util.concurrent.TimeUnit; | ||
| 6 | import javax.annotation.Resource; | 6 | import javax.annotation.Resource; |
| 7 | import javax.imageio.ImageIO; | 7 | import javax.imageio.ImageIO; |
| 8 | import javax.servlet.http.HttpServletResponse; | 8 | import javax.servlet.http.HttpServletResponse; |
| 9 | -import com.ruoyi.common.config.RuoYiConfig; | ||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.util.FastByteArrayOutputStream; | 10 | import org.springframework.util.FastByteArrayOutputStream; |
| 12 | import org.springframework.web.bind.annotation.GetMapping; | 11 | import org.springframework.web.bind.annotation.GetMapping; |
| 13 | import org.springframework.web.bind.annotation.RestController; | 12 | import org.springframework.web.bind.annotation.RestController; |
| 14 | import com.google.code.kaptcha.Producer; | 13 | import com.google.code.kaptcha.Producer; |
| 14 | +import com.ruoyi.common.config.RuoYiConfig; | ||
| 15 | +import com.ruoyi.common.constant.CacheConstants; | ||
| 15 | import com.ruoyi.common.constant.Constants; | 16 | import com.ruoyi.common.constant.Constants; |
| 16 | import com.ruoyi.common.core.domain.AjaxResult; | 17 | import com.ruoyi.common.core.domain.AjaxResult; |
| 17 | import com.ruoyi.common.core.redis.RedisCache; | 18 | import com.ruoyi.common.core.redis.RedisCache; |
| @@ -54,7 +55,7 @@ public class CaptchaController | @@ -54,7 +55,7 @@ public class CaptchaController | ||
| 54 | 55 | ||
| 55 | // 保存验证码信息 | 56 | // 保存验证码信息 |
| 56 | String uuid = IdUtils.simpleUUID(); | 57 | String uuid = IdUtils.simpleUUID(); |
| 57 | - String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; | 58 | + String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| 58 | 59 | ||
| 59 | String capStr = null, code = null; | 60 | String capStr = null, code = null; |
| 60 | BufferedImage image = null; | 61 | BufferedImage image = null; |
| 1 | package com.ruoyi.web.controller.monitor; | 1 | package com.ruoyi.web.controller.monitor; |
| 2 | 2 | ||
| 3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
| 4 | +import java.util.Collection; | ||
| 4 | import java.util.HashMap; | 5 | import java.util.HashMap; |
| 5 | import java.util.List; | 6 | import java.util.List; |
| 6 | import java.util.Map; | 7 | import java.util.Map; |
| 7 | import java.util.Properties; | 8 | import java.util.Properties; |
| 9 | +import java.util.Set; | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.data.redis.core.RedisCallback; | 11 | import org.springframework.data.redis.core.RedisCallback; |
| 10 | import org.springframework.data.redis.core.RedisTemplate; | 12 | import org.springframework.data.redis.core.RedisTemplate; |
| 11 | import org.springframework.security.access.prepost.PreAuthorize; | 13 | import org.springframework.security.access.prepost.PreAuthorize; |
| 14 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 12 | import org.springframework.web.bind.annotation.GetMapping; | 15 | import org.springframework.web.bind.annotation.GetMapping; |
| 16 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 13 | import org.springframework.web.bind.annotation.RequestMapping; | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| 14 | import org.springframework.web.bind.annotation.RestController; | 18 | import org.springframework.web.bind.annotation.RestController; |
| 19 | +import com.ruoyi.common.constant.CacheConstants; | ||
| 15 | import com.ruoyi.common.core.domain.AjaxResult; | 20 | import com.ruoyi.common.core.domain.AjaxResult; |
| 16 | import com.ruoyi.common.utils.StringUtils; | 21 | import com.ruoyi.common.utils.StringUtils; |
| 22 | +import com.ruoyi.system.domain.SysCache; | ||
| 17 | 23 | ||
| 18 | /** | 24 | /** |
| 19 | * 缓存监控 | 25 | * 缓存监控 |
| @@ -27,6 +33,16 @@ public class CacheController | @@ -27,6 +33,16 @@ public class CacheController | ||
| 27 | @Autowired | 33 | @Autowired |
| 28 | private RedisTemplate<String, String> redisTemplate; | 34 | private RedisTemplate<String, String> redisTemplate; |
| 29 | 35 | ||
| 36 | + private final static List<SysCache> caches = new ArrayList<SysCache>(); | ||
| 37 | + { | ||
| 38 | + caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息")); | ||
| 39 | + caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息")); | ||
| 40 | + caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典")); | ||
| 41 | + caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码")); | ||
| 42 | + caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); | ||
| 43 | + caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); | ||
| 44 | + } | ||
| 45 | + | ||
| 30 | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | 46 | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| 31 | @GetMapping() | 47 | @GetMapping() |
| 32 | public AjaxResult getInfo() throws Exception | 48 | public AjaxResult getInfo() throws Exception |
| @@ -50,4 +66,54 @@ public class CacheController | @@ -50,4 +66,54 @@ public class CacheController | ||
| 50 | result.put("commandStats", pieList); | 66 | result.put("commandStats", pieList); |
| 51 | return AjaxResult.success(result); | 67 | return AjaxResult.success(result); |
| 52 | } | 68 | } |
| 69 | + | ||
| 70 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 71 | + @GetMapping("/getNames") | ||
| 72 | + public AjaxResult cache() | ||
| 73 | + { | ||
| 74 | + return AjaxResult.success(caches); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 78 | + @GetMapping("/getKeys/{cacheName}") | ||
| 79 | + public AjaxResult getCacheKeys(@PathVariable String cacheName) | ||
| 80 | + { | ||
| 81 | + Set<String> cacheKyes = redisTemplate.keys(cacheName + "*"); | ||
| 82 | + return AjaxResult.success(cacheKyes); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 86 | + @GetMapping("/getValue/{cacheName}/{cacheKey}") | ||
| 87 | + public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) | ||
| 88 | + { | ||
| 89 | + String cacheValue = redisTemplate.opsForValue().get(cacheKey); | ||
| 90 | + SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); | ||
| 91 | + return AjaxResult.success(sysCache); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 95 | + @DeleteMapping("/clearCacheName/{cacheName}") | ||
| 96 | + public AjaxResult clearCacheName(@PathVariable String cacheName) | ||
| 97 | + { | ||
| 98 | + Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); | ||
| 99 | + redisTemplate.delete(cacheKeys); | ||
| 100 | + return AjaxResult.success(); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 104 | + @DeleteMapping("/clearCacheKey/{cacheKey}") | ||
| 105 | + public AjaxResult clearCacheKey(@PathVariable String cacheKey) | ||
| 106 | + { | ||
| 107 | + redisTemplate.delete(cacheKey); | ||
| 108 | + return AjaxResult.success(); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||
| 112 | + @DeleteMapping("/clearCacheAll") | ||
| 113 | + public AjaxResult clearCacheAll() | ||
| 114 | + { | ||
| 115 | + Collection<String> cacheKeys = redisTemplate.keys("*"); | ||
| 116 | + redisTemplate.delete(cacheKeys); | ||
| 117 | + return AjaxResult.success(); | ||
| 118 | + } | ||
| 53 | } | 119 | } |
| @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.PathVariable; | @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.PathVariable; | ||
| 12 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
| 14 | import com.ruoyi.common.annotation.Log; | 14 | import com.ruoyi.common.annotation.Log; |
| 15 | -import com.ruoyi.common.constant.Constants; | 15 | +import com.ruoyi.common.constant.CacheConstants; |
| 16 | import com.ruoyi.common.core.controller.BaseController; | 16 | import com.ruoyi.common.core.controller.BaseController; |
| 17 | import com.ruoyi.common.core.domain.AjaxResult; | 17 | import com.ruoyi.common.core.domain.AjaxResult; |
| 18 | import com.ruoyi.common.core.domain.model.LoginUser; | 18 | import com.ruoyi.common.core.domain.model.LoginUser; |
| @@ -42,7 +42,7 @@ public class SysUserOnlineController extends BaseController | @@ -42,7 +42,7 @@ public class SysUserOnlineController extends BaseController | ||
| 42 | @GetMapping("/list") | 42 | @GetMapping("/list") |
| 43 | public TableDataInfo list(String ipaddr, String userName) | 43 | public TableDataInfo list(String ipaddr, String userName) |
| 44 | { | 44 | { |
| 45 | - Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*"); | 45 | + Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); |
| 46 | List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); | 46 | List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); |
| 47 | for (String key : keys) | 47 | for (String key : keys) |
| 48 | { | 48 | { |
| @@ -86,7 +86,7 @@ public class SysUserOnlineController extends BaseController | @@ -86,7 +86,7 @@ public class SysUserOnlineController extends BaseController | ||
| 86 | @DeleteMapping("/{tokenId}") | 86 | @DeleteMapping("/{tokenId}") |
| 87 | public AjaxResult forceLogout(@PathVariable String tokenId) | 87 | public AjaxResult forceLogout(@PathVariable String tokenId) |
| 88 | { | 88 | { |
| 89 | - redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId); | 89 | + redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); |
| 90 | return AjaxResult.success(); | 90 | return AjaxResult.success(); |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| @@ -5,7 +5,7 @@ import java.lang.annotation.ElementType; | @@ -5,7 +5,7 @@ import java.lang.annotation.ElementType; | ||
| 5 | import java.lang.annotation.Retention; | 5 | import java.lang.annotation.Retention; |
| 6 | import java.lang.annotation.RetentionPolicy; | 6 | import java.lang.annotation.RetentionPolicy; |
| 7 | import java.lang.annotation.Target; | 7 | import java.lang.annotation.Target; |
| 8 | -import com.ruoyi.common.constant.Constants; | 8 | +import com.ruoyi.common.constant.CacheConstants; |
| 9 | import com.ruoyi.common.enums.LimitType; | 9 | import com.ruoyi.common.enums.LimitType; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -21,7 +21,7 @@ public @interface RateLimiter | @@ -21,7 +21,7 @@ public @interface RateLimiter | ||
| 21 | /** | 21 | /** |
| 22 | * 限流key | 22 | * 限流key |
| 23 | */ | 23 | */ |
| 24 | - public String key() default Constants.RATE_LIMIT_KEY; | 24 | + public String key() default CacheConstants.RATE_LIMIT_KEY; |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * 限流时间,单位秒 | 27 | * 限流时间,单位秒 |
| 1 | +package com.ruoyi.common.constant; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 缓存的key 常量 | ||
| 5 | + * | ||
| 6 | + * @author ruoyi | ||
| 7 | + */ | ||
| 8 | +public class CacheConstants | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * 登录用户 redis key | ||
| 12 | + */ | ||
| 13 | + public static final String LOGIN_TOKEN_KEY = "login_tokens:"; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 验证码 redis key | ||
| 17 | + */ | ||
| 18 | + public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 参数管理 cache key | ||
| 22 | + */ | ||
| 23 | + public static final String SYS_CONFIG_KEY = "sys_config:"; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 字典管理 cache key | ||
| 27 | + */ | ||
| 28 | + public static final String SYS_DICT_KEY = "sys_dict:"; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 防重提交 redis key | ||
| 32 | + */ | ||
| 33 | + public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 限流 redis key | ||
| 37 | + */ | ||
| 38 | + public static final String RATE_LIMIT_KEY = "rate_limit:"; | ||
| 39 | +} |
| @@ -58,27 +58,7 @@ public class Constants | @@ -58,27 +58,7 @@ public class Constants | ||
| 58 | * 登录失败 | 58 | * 登录失败 |
| 59 | */ | 59 | */ |
| 60 | public static final String LOGIN_FAIL = "Error"; | 60 | public static final String LOGIN_FAIL = "Error"; |
| 61 | - | ||
| 62 | - /** | ||
| 63 | - * 验证码 redis key | ||
| 64 | - */ | ||
| 65 | - public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | - * 登录用户 redis key | ||
| 69 | - */ | ||
| 70 | - public static final String LOGIN_TOKEN_KEY = "login_tokens:"; | ||
| 71 | - | ||
| 72 | - /** | ||
| 73 | - * 防重提交 redis key | ||
| 74 | - */ | ||
| 75 | - public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * 限流 redis key | ||
| 79 | - */ | ||
| 80 | - public static final String RATE_LIMIT_KEY = "rate_limit:"; | ||
| 81 | - | 61 | + |
| 82 | /** | 62 | /** |
| 83 | * 验证码有效期(分钟) | 63 | * 验证码有效期(分钟) |
| 84 | */ | 64 | */ |
| @@ -125,16 +105,6 @@ public class Constants | @@ -125,16 +105,6 @@ public class Constants | ||
| 125 | public static final String JWT_AUTHORITIES = "authorities"; | 105 | public static final String JWT_AUTHORITIES = "authorities"; |
| 126 | 106 | ||
| 127 | /** | 107 | /** |
| 128 | - * 参数管理 cache key | ||
| 129 | - */ | ||
| 130 | - public static final String SYS_CONFIG_KEY = "sys_config:"; | ||
| 131 | - | ||
| 132 | - /** | ||
| 133 | - * 字典管理 cache key | ||
| 134 | - */ | ||
| 135 | - public static final String SYS_DICT_KEY = "sys_dict:"; | ||
| 136 | - | ||
| 137 | - /** | ||
| 138 | * 资源映射路径 前缀 | 108 | * 资源映射路径 前缀 |
| 139 | */ | 109 | */ |
| 140 | public static final String RESOURCE_PREFIX = "/profile"; | 110 | public static final String RESOURCE_PREFIX = "/profile"; |
| @@ -3,7 +3,7 @@ package com.ruoyi.common.utils; | @@ -3,7 +3,7 @@ package com.ruoyi.common.utils; | ||
| 3 | import java.util.Collection; | 3 | import java.util.Collection; |
| 4 | import java.util.List; | 4 | import java.util.List; |
| 5 | import com.alibaba.fastjson2.JSONArray; | 5 | import com.alibaba.fastjson2.JSONArray; |
| 6 | -import com.ruoyi.common.constant.Constants; | 6 | +import com.ruoyi.common.constant.CacheConstants; |
| 7 | import com.ruoyi.common.core.domain.entity.SysDictData; | 7 | import com.ruoyi.common.core.domain.entity.SysDictData; |
| 8 | import com.ruoyi.common.core.redis.RedisCache; | 8 | import com.ruoyi.common.core.redis.RedisCache; |
| 9 | import com.ruoyi.common.utils.spring.SpringUtils; | 9 | import com.ruoyi.common.utils.spring.SpringUtils; |
| @@ -169,7 +169,7 @@ public class DictUtils | @@ -169,7 +169,7 @@ public class DictUtils | ||
| 169 | */ | 169 | */ |
| 170 | public static void clearDictCache() | 170 | public static void clearDictCache() |
| 171 | { | 171 | { |
| 172 | - Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*"); | 172 | + Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*"); |
| 173 | SpringUtils.getBean(RedisCache.class).deleteObject(keys); | 173 | SpringUtils.getBean(RedisCache.class).deleteObject(keys); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| @@ -181,6 +181,6 @@ public class DictUtils | @@ -181,6 +181,6 @@ public class DictUtils | ||
| 181 | */ | 181 | */ |
| 182 | public static String getCacheKey(String configKey) | 182 | public static String getCacheKey(String configKey) |
| 183 | { | 183 | { |
| 184 | - return Constants.SYS_DICT_KEY + configKey; | 184 | + return CacheConstants.SYS_DICT_KEY + configKey; |
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Value; | @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Value; | ||
| 9 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
| 10 | import com.alibaba.fastjson2.JSON; | 10 | import com.alibaba.fastjson2.JSON; |
| 11 | import com.ruoyi.common.annotation.RepeatSubmit; | 11 | import com.ruoyi.common.annotation.RepeatSubmit; |
| 12 | -import com.ruoyi.common.constant.Constants; | 12 | +import com.ruoyi.common.constant.CacheConstants; |
| 13 | import com.ruoyi.common.core.redis.RedisCache; | 13 | import com.ruoyi.common.core.redis.RedisCache; |
| 14 | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; | 14 | import com.ruoyi.common.filter.RepeatedlyRequestWrapper; |
| 15 | import com.ruoyi.common.utils.StringUtils; | 15 | import com.ruoyi.common.utils.StringUtils; |
| @@ -63,7 +63,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor | @@ -63,7 +63,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor | ||
| 63 | String submitKey = StringUtils.trimToEmpty(request.getHeader(header)); | 63 | String submitKey = StringUtils.trimToEmpty(request.getHeader(header)); |
| 64 | 64 | ||
| 65 | // 唯一标识(指定key + url + 消息头) | 65 | // 唯一标识(指定key + url + 消息头) |
| 66 | - String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey; | 66 | + String cacheRepeatKey = CacheConstants.REPEAT_SUBMIT_KEY + url + submitKey; |
| 67 | 67 | ||
| 68 | Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); | 68 | Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); |
| 69 | if (sessionObj != null) | 69 | if (sessionObj != null) |
| @@ -7,6 +7,7 @@ import org.springframework.security.authentication.BadCredentialsException; | @@ -7,6 +7,7 @@ import org.springframework.security.authentication.BadCredentialsException; | ||
| 7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | 7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| 8 | import org.springframework.security.core.Authentication; | 8 | import org.springframework.security.core.Authentication; |
| 9 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
| 10 | +import com.ruoyi.common.constant.CacheConstants; | ||
| 10 | import com.ruoyi.common.constant.Constants; | 11 | import com.ruoyi.common.constant.Constants; |
| 11 | import com.ruoyi.common.core.domain.entity.SysUser; | 12 | import com.ruoyi.common.core.domain.entity.SysUser; |
| 12 | import com.ruoyi.common.core.domain.model.LoginUser; | 13 | import com.ruoyi.common.core.domain.model.LoginUser; |
| @@ -17,8 +18,8 @@ import com.ruoyi.common.exception.user.CaptchaExpireException; | @@ -17,8 +18,8 @@ import com.ruoyi.common.exception.user.CaptchaExpireException; | ||
| 17 | import com.ruoyi.common.exception.user.UserPasswordNotMatchException; | 18 | import com.ruoyi.common.exception.user.UserPasswordNotMatchException; |
| 18 | import com.ruoyi.common.utils.DateUtils; | 19 | import com.ruoyi.common.utils.DateUtils; |
| 19 | import com.ruoyi.common.utils.MessageUtils; | 20 | import com.ruoyi.common.utils.MessageUtils; |
| 20 | -import com.ruoyi.common.utils.StringUtils; | ||
| 21 | import com.ruoyi.common.utils.ServletUtils; | 21 | import com.ruoyi.common.utils.ServletUtils; |
| 22 | +import com.ruoyi.common.utils.StringUtils; | ||
| 22 | import com.ruoyi.common.utils.ip.IpUtils; | 23 | import com.ruoyi.common.utils.ip.IpUtils; |
| 23 | import com.ruoyi.framework.manager.AsyncManager; | 24 | import com.ruoyi.framework.manager.AsyncManager; |
| 24 | import com.ruoyi.framework.manager.factory.AsyncFactory; | 25 | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| @@ -103,7 +104,7 @@ public class SysLoginService | @@ -103,7 +104,7 @@ public class SysLoginService | ||
| 103 | */ | 104 | */ |
| 104 | public void validateCaptcha(String username, String code, String uuid) | 105 | public void validateCaptcha(String username, String code, String uuid) |
| 105 | { | 106 | { |
| 106 | - String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); | 107 | + String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); |
| 107 | String captcha = redisCache.getCacheObject(verifyKey); | 108 | String captcha = redisCache.getCacheObject(verifyKey); |
| 108 | redisCache.deleteObject(verifyKey); | 109 | redisCache.deleteObject(verifyKey); |
| 109 | if (captcha == null) | 110 | if (captcha == null) |
| @@ -2,6 +2,7 @@ package com.ruoyi.framework.web.service; | @@ -2,6 +2,7 @@ package com.ruoyi.framework.web.service; | ||
| 2 | 2 | ||
| 3 | import org.springframework.beans.factory.annotation.Autowired; | 3 | import org.springframework.beans.factory.annotation.Autowired; |
| 4 | import org.springframework.stereotype.Component; | 4 | import org.springframework.stereotype.Component; |
| 5 | +import com.ruoyi.common.constant.CacheConstants; | ||
| 5 | import com.ruoyi.common.constant.Constants; | 6 | import com.ruoyi.common.constant.Constants; |
| 6 | import com.ruoyi.common.constant.UserConstants; | 7 | import com.ruoyi.common.constant.UserConstants; |
| 7 | import com.ruoyi.common.core.domain.entity.SysUser; | 8 | import com.ruoyi.common.core.domain.entity.SysUser; |
| @@ -100,7 +101,7 @@ public class SysRegisterService | @@ -100,7 +101,7 @@ public class SysRegisterService | ||
| 100 | */ | 101 | */ |
| 101 | public void validateCaptcha(String username, String code, String uuid) | 102 | public void validateCaptcha(String username, String code, String uuid) |
| 102 | { | 103 | { |
| 103 | - String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); | 104 | + String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); |
| 104 | String captcha = redisCache.getCacheObject(verifyKey); | 105 | String captcha = redisCache.getCacheObject(verifyKey); |
| 105 | redisCache.deleteObject(verifyKey); | 106 | redisCache.deleteObject(verifyKey); |
| 106 | if (captcha == null) | 107 | if (captcha == null) |
| @@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest; | @@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest; | ||
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | import org.springframework.beans.factory.annotation.Value; | 8 | import org.springframework.beans.factory.annotation.Value; |
| 9 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
| 10 | +import com.ruoyi.common.constant.CacheConstants; | ||
| 10 | import com.ruoyi.common.constant.Constants; | 11 | import com.ruoyi.common.constant.Constants; |
| 11 | import com.ruoyi.common.core.domain.model.LoginUser; | 12 | import com.ruoyi.common.core.domain.model.LoginUser; |
| 12 | import com.ruoyi.common.core.redis.RedisCache; | 13 | import com.ruoyi.common.core.redis.RedisCache; |
| @@ -220,6 +221,6 @@ public class TokenService | @@ -220,6 +221,6 @@ public class TokenService | ||
| 220 | 221 | ||
| 221 | private String getTokenKey(String uuid) | 222 | private String getTokenKey(String uuid) |
| 222 | { | 223 | { |
| 223 | - return Constants.LOGIN_TOKEN_KEY + uuid; | 224 | + return CacheConstants.LOGIN_TOKEN_KEY + uuid; |
| 224 | } | 225 | } |
| 225 | } | 226 | } |
| 1 | +package com.ruoyi.system.domain; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.utils.StringUtils; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 缓存信息 | ||
| 7 | + * | ||
| 8 | + * @author ruoyi | ||
| 9 | + */ | ||
| 10 | +public class SysCache | ||
| 11 | +{ | ||
| 12 | + /** 缓存名称 */ | ||
| 13 | + private String cacheName = ""; | ||
| 14 | + | ||
| 15 | + /** 缓存键名 */ | ||
| 16 | + private String cacheKey = ""; | ||
| 17 | + | ||
| 18 | + /** 缓存内容 */ | ||
| 19 | + private String cacheValue = ""; | ||
| 20 | + | ||
| 21 | + /** 备注 */ | ||
| 22 | + private String remark = ""; | ||
| 23 | + | ||
| 24 | + public SysCache() | ||
| 25 | + { | ||
| 26 | + | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public SysCache(String cacheName, String remark) | ||
| 30 | + { | ||
| 31 | + this.cacheName = cacheName; | ||
| 32 | + this.remark = remark; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public SysCache(String cacheName, String cacheKey, String cacheValue) | ||
| 36 | + { | ||
| 37 | + this.cacheName = StringUtils.replace(cacheName, ":", ""); | ||
| 38 | + this.cacheKey = StringUtils.replace(cacheKey, cacheName, ""); | ||
| 39 | + this.cacheValue = cacheValue; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public String getCacheName() | ||
| 43 | + { | ||
| 44 | + return cacheName; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setCacheName(String cacheName) | ||
| 48 | + { | ||
| 49 | + this.cacheName = cacheName; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public String getCacheKey() | ||
| 53 | + { | ||
| 54 | + return cacheKey; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setCacheKey(String cacheKey) | ||
| 58 | + { | ||
| 59 | + this.cacheKey = cacheKey; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public String getCacheValue() | ||
| 63 | + { | ||
| 64 | + return cacheValue; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setCacheValue(String cacheValue) | ||
| 68 | + { | ||
| 69 | + this.cacheValue = cacheValue; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public String getRemark() | ||
| 73 | + { | ||
| 74 | + return remark; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setRemark(String remark) | ||
| 78 | + { | ||
| 79 | + this.remark = remark; | ||
| 80 | + } | ||
| 81 | +} |
| 1 | package com.ruoyi.system.service.impl; | 1 | package com.ruoyi.system.service.impl; |
| 2 | 2 | ||
| 3 | +import java.util.Collection; | ||
| 4 | +import java.util.List; | ||
| 5 | +import javax.annotation.PostConstruct; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 3 | import com.ruoyi.common.annotation.DataSource; | 8 | import com.ruoyi.common.annotation.DataSource; |
| 4 | -import com.ruoyi.common.constant.Constants; | 9 | +import com.ruoyi.common.constant.CacheConstants; |
| 5 | import com.ruoyi.common.constant.UserConstants; | 10 | import com.ruoyi.common.constant.UserConstants; |
| 6 | import com.ruoyi.common.core.redis.RedisCache; | 11 | import com.ruoyi.common.core.redis.RedisCache; |
| 7 | import com.ruoyi.common.core.text.Convert; | 12 | import com.ruoyi.common.core.text.Convert; |
| @@ -11,11 +16,6 @@ import com.ruoyi.common.utils.StringUtils; | @@ -11,11 +16,6 @@ import com.ruoyi.common.utils.StringUtils; | ||
| 11 | import com.ruoyi.system.domain.SysConfig; | 16 | import com.ruoyi.system.domain.SysConfig; |
| 12 | import com.ruoyi.system.mapper.SysConfigMapper; | 17 | import com.ruoyi.system.mapper.SysConfigMapper; |
| 13 | import com.ruoyi.system.service.ISysConfigService; | 18 | import com.ruoyi.system.service.ISysConfigService; |
| 14 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | -import org.springframework.stereotype.Service; | ||
| 16 | -import javax.annotation.PostConstruct; | ||
| 17 | -import java.util.Collection; | ||
| 18 | -import java.util.List; | ||
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | * 参数配置 服务层实现 | 21 | * 参数配置 服务层实现 |
| @@ -181,7 +181,7 @@ public class SysConfigServiceImpl implements ISysConfigService | @@ -181,7 +181,7 @@ public class SysConfigServiceImpl implements ISysConfigService | ||
| 181 | @Override | 181 | @Override |
| 182 | public void clearConfigCache() | 182 | public void clearConfigCache() |
| 183 | { | 183 | { |
| 184 | - Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); | 184 | + Collection<String> keys = redisCache.keys(CacheConstants.SYS_CONFIG_KEY + "*"); |
| 185 | redisCache.deleteObject(keys); | 185 | redisCache.deleteObject(keys); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| @@ -221,6 +221,6 @@ public class SysConfigServiceImpl implements ISysConfigService | @@ -221,6 +221,6 @@ public class SysConfigServiceImpl implements ISysConfigService | ||
| 221 | */ | 221 | */ |
| 222 | private String getCacheKey(String configKey) | 222 | private String getCacheKey(String configKey) |
| 223 | { | 223 | { |
| 224 | - return Constants.SYS_CONFIG_KEY + configKey; | 224 | + return CacheConstants.SYS_CONFIG_KEY + configKey; |
| 225 | } | 225 | } |
| 226 | } | 226 | } |
| @@ -7,3 +7,51 @@ export function getCache() { | @@ -7,3 +7,51 @@ export function getCache() { | ||
| 7 | method: 'get' | 7 | method: 'get' |
| 8 | }) | 8 | }) |
| 9 | } | 9 | } |
| 10 | + | ||
| 11 | +// 查询缓存名称列表 | ||
| 12 | +export function listCacheName() { | ||
| 13 | + return request({ | ||
| 14 | + url: '/monitor/cache/getNames', | ||
| 15 | + method: 'get' | ||
| 16 | + }) | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +// 查询缓存键名列表 | ||
| 20 | +export function listCacheKey(cacheName) { | ||
| 21 | + return request({ | ||
| 22 | + url: '/monitor/cache/getKeys/' + cacheName, | ||
| 23 | + method: 'get' | ||
| 24 | + }) | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// 查询缓存内容 | ||
| 28 | +export function getCacheValue(cacheName, cacheKey) { | ||
| 29 | + return request({ | ||
| 30 | + url: '/monitor/cache/getValue/' + cacheName + '/' + cacheKey, | ||
| 31 | + method: 'get' | ||
| 32 | + }) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +// 清理指定名称缓存 | ||
| 36 | +export function clearCacheName(cacheName) { | ||
| 37 | + return request({ | ||
| 38 | + url: '/monitor/cache/clearCacheName/' + cacheName, | ||
| 39 | + method: 'delete' | ||
| 40 | + }) | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// 清理指定键名缓存 | ||
| 44 | +export function clearCacheKey(cacheKey) { | ||
| 45 | + return request({ | ||
| 46 | + url: '/monitor/cache/clearCacheKey/' + cacheKey, | ||
| 47 | + method: 'delete' | ||
| 48 | + }) | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +// 清理全部缓存 | ||
| 52 | +export function clearCacheAll() { | ||
| 53 | + return request({ | ||
| 54 | + url: '/monitor/cache/clearCacheAll', | ||
| 55 | + method: 'delete' | ||
| 56 | + }) | ||
| 57 | +} |
ruoyi-ui/src/assets/icons/svg/redis-list.svg
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1656035183065" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3395" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css">@font-face { font-family: feedback-iconfont; src: url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff2?t=1630033759944") format("woff2"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.woff?t=1630033759944") format("woff"), url("//at.alicdn.com/t/font_1031158_u69w8yhxdu.ttf?t=1630033759944") format("truetype"); } | ||
| 2 | +</style></defs><path d="M958.88 730.06H65.12c-18.28 0-33.12-14.82-33.12-33.12V68.91c0-18.29 14.83-33.12 33.12-33.12h893.77c18.28 0 33.12 14.82 33.12 33.12v628.03c-0.01 18.3-14.84 33.12-33.13 33.12zM98.23 663.83h827.53v-561.8H98.23v561.8z" p-id="3396"></path><path d="M512 954.55c-18.28 0-33.12-14.82-33.12-33.12V733.92c0-18.29 14.83-33.12 33.12-33.12s33.12 14.82 33.12 33.12v187.51c0 18.3-14.84 33.12-33.12 33.12z" p-id="3397"></path><path d="M762.01 988.21H261.99c-18.28 0-33.12-14.82-33.12-33.12 0-18.29 14.83-33.12 33.12-33.12h500.03c18.28 0 33.12 14.82 33.12 33.12-0.01 18.29-14.84 33.12-33.13 33.12zM514.74 578.55c-21.63 0-43.31-3.87-64.21-11.65-45.95-17.13-82.49-51.13-102.86-95.74-5.07-11.08-0.19-24.19 10.89-29.26 11.08-5.09 24.19-0.18 29.26 10.91 15.5 33.88 43.25 59.7 78.14 72.71 34.93 12.99 72.79 11.64 106.66-3.85 33.22-15.17 58.8-42.26 72.03-76.3 4.42-11.37 17.21-17.01 28.57-12.58 11.36 4.42 16.99 17.22 12.57 28.58-17.42 44.82-51.1 80.5-94.82 100.47-24.34 11.12-50.25 16.71-76.23 16.71z" p-id="3398"></path><path d="M325.27 528.78c-1.66 0-3.34-0.18-5.02-0.57-11.88-2.77-19.28-14.63-16.49-26.51l18.84-81c1.34-5.82 5-10.84 10.13-13.92 5.09-3.09 11.3-3.96 17.03-2.41l80.51 21.43c11.79 3.14 18.8 15.23 15.67 27.02-3.15 11.79-15.42 18.75-27.02 15.65l-58.49-15.57-13.69 58.81c-2.37 10.2-11.45 17.07-21.47 17.07zM360.8 351.01c-2.65 0-5.37-0.49-8-1.51-11.36-4.41-16.99-17.21-12.59-28.57 17.4-44.79 51.06-80.47 94.8-100.48 92.15-42.06 201.25-1.39 243.31 90.68 5.07 11.08 0.19 24.19-10.89 29.26-11.13 5.07-24.19 0.17-29.26-10.91-31.97-69.91-114.9-100.82-184.79-68.86-33.22 15.19-58.8 42.28-71.99 76.29-3.41 8.74-11.75 14.1-20.59 14.1z" p-id="3399"></path><path d="M684.68 376.74c-1.47 0-2.95-0.15-4.42-0.44l-81.61-16.68c-11.94-2.45-19.64-14.11-17.21-26.06 2.44-11.96 14.1-19.64 26.04-17.22l59.29 12.12 10.23-59.5c2.05-12 13.52-20.19 25.48-18.01 12.03 2.06 20.09 13.48 18.02 25.5l-14.08 81.96a22.089 22.089 0 0 1-9.29 14.49c-3.7 2.51-8.03 3.84-12.45 3.84z" p-id="3400"></path></svg> |
| @@ -71,7 +71,7 @@ import { getCache } from "@/api/monitor/cache"; | @@ -71,7 +71,7 @@ import { getCache } from "@/api/monitor/cache"; | ||
| 71 | import echarts from "echarts"; | 71 | import echarts from "echarts"; |
| 72 | 72 | ||
| 73 | export default { | 73 | export default { |
| 74 | - name: "Server", | 74 | + name: "Cache", |
| 75 | data() { | 75 | data() { |
| 76 | return { | 76 | return { |
| 77 | // 统计命令信息 | 77 | // 统计命令信息 |
| @@ -79,8 +79,8 @@ export default { | @@ -79,8 +79,8 @@ export default { | ||
| 79 | // 使用内存 | 79 | // 使用内存 |
| 80 | usedmemory: null, | 80 | usedmemory: null, |
| 81 | // cache信息 | 81 | // cache信息 |
| 82 | - cache: [], | ||
| 83 | - }; | 82 | + cache: [] |
| 83 | + } | ||
| 84 | }, | 84 | }, |
| 85 | created() { | 85 | created() { |
| 86 | this.getList(); | 86 | this.getList(); |
| @@ -109,8 +109,8 @@ export default { | @@ -109,8 +109,8 @@ export default { | ||
| 109 | data: response.data.commandStats, | 109 | data: response.data.commandStats, |
| 110 | animationEasing: "cubicInOut", | 110 | animationEasing: "cubicInOut", |
| 111 | animationDuration: 1000, | 111 | animationDuration: 1000, |
| 112 | - }, | ||
| 113 | - ], | 112 | + } |
| 113 | + ] | ||
| 114 | }); | 114 | }); |
| 115 | this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons"); | 115 | this.usedmemory = echarts.init(this.$refs.usedmemory, "macarons"); |
| 116 | this.usedmemory.setOption({ | 116 | this.usedmemory.setOption({ |
| @@ -130,17 +130,17 @@ export default { | @@ -130,17 +130,17 @@ export default { | ||
| 130 | { | 130 | { |
| 131 | value: parseFloat(this.cache.info.used_memory_human), | 131 | value: parseFloat(this.cache.info.used_memory_human), |
| 132 | name: "内存消耗", | 132 | name: "内存消耗", |
| 133 | - }, | ||
| 134 | - ], | ||
| 135 | - }, | ||
| 136 | - ], | 133 | + } |
| 134 | + ] | ||
| 135 | + } | ||
| 136 | + ] | ||
| 137 | }); | 137 | }); |
| 138 | }); | 138 | }); |
| 139 | }, | 139 | }, |
| 140 | // 打开加载层 | 140 | // 打开加载层 |
| 141 | openLoading() { | 141 | openLoading() { |
| 142 | this.$modal.loading("正在加载缓存监控数据,请稍候!"); | 142 | this.$modal.loading("正在加载缓存监控数据,请稍候!"); |
| 143 | - }, | ||
| 144 | - }, | 143 | + } |
| 144 | + } | ||
| 145 | }; | 145 | }; |
| 146 | </script> | 146 | </script> |
ruoyi-ui/src/views/monitor/cache/list.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-row :gutter="10"> | ||
| 4 | + <el-col :span="8"> | ||
| 5 | + <el-card style="height: calc(100vh - 125px)"> | ||
| 6 | + <div slot="header"> | ||
| 7 | + <span>缓存列表</span> | ||
| 8 | + <el-button | ||
| 9 | + style="float: right; padding: 3px 0" | ||
| 10 | + type="text" | ||
| 11 | + icon="el-icon-refresh-right" | ||
| 12 | + @click="refreshCacheNames()" | ||
| 13 | + ></el-button> | ||
| 14 | + </div> | ||
| 15 | + <el-table | ||
| 16 | + v-loading="loading" | ||
| 17 | + :data="cacheNames" | ||
| 18 | + :height="tableHeight" | ||
| 19 | + highlight-current-row | ||
| 20 | + @row-click="getCacheKeys" | ||
| 21 | + style="width: 100%" | ||
| 22 | + > | ||
| 23 | + <el-table-column | ||
| 24 | + label="序号" | ||
| 25 | + width="60" | ||
| 26 | + type="index" | ||
| 27 | + ></el-table-column> | ||
| 28 | + | ||
| 29 | + <el-table-column | ||
| 30 | + label="缓存名称" | ||
| 31 | + align="center" | ||
| 32 | + prop="cacheName" | ||
| 33 | + :show-overflow-tooltip="true" | ||
| 34 | + :formatter="nameFormatter" | ||
| 35 | + ></el-table-column> | ||
| 36 | + | ||
| 37 | + <el-table-column | ||
| 38 | + label="备注" | ||
| 39 | + align="center" | ||
| 40 | + prop="remark" | ||
| 41 | + :show-overflow-tooltip="true" | ||
| 42 | + /> | ||
| 43 | + <el-table-column | ||
| 44 | + label="操作" | ||
| 45 | + width="60" | ||
| 46 | + align="center" | ||
| 47 | + class-name="small-padding fixed-width" | ||
| 48 | + > | ||
| 49 | + <template slot-scope="scope"> | ||
| 50 | + <el-button | ||
| 51 | + size="mini" | ||
| 52 | + type="text" | ||
| 53 | + icon="el-icon-delete" | ||
| 54 | + @click="handleClearCacheName(scope.row)" | ||
| 55 | + ></el-button> | ||
| 56 | + </template> | ||
| 57 | + </el-table-column> | ||
| 58 | + </el-table> | ||
| 59 | + </el-card> | ||
| 60 | + </el-col> | ||
| 61 | + | ||
| 62 | + <el-col :span="8"> | ||
| 63 | + <el-card style="height: calc(100vh - 125px)"> | ||
| 64 | + <div slot="header"> | ||
| 65 | + <span>键名列表</span> | ||
| 66 | + <el-button | ||
| 67 | + style="float: right; padding: 3px 0" | ||
| 68 | + type="text" | ||
| 69 | + icon="el-icon-refresh-right" | ||
| 70 | + @click="refreshCacheKeys()" | ||
| 71 | + ></el-button> | ||
| 72 | + </div> | ||
| 73 | + <el-table | ||
| 74 | + v-loading="subLoading" | ||
| 75 | + :data="cacheKeys" | ||
| 76 | + :height="tableHeight" | ||
| 77 | + highlight-current-row | ||
| 78 | + @row-click="handleCacheValue" | ||
| 79 | + style="width: 100%" | ||
| 80 | + > | ||
| 81 | + <el-table-column | ||
| 82 | + label="序号" | ||
| 83 | + width="60" | ||
| 84 | + type="index" | ||
| 85 | + ></el-table-column> | ||
| 86 | + <el-table-column | ||
| 87 | + label="缓存键名" | ||
| 88 | + align="center" | ||
| 89 | + :show-overflow-tooltip="true" | ||
| 90 | + :formatter="keyFormatter" | ||
| 91 | + > | ||
| 92 | + </el-table-column> | ||
| 93 | + <el-table-column | ||
| 94 | + label="操作" | ||
| 95 | + width="60" | ||
| 96 | + align="center" | ||
| 97 | + class-name="small-padding fixed-width" | ||
| 98 | + > | ||
| 99 | + <template slot-scope="scope"> | ||
| 100 | + <el-button | ||
| 101 | + size="mini" | ||
| 102 | + type="text" | ||
| 103 | + icon="el-icon-delete" | ||
| 104 | + @click="handleClearCacheKey(scope.row)" | ||
| 105 | + ></el-button> | ||
| 106 | + </template> | ||
| 107 | + </el-table-column> | ||
| 108 | + </el-table> | ||
| 109 | + </el-card> | ||
| 110 | + </el-col> | ||
| 111 | + | ||
| 112 | + <el-col :span="8"> | ||
| 113 | + <el-card :bordered="false" style="height: calc(100vh - 125px)"> | ||
| 114 | + <div slot="header"> | ||
| 115 | + <span>缓存内容</span> | ||
| 116 | + <el-button | ||
| 117 | + style="float: right; padding: 3px 0" | ||
| 118 | + type="text" | ||
| 119 | + icon="el-icon-refresh-right" | ||
| 120 | + @click="handleClearCacheAll()" | ||
| 121 | + >清理全部</el-button | ||
| 122 | + > | ||
| 123 | + </div> | ||
| 124 | + <el-form :model="form"> | ||
| 125 | + <el-row :gutter="32"> | ||
| 126 | + <el-col :offset="1" :span="22"> | ||
| 127 | + <el-form-item label="缓存名称:" prop="cacheName"> | ||
| 128 | + <el-input v-model="cacheForm.cacheName" :readOnly="true" /> | ||
| 129 | + </el-form-item> | ||
| 130 | + </el-col> | ||
| 131 | + <el-col :offset="1" :span="22"> | ||
| 132 | + <el-form-item label="缓存键名:" prop="cacheKey"> | ||
| 133 | + <el-input v-model="cacheForm.cacheKey" :readOnly="true" /> | ||
| 134 | + </el-form-item> | ||
| 135 | + </el-col> | ||
| 136 | + <el-col :offset="1" :span="22"> | ||
| 137 | + <el-form-item label="缓存内容:" prop="cacheValue"> | ||
| 138 | + <el-input | ||
| 139 | + v-model="cacheForm.cacheValue" | ||
| 140 | + type="textarea" | ||
| 141 | + :rows="8" | ||
| 142 | + :readOnly="true" | ||
| 143 | + /> | ||
| 144 | + </el-form-item> | ||
| 145 | + </el-col> | ||
| 146 | + </el-row> | ||
| 147 | + </el-form> | ||
| 148 | + </el-card> | ||
| 149 | + </el-col> | ||
| 150 | + </el-row> | ||
| 151 | + </div> | ||
| 152 | +</template> | ||
| 153 | + | ||
| 154 | +<script> | ||
| 155 | +import { listCacheName, listCacheKey, getCacheValue, clearCacheName, clearCacheKey, clearCacheAll } from "@/api/monitor/cache"; | ||
| 156 | + | ||
| 157 | +export default { | ||
| 158 | + name: "CacheList", | ||
| 159 | + data() { | ||
| 160 | + return { | ||
| 161 | + cacheNames: [], | ||
| 162 | + cacheKeys: [], | ||
| 163 | + cacheForm: {}, | ||
| 164 | + loading: true, | ||
| 165 | + subLoading: false, | ||
| 166 | + nowCacheName: "", | ||
| 167 | + tableHeight: window.innerHeight - 200 | ||
| 168 | + }; | ||
| 169 | + }, | ||
| 170 | + created() { | ||
| 171 | + this.getCacheNames(); | ||
| 172 | + }, | ||
| 173 | + methods: { | ||
| 174 | + /** 查询缓存名称列表 */ | ||
| 175 | + getCacheNames() { | ||
| 176 | + this.loading = true; | ||
| 177 | + listCacheName().then(response => { | ||
| 178 | + this.cacheNames = response.data; | ||
| 179 | + this.loading = false; | ||
| 180 | + }); | ||
| 181 | + }, | ||
| 182 | + /** 刷新缓存名称列表 */ | ||
| 183 | + refreshCacheNames() { | ||
| 184 | + this.getCacheNames(); | ||
| 185 | + this.$modal.msgSuccess("刷新缓存列表成功"); | ||
| 186 | + }, | ||
| 187 | + /** 清理指定名称缓存 */ | ||
| 188 | + handleClearCacheName(row) { | ||
| 189 | + clearCacheName(row.cacheName).then(response => { | ||
| 190 | + this.$modal.msgSuccess("清理缓存名称[" + this.nowCacheName + "]成功"); | ||
| 191 | + this.getCacheKeys(); | ||
| 192 | + }); | ||
| 193 | + }, | ||
| 194 | + /** 查询缓存键名列表 */ | ||
| 195 | + getCacheKeys(row) { | ||
| 196 | + const cacheName = row !== undefined ? row.cacheName : this.nowCacheName; | ||
| 197 | + if (cacheName === "") { | ||
| 198 | + return; | ||
| 199 | + } | ||
| 200 | + this.subLoading = true; | ||
| 201 | + listCacheKey(cacheName).then(response => { | ||
| 202 | + this.cacheKeys = response.data; | ||
| 203 | + this.subLoading = false; | ||
| 204 | + this.nowCacheName = cacheName; | ||
| 205 | + }); | ||
| 206 | + }, | ||
| 207 | + /** 刷新缓存键名列表 */ | ||
| 208 | + refreshCacheKeys() { | ||
| 209 | + this.getCacheKeys(); | ||
| 210 | + this.$modal.msgSuccess("刷新键名列表成功"); | ||
| 211 | + }, | ||
| 212 | + /** 清理指定键名缓存 */ | ||
| 213 | + handleClearCacheKey(cacheKey) { | ||
| 214 | + clearCacheKey(cacheKey).then(response => { | ||
| 215 | + this.$modal.msgSuccess("清理缓存键名[" + cacheKey + "]成功"); | ||
| 216 | + this.getCacheKeys(); | ||
| 217 | + }); | ||
| 218 | + }, | ||
| 219 | + /** 列表前缀去除 */ | ||
| 220 | + nameFormatter(row) { | ||
| 221 | + return row.cacheName.replace(":", ""); | ||
| 222 | + }, | ||
| 223 | + /** 键名前缀去除 */ | ||
| 224 | + keyFormatter(cacheKey) { | ||
| 225 | + return cacheKey.replace(this.nowCacheName, ""); | ||
| 226 | + }, | ||
| 227 | + /** 查询缓存内容详细 */ | ||
| 228 | + handleCacheValue(cacheKey) { | ||
| 229 | + getCacheValue(this.nowCacheName, cacheKey).then(response => { | ||
| 230 | + this.cacheForm = response.data; | ||
| 231 | + }); | ||
| 232 | + }, | ||
| 233 | + /** 清理全部缓存 */ | ||
| 234 | + handleClearCacheAll() { | ||
| 235 | + clearCacheAll().then(response => { | ||
| 236 | + this.$modal.msgSuccess("清理全部缓存成功"); | ||
| 237 | + }); | ||
| 238 | + } | ||
| 239 | + }, | ||
| 240 | +}; | ||
| 241 | +</script> |
| @@ -176,9 +176,10 @@ insert into sys_menu values('110', '定时任务', '2', '2', 'job', 'm | @@ -176,9 +176,10 @@ insert into sys_menu values('110', '定时任务', '2', '2', 'job', 'm | ||
| 176 | insert into sys_menu values('111', '数据监控', '2', '3', 'druid', 'monitor/druid/index', '', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', sysdate(), '', null, '数据监控菜单'); | 176 | insert into sys_menu values('111', '数据监控', '2', '3', 'druid', 'monitor/druid/index', '', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', sysdate(), '', null, '数据监控菜单'); |
| 177 | insert into sys_menu values('112', '服务监控', '2', '4', 'server', 'monitor/server/index', '', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', sysdate(), '', null, '服务监控菜单'); | 177 | insert into sys_menu values('112', '服务监控', '2', '4', 'server', 'monitor/server/index', '', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', sysdate(), '', null, '服务监控菜单'); |
| 178 | insert into sys_menu values('113', '缓存监控', '2', '5', 'cache', 'monitor/cache/index', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', sysdate(), '', null, '缓存监控菜单'); | 178 | insert into sys_menu values('113', '缓存监控', '2', '5', 'cache', 'monitor/cache/index', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', sysdate(), '', null, '缓存监控菜单'); |
| 179 | -insert into sys_menu values('114', '表单构建', '3', '1', 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表单构建菜单'); | ||
| 180 | -insert into sys_menu values('115', '代码生成', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代码生成菜单'); | ||
| 181 | -insert into sys_menu values('116', '系统接口', '3', '3', 'swagger', 'tool/swagger/index', '', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, '系统接口菜单'); | 179 | +insert into sys_menu values('114', '缓存列表', '2', '6', 'cacheList', 'monitor/cache/list', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis-list', 'admin', sysdate(), '', null, '缓存列表菜单'); |
| 180 | +insert into sys_menu values('115', '表单构建', '3', '1', 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表单构建菜单'); | ||
| 181 | +insert into sys_menu values('116', '代码生成', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代码生成菜单'); | ||
| 182 | +insert into sys_menu values('117', '系统接口', '3', '3', 'swagger', 'tool/swagger/index', '', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, '系统接口菜单'); | ||
| 182 | -- 三级菜单 | 183 | -- 三级菜单 |
| 183 | insert into sys_menu values('500', '操作日志', '108', '1', 'operlog', 'monitor/operlog/index', '', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', sysdate(), '', null, '操作日志菜单'); | 184 | insert into sys_menu values('500', '操作日志', '108', '1', 'operlog', 'monitor/operlog/index', '', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', sysdate(), '', null, '操作日志菜单'); |
| 184 | insert into sys_menu values('501', '登录日志', '108', '2', 'logininfor', 'monitor/logininfor/index', '', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', sysdate(), '', null, '登录日志菜单'); | 185 | insert into sys_menu values('501', '登录日志', '108', '2', 'logininfor', 'monitor/logininfor/index', '', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', sysdate(), '', null, '登录日志菜单'); |
| @@ -308,6 +309,7 @@ insert into sys_role_menu values ('2', '113'); | @@ -308,6 +309,7 @@ insert into sys_role_menu values ('2', '113'); | ||
| 308 | insert into sys_role_menu values ('2', '114'); | 309 | insert into sys_role_menu values ('2', '114'); |
| 309 | insert into sys_role_menu values ('2', '115'); | 310 | insert into sys_role_menu values ('2', '115'); |
| 310 | insert into sys_role_menu values ('2', '116'); | 311 | insert into sys_role_menu values ('2', '116'); |
| 312 | +insert into sys_role_menu values ('2', '117'); | ||
| 311 | insert into sys_role_menu values ('2', '500'); | 313 | insert into sys_role_menu values ('2', '500'); |
| 312 | insert into sys_role_menu values ('2', '501'); | 314 | insert into sys_role_menu values ('2', '501'); |
| 313 | insert into sys_role_menu values ('2', '1000'); | 315 | insert into sys_role_menu values ('2', '1000'); |
-
请 注册 或 登录 后发表评论