From ce291f1a93a550e7447d5f679373e4e95084b227 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Wed, 17 Jan 2024 22:13:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/CacheConstants.java | 2 +- .../system/common/enums/CaptchaTypeEnum.java | 25 +++++++++---------- .../system/service/impl/AuthServiceImpl.java | 16 +++++++----- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/youlai/system/common/constant/CacheConstants.java b/src/main/java/com/youlai/system/common/constant/CacheConstants.java index a702630a..8d5301eb 100644 --- a/src/main/java/com/youlai/system/common/constant/CacheConstants.java +++ b/src/main/java/com/youlai/system/common/constant/CacheConstants.java @@ -21,7 +21,7 @@ public interface CacheConstants { /** * 黑名单Token缓存前缀 */ - String BLACKLIST_TOKEN_PREFIX = "blacklist_token:"; + String BLACKLIST_TOKEN_PREFIX = "token:blacklist:"; } diff --git a/src/main/java/com/youlai/system/common/enums/CaptchaTypeEnum.java b/src/main/java/com/youlai/system/common/enums/CaptchaTypeEnum.java index ba9ecf67..c2896d9e 100644 --- a/src/main/java/com/youlai/system/common/enums/CaptchaTypeEnum.java +++ b/src/main/java/com/youlai/system/common/enums/CaptchaTypeEnum.java @@ -4,25 +4,24 @@ package com.youlai.system.common.enums; * EasyCaptcha 验证码类型枚举 * * @author haoxr - * @since 2023/03/24 + * @since 2.5.1 */ public enum CaptchaTypeEnum { /** - * 算数 + * 圆圈干扰验证码 */ - ARITHMETIC, + CIRCLE, /** - * 中文 - */ - CHINESE, - /** - * 中文闪图 - */ - CHINESE_GIF, - /** - * 闪图 + * GIF验证码 */ GIF, - SPEC + /** + * 干扰线验证码 + */ + LINE, + /** + * 扭曲干扰验证码 + */ + SHEAR } diff --git a/src/main/java/com/youlai/system/service/impl/AuthServiceImpl.java b/src/main/java/com/youlai/system/service/impl/AuthServiceImpl.java index ae00fb76..2c93349f 100644 --- a/src/main/java/com/youlai/system/service/impl/AuthServiceImpl.java +++ b/src/main/java/com/youlai/system/service/impl/AuthServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.captcha.generator.CodeGenerator; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import com.youlai.system.common.constant.CacheConstants; +import com.youlai.system.common.enums.CaptchaTypeEnum; import com.youlai.system.core.security.jwt.JwtTokenProvider; import com.youlai.system.model.dto.CaptchaResult; import com.youlai.system.model.dto.LoginResult; @@ -14,6 +15,7 @@ import com.youlai.system.service.AuthService; import io.jsonwebtoken.Claims; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -35,6 +37,7 @@ import java.util.concurrent.TimeUnit; */ @Service @RequiredArgsConstructor +@Slf4j public class AuthServiceImpl implements AuthService { private final AuthenticationManager authenticationManager; @@ -73,6 +76,7 @@ public class AuthServiceImpl implements AuthService { if (StrUtil.isNotBlank(token)) { Claims claims = jwtTokenProvider.getTokenClaims(token); String jti = claims.get("jti", String.class); + Date expiration = claims.getExpiration(); if (expiration != null) { long ttl = expiration.getTime() - System.currentTimeMillis(); @@ -92,23 +96,23 @@ public class AuthServiceImpl implements AuthService { @Override public CaptchaResult getCaptcha() { - String type = captchaProperties.getType(); + String captchaType = captchaProperties.getType(); int width = captchaProperties.getWidth(); int height = captchaProperties.getHeight(); int interfereCount = captchaProperties.getInterfereCount(); int codeLength = captchaProperties.getCode().getLength(); AbstractCaptcha captcha; - if ("circle".equalsIgnoreCase(type)) { + if (CaptchaTypeEnum.CIRCLE.name().equalsIgnoreCase(captchaType)) { captcha = CaptchaUtil.createCircleCaptcha(width, height, codeLength, interfereCount); - } else if ("gif".equalsIgnoreCase(type)) { + } else if (CaptchaTypeEnum.GIF.name().equalsIgnoreCase(captchaType)) { captcha = CaptchaUtil.createGifCaptcha(width, height, codeLength); - } else if ("line".equalsIgnoreCase(type)) { + } else if (CaptchaTypeEnum.LINE.name().equalsIgnoreCase(captchaType)) { captcha = CaptchaUtil.createLineCaptcha(width, height, codeLength, interfereCount); - } else if ("shear".equalsIgnoreCase(type)) { + } else if (CaptchaTypeEnum.SHEAR.name().equalsIgnoreCase(captchaType)) { captcha = CaptchaUtil.createShearCaptcha(width, height, codeLength, interfereCount); } else { - throw new IllegalArgumentException("Invalid captcha type: " + type); + throw new IllegalArgumentException("Invalid captcha type: " + captchaType); } captcha.setGenerator(codeGenerator); captcha.setTextAlpha(captchaProperties.getTextAlpha()); From f662af4e232ab1804b37fdb599a710b2ce88baf8 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Wed, 17 Jan 2024 22:14:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(pom.xml):=20=E5=8D=87=E7=BA=A7SpringB?= =?UTF-8?q?oot3.2.1=EF=BC=8CMybatis-Plus3.5.5=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- pom.xml | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index db95f5d8..0336ca49 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

有来技术 - 有来技术 + 有来技术 有来技术 diff --git a/pom.xml b/pom.xml index 16869069..8bc61020 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ com.youlai youlai-boot - 2.5.2 + 2.5.3 基于 Java 17 + SpringBoot 3 构建的权限管理系统。 org.springframework.boot spring-boot-starter-parent - 3.2.0 + 3.2.1 @@ -24,7 +24,7 @@ 8.0.28 1.2.16 - 3.5.4.1 + 3.5.5 4.3.0 @@ -121,12 +121,6 @@ com.baomidou mybatis-plus-boot-starter ${mybatis-plus.version} - - - mybatis-spring - org.mybatis - -