update 优化api,gateway,auth代码结构

This commit is contained in:
AprilWind
2024-01-19 16:57:17 +08:00
parent bf95012138
commit ef83f06f2b
35 changed files with 320 additions and 29 deletions

View File

@@ -59,11 +59,13 @@ public class CaptchaController {
// 生成验证码
CaptchaType captchaType = captchaProperties.getType();
boolean isMath = CaptchaType.MATH == captchaType;
//如果是则拿取数字验证码位数,如果不是则拿取字符验证码长度
Integer length = isMath ? captchaProperties.getNumberLength() : captchaProperties.getCharLength();
CodeGenerator codeGenerator = ReflectUtils.newInstance(captchaType.getClazz(), length);
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
captcha.setGenerator(codeGenerator);
captcha.createCode();
// 如果是数学验证码使用SpEL表达式处理验证码结果
String code = captcha.getCode();
if (isMath) {
ExpressionParser parser = new SpelExpressionParser();