fix: 验证码不刷新问题修复,项目包结构调整
This commit is contained in:
@@ -5,6 +5,7 @@ import cn.hutool.captcha.CircleCaptcha;
|
||||
import cn.hutool.captcha.generator.CodeGenerator;
|
||||
import cn.hutool.captcha.generator.MathGenerator;
|
||||
import cn.hutool.captcha.generator.RandomGenerator;
|
||||
import com.youlai.system.model.dto.CaptchaResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -16,7 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @since 2023/11/24
|
||||
*/
|
||||
@Configuration
|
||||
public class CaptchaConfig {
|
||||
public class CaptchaGenerator {
|
||||
|
||||
@Autowired
|
||||
private CaptchaProperties captchaProperties;
|
||||
@@ -27,7 +28,7 @@ public class CaptchaConfig {
|
||||
* @return CodeGenerator
|
||||
*/
|
||||
@Bean
|
||||
public CodeGenerator captchaGenerator() {
|
||||
public CodeGenerator codeGenerator() {
|
||||
String codeType = captchaProperties.getCode().getType();
|
||||
int codeLength = captchaProperties.getCode().getLength();
|
||||
if ("math".equalsIgnoreCase(codeType)) {
|
||||
@@ -39,13 +40,24 @@ public class CaptchaConfig {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
*
|
||||
* @return CaptchaModel 验证码
|
||||
*/
|
||||
public CaptchaModel generate() {
|
||||
AbstractCaptcha captcha = getCaptcha();
|
||||
captcha.createCode();
|
||||
return new CaptchaModel(captcha.getCode(), captcha.getImageBase64Data());
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码类
|
||||
*
|
||||
* @return AbstractCaptcha
|
||||
*/
|
||||
@Bean
|
||||
public AbstractCaptcha abstractCaptcha() {
|
||||
public AbstractCaptcha getCaptcha() {
|
||||
AbstractCaptcha captcha = null;
|
||||
|
||||
String type = captchaProperties.getType();
|
||||
@@ -67,7 +79,7 @@ public class CaptchaConfig {
|
||||
throw new IllegalArgumentException("Invalid captcha type: " + type);
|
||||
}
|
||||
|
||||
captcha.setGenerator(captchaGenerator());
|
||||
captcha.setGenerator(codeGenerator());
|
||||
return captcha;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.youlai.system.plugin.captcha;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 验证码对象
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CaptchaModel {
|
||||
/**
|
||||
* 验证码编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 验证码图片Base64
|
||||
*/
|
||||
private String base64;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.youlai.system.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
|
||||
import com.youlai.system.common.result.ResultCode;
|
||||
import com.youlai.system.common.exception.BusinessException;
|
||||
import com.youlai.system.core.security.jwt.JwtTokenProvider;
|
||||
import com.youlai.system.base.security.jwt.JwtTokenProvider;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.youlai.system.plugin.websocket;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @since 2023/11/7
|
||||
*/
|
||||
public class StompPrincipal {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.youlai.system.plugin.websocket;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.youlai.system.core.security.jwt.JwtTokenProvider;
|
||||
import com.youlai.system.base.security.jwt.JwtTokenProvider;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
Reference in New Issue
Block a user