已修改11个文件
已重命名1个文件
已添加2个文件
ÎļþÃû´Ó sql/ry_20220613.sql ÐÞ¸Ä |
| | |
| | | insert into sys_menu values('111', 'æ°æ®çæ§', '2', '3', 'druid', 'monitor/druid/index', '', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', sysdate(), '', null, 'æ°æ®çæ§èå');
|
| | | insert into sys_menu values('112', 'æå¡çæ§', '2', '4', 'server', 'monitor/server/index', '', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', sysdate(), '', null, 'æå¡çæ§èå');
|
| | | insert into sys_menu values('113', 'ç¼åçæ§', '2', '5', 'cache', 'monitor/cache/index', '', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', sysdate(), '', null, 'ç¼åçæ§èå');
|
| | | insert into sys_menu values('114', '表åæå»º', '3', '1', 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表åæå»ºèå');
|
| | | insert into sys_menu values('115', '代ç çæ', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代ç çæèå');
|
| | | insert into sys_menu values('116', 'ç³»ç»æ¥å£', '3', '3', 'swagger', 'tool/swagger/index', '', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, 'ç³»ç»æ¥å£èå');
|
| | | 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, 'ç¼åå表èå');
|
| | | insert into sys_menu values('115', '表åæå»º', '3', '1', 'build', 'tool/build/index', '', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表åæå»ºèå');
|
| | | insert into sys_menu values('116', '代ç çæ', '3', '2', 'gen', 'tool/gen/index', '', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代ç çæèå');
|
| | | insert into sys_menu values('117', 'ç³»ç»æ¥å£', '3', '3', 'swagger', 'tool/swagger/index', '', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, 'ç³»ç»æ¥å£èå');
|
| | | -- ä¸çº§èå
|
| | | insert into sys_menu values('500', 'æä½æ¥å¿', '108', '1', 'operlog', 'monitor/operlog/index', '', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', sysdate(), '', null, 'æä½æ¥å¿èå');
|
| | | insert into sys_menu values('501', 'ç»å½æ¥å¿', '108', '2', 'logininfor', 'monitor/logininfor/index', '', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', sysdate(), '', null, 'ç»å½æ¥å¿èå');
|
| | |
| | | insert into sys_role_menu values ('2', '114');
|
| | | insert into sys_role_menu values ('2', '115');
|
| | | insert into sys_role_menu values ('2', '116');
|
| | | insert into sys_role_menu values ('2', '117');
|
| | | insert into sys_role_menu values ('2', '500');
|
| | | insert into sys_role_menu values ('2', '501');
|
| | | insert into sys_role_menu values ('2', '1000');
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.constant;
|
| | |
|
| | | /**
|
| | | * ç¼åçkey 常é
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class CacheConstants
|
| | | {
|
| | | /**
|
| | | * ç»å½ç¨æ· redis key
|
| | | */
|
| | | public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
| | |
|
| | | /**
|
| | | * éªè¯ç redis key
|
| | | */
|
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
| | |
|
| | | /**
|
| | | * åæ°ç®¡ç cache key
|
| | | */
|
| | | public static final String SYS_CONFIG_KEY = "sys_config:";
|
| | |
|
| | | /**
|
| | | * åå
¸ç®¡ç cache key
|
| | | */
|
| | | public static final String SYS_DICT_KEY = "sys_dict:";
|
| | |
|
| | | /**
|
| | | * é²éæäº¤ redis key
|
| | | */
|
| | | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
| | |
|
| | | /**
|
| | | * éæµ redis key
|
| | | */
|
| | | public static final String RATE_LIMIT_KEY = "rate_limit:";
|
| | | }
|
| | |
| | | * ç»å½å¤±è´¥
|
| | | */
|
| | | public static final String LOGIN_FAIL = "Error";
|
| | |
|
| | | /**
|
| | | * éªè¯ç redis key
|
| | | */
|
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
| | |
|
| | | /**
|
| | | * ç»å½ç¨æ· redis key
|
| | | */
|
| | | public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
| | |
|
| | | /**
|
| | | * é²éæäº¤ redis key
|
| | | */
|
| | | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
| | |
|
| | | /**
|
| | | * éæµ redis key
|
| | | */
|
| | | public static final String RATE_LIMIT_KEY = "rate_limit:";
|
| | |
|
| | | |
| | | /**
|
| | | * éªè¯ç æææï¼åéï¼
|
| | | */
|
| | |
| | | * ç¨æ·æé
|
| | | */
|
| | | public static final String JWT_AUTHORITIES = "authorities";
|
| | |
|
| | | /**
|
| | | * åæ°ç®¡ç cache key
|
| | | */
|
| | | public static final String SYS_CONFIG_KEY = "sys_config:";
|
| | |
|
| | | /**
|
| | | * åå
¸ç®¡ç cache key
|
| | | */
|
| | | public static final String SYS_DICT_KEY = "sys_dict:";
|
| | |
|
| | | /**
|
| | | * èµæºæ å°è·¯å¾ åç¼
|
| | |
| | | import java.util.Collection;
|
| | | import java.util.List;
|
| | | import com.alibaba.fastjson2.JSONArray;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.project.system.domain.SysDictData;
|
| | |
| | | */
|
| | | public static void clearDictCache()
|
| | | {
|
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
|
| | | Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*");
|
| | | SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | public static String getCacheKey(String configKey)
|
| | | {
|
| | | return Constants.SYS_DICT_KEY + configKey;
|
| | | return CacheConstants.SYS_DICT_KEY + configKey;
|
| | | }
|
| | | }
|
| | |
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.LimitType;
|
| | |
|
| | | /**
|
| | |
| | | /**
|
| | | * éæµkey
|
| | | */
|
| | | public String key() default Constants.RATE_LIMIT_KEY;
|
| | | public String key() default CacheConstants.RATE_LIMIT_KEY;
|
| | |
|
| | | /**
|
| | | * éæµæ¶é´,åä½ç§
|
| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.alibaba.fastjson2.JSON;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.http.HttpHelper;
|
| | |
| | | String submitKey = StringUtils.trimToEmpty(request.getHeader(header));
|
| | |
|
| | | // å¯ä¸æ è¯ï¼æå®key + url + æ¶æ¯å¤´ï¼
|
| | | String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
|
| | | String cacheRepeatKey = CacheConstants.REPEAT_SUBMIT_KEY + url + submitKey;
|
| | |
|
| | | Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
|
| | | if (sessionObj != null)
|
| | |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
| | | import org.springframework.security.core.Authentication;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | | import com.ruoyi.common.exception.user.CaptchaException;
|
| | |
| | | */
|
| | | public void validateCaptcha(String username, String code, String uuid)
|
| | | {
|
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
| | | String captcha = redisCache.getCacheObject(verifyKey);
|
| | | redisCache.deleteObject(verifyKey);
|
| | | if (captcha == null)
|
| | |
| | |
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.exception.user.CaptchaException;
|
| | |
| | | */
|
| | | public void validateCaptcha(String username, String code, String uuid)
|
| | | {
|
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
| | | String captcha = redisCache.getCacheObject(verifyKey);
|
| | | redisCache.deleteObject(verifyKey);
|
| | | if (captcha == null)
|
| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.ServletUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | |
| | |
|
| | | private String getTokenKey(String uuid)
|
| | | {
|
| | | return Constants.LOGIN_TOKEN_KEY + uuid;
|
| | | return CacheConstants.LOGIN_TOKEN_KEY + uuid;
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.google.code.kaptcha.Producer;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.sign.Base64;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | |
| | |
|
| | | // ä¿åéªè¯ç ä¿¡æ¯
|
| | | String uuid = IdUtils.simpleUUID();
|
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
| | |
|
| | | String capStr = null, code = null;
|
| | | BufferedImage image = null;
|
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collection;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Properties;
|
| | | import java.util.Set;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.data.redis.core.RedisCallback;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.monitor.domain.SysCache;
|
| | |
|
| | | /**
|
| | | * ç¼åçæ§
|
| | |
| | | {
|
| | | @Autowired
|
| | | private RedisTemplate<String, String> redisTemplate;
|
| | |
|
| | | private final static List<SysCache> caches = new ArrayList<SysCache>();
|
| | | {
|
| | | caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "ç¨æ·ä¿¡æ¯"));
|
| | | caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "é
置信æ¯"));
|
| | | caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "æ°æ®åå
¸"));
|
| | | caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "éªè¯ç "));
|
| | | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "é²éæäº¤"));
|
| | | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "éæµå¤ç"));
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping()
|
| | |
| | | result.put("commandStats", pieList);
|
| | | return AjaxResult.success(result);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getNames")
|
| | | public AjaxResult cache()
|
| | | {
|
| | | return AjaxResult.success(caches);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getKeys/{cacheName}")
|
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName)
|
| | | {
|
| | | Set<String> cacheKyes = redisTemplate.keys(cacheName + "*");
|
| | | return AjaxResult.success(cacheKyes);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}")
|
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
|
| | | {
|
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
| | | return AjaxResult.success(sysCache);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheName/{cacheName}")
|
| | | public AjaxResult clearCacheName(@PathVariable String cacheName)
|
| | | {
|
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
| | | redisTemplate.delete(cacheKeys);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheKey/{cacheKey}")
|
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey)
|
| | | {
|
| | | redisTemplate.delete(cacheKey);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheAll")
|
| | | public AjaxResult clearCacheAll()
|
| | | {
|
| | | Collection<String> cacheKeys = redisTemplate.keys("*");
|
| | | redisTemplate.delete(cacheKeys);
|
| | | return AjaxResult.success();
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | |
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(String ipaddr, String userName)
|
| | | {
|
| | | Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
| | | Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
| | | List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
| | | for (String key : keys)
|
| | | {
|
| | |
| | | @DeleteMapping("/{tokenId}")
|
| | | public AjaxResult forceLogout(@PathVariable String tokenId)
|
| | | {
|
| | | redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
| | | redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
| | | return AjaxResult.success();
|
| | | }
|
| | | }
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.project.monitor.domain;
|
| | |
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | |
|
| | | /**
|
| | | * ç¼åä¿¡æ¯
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class SysCache
|
| | | {
|
| | | /** ç¼ååç§° */
|
| | | private String cacheName = "";
|
| | |
|
| | | /** ç¼åé®å */
|
| | | private String cacheKey = "";
|
| | |
|
| | | /** ç¼åå
容 */
|
| | | private String cacheValue = "";
|
| | |
|
| | | /** 夿³¨ */
|
| | | private String remark = "";
|
| | |
|
| | | public SysCache()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | public SysCache(String cacheName, String remark)
|
| | | {
|
| | | this.cacheName = cacheName;
|
| | | this.remark = remark;
|
| | | }
|
| | |
|
| | | public SysCache(String cacheName, String cacheKey, String cacheValue)
|
| | | {
|
| | | this.cacheName = StringUtils.replace(cacheName, ":", "");
|
| | | this.cacheKey = StringUtils.replace(cacheKey, cacheName, "");
|
| | | this.cacheValue = cacheValue;
|
| | | }
|
| | |
|
| | | public String getCacheName()
|
| | | {
|
| | | return cacheName;
|
| | | }
|
| | |
|
| | | public void setCacheName(String cacheName)
|
| | | {
|
| | | this.cacheName = cacheName;
|
| | | }
|
| | |
|
| | | public String getCacheKey()
|
| | | {
|
| | | return cacheKey;
|
| | | }
|
| | |
|
| | | public void setCacheKey(String cacheKey)
|
| | | {
|
| | | this.cacheKey = cacheKey;
|
| | | }
|
| | |
|
| | | public String getCacheValue()
|
| | | {
|
| | | return cacheValue;
|
| | | }
|
| | |
|
| | | public void setCacheValue(String cacheValue)
|
| | | {
|
| | | this.cacheValue = cacheValue;
|
| | | }
|
| | |
|
| | | public String getRemark()
|
| | | {
|
| | | return remark;
|
| | | }
|
| | |
|
| | | public void setRemark(String remark)
|
| | | {
|
| | | this.remark = remark;
|
| | | }
|
| | | }
|
| | |
| | | import javax.annotation.PostConstruct;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.core.text.Convert;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | |
| | | @Override
|
| | | public void clearConfigCache()
|
| | | {
|
| | | Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
| | | Collection<String> keys = redisCache.keys(CacheConstants.SYS_CONFIG_KEY + "*");
|
| | | redisCache.deleteObject(keys);
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | private String getCacheKey(String configKey)
|
| | | {
|
| | | return Constants.SYS_CONFIG_KEY + configKey;
|
| | | return CacheConstants.SYS_CONFIG_KEY + configKey;
|
| | | }
|
| | | }
|