mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	优化:优化部分常量命名及使用
This commit is contained in:
		| @@ -65,7 +65,7 @@ public class LoginController { | ||||
|     @PostMapping("/login") | ||||
|     public R<LoginVO> login(@Validated @RequestBody LoginRequest loginRequest) { | ||||
|         // 校验验证码 | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_CACHE_KEY, loginRequest.getUuid()); | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, loginRequest.getUuid()); | ||||
|         String captcha = RedisUtils.getCacheObject(captchaKey); | ||||
|         ValidationUtils.throwIfBlank(captcha, "验证码已失效"); | ||||
|         RedisUtils.deleteCacheObject(captchaKey); | ||||
|   | ||||
| @@ -74,7 +74,7 @@ public class CaptchaController { | ||||
|  | ||||
|         // 保存验证码 | ||||
|         String uuid = IdUtil.fastSimpleUUID(); | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_CACHE_KEY, uuid); | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, uuid); | ||||
|         RedisUtils.setCacheObject(captchaKey, captcha.text(), | ||||
|             Duration.ofMinutes(captchaImage.getExpirationInMinutes())); | ||||
|  | ||||
| @@ -88,9 +88,9 @@ public class CaptchaController { | ||||
|     public R getMailCaptcha( | ||||
|         @NotBlank(message = "邮箱不能为空") @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误") String email) | ||||
|         throws MessagingException { | ||||
|         String limitCacheKey = CacheConsts.LIMIT_CACHE_KEY; | ||||
|         String captchaCacheKey = CacheConsts.CAPTCHA_CACHE_KEY; | ||||
|         String limitCaptchaKey = RedisUtils.formatKey(limitCacheKey, captchaCacheKey, email); | ||||
|         String limitKeyPrefix = CacheConsts.LIMIT_KEY_PREFIX; | ||||
|         String captchaKeyPrefix = CacheConsts.CAPTCHA_KEY_PREFIX; | ||||
|         String limitCaptchaKey = RedisUtils.formatKey(limitKeyPrefix, captchaKeyPrefix, email); | ||||
|         long limitTimeInMillisecond = RedisUtils.getTimeToLive(limitCaptchaKey); | ||||
|         CheckUtils.throwIf(limitTimeInMillisecond > 0, "发送邮箱验证码过于频繁,请您 {}s 后再试", limitTimeInMillisecond / 1000); | ||||
|  | ||||
| @@ -105,7 +105,7 @@ public class CaptchaController { | ||||
|         MailUtils.sendHtml(email, String.format("【%s】邮箱验证码", properties.getName()), content); | ||||
|  | ||||
|         // 保存验证码 | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_CACHE_KEY, email); | ||||
|         String captchaKey = RedisUtils.formatKey(captchaKeyPrefix, email); | ||||
|         RedisUtils.setCacheObject(captchaKey, captcha, Duration.ofMinutes(expirationInMinutes)); | ||||
|         RedisUtils.setCacheObject(limitCaptchaKey, captcha, Duration.ofSeconds(captchaMail.getLimitInSeconds())); | ||||
|         return R.ok(String.format("发送成功,验证码有效期 %s 分钟", expirationInMinutes)); | ||||
|   | ||||
| @@ -74,7 +74,7 @@ public class OnlineUserController { | ||||
|  | ||||
|             // 获取 Token Session | ||||
|             SaSession saSession = StpUtil.getTokenSessionByToken(token); | ||||
|             LoginUser loginUser = saSession.get(CacheConsts.LOGIN_USER_CACHE_KEY, new LoginUser()); | ||||
|             LoginUser loginUser = saSession.get(CacheConsts.LOGIN_USER_KEY, new LoginUser()); | ||||
|  | ||||
|             // 检查是否符合查询条件 | ||||
|             if (Boolean.TRUE.equals(checkQuery(query, loginUser))) { | ||||
|   | ||||
| @@ -103,7 +103,7 @@ public class UserCenterController { | ||||
|         ValidationUtils.throwIfBlank(rawCurrentPassword, "当前密码解密失败"); | ||||
|  | ||||
|         // 校验验证码 | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_CACHE_KEY, updateEmailRequest.getNewEmail()); | ||||
|         String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, updateEmailRequest.getNewEmail()); | ||||
|         String captcha = RedisUtils.getCacheObject(captchaKey); | ||||
|         ValidationUtils.throwIfBlank(captcha, "验证码已失效"); | ||||
|         ValidationUtils.throwIfNotEqualIgnoreCase(updateEmailRequest.getCaptcha(), captcha, "验证码错误"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user