2
0

feat: add register

This commit is contained in:
caiyuchao
2024-11-27 18:36:18 +08:00
parent dd62a85f51
commit f13548d937
18 changed files with 212 additions and 36 deletions

View File

@@ -1,9 +1,10 @@
package org.wfc.gateway.service;
import java.io.IOException;
import org.wfc.common.core.exception.CaptchaException;
import org.wfc.common.core.web.domain.AjaxResult;
import java.io.IOException;
/**
* 验证码处理
*
@@ -19,5 +20,5 @@ public interface ValidateCodeService
/**
* 校验验证码
*/
public void checkCaptcha(String key, String value) throws CaptchaException;
public void checkCaptcha(String key, String value, boolean isPic) throws CaptchaException;
}

View File

@@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.FastByteArrayOutputStream;
import org.wfc.common.core.constant.CacheConstants;
import org.wfc.common.core.constant.Constants;
import org.wfc.common.core.constant.GlobalConstants;
import org.wfc.common.core.exception.CaptchaException;
import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.core.utils.sign.Base64;
@@ -63,7 +63,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
@@ -109,19 +109,21 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
* 校验验证码
*/
@Override
public void checkCaptcha(String code, String uuid) throws CaptchaException
public void checkCaptcha(String code, String uuid, boolean isPic) throws CaptchaException
{
if (StringUtils.isEmpty(code))
{
throw new CaptchaException("user.jcaptcha.not.blank");
}
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisService.getCacheObject(verifyKey);
if (captcha == null)
{
throw new CaptchaException();
}
redisService.deleteObject(verifyKey);
if (isPic) {
redisService.deleteObject(verifyKey);
}
if (!code.equalsIgnoreCase(captcha))
{
throw new CaptchaException();