|
@@ -6,9 +6,14 @@ import java.util.concurrent.TimeUnit;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.system.domain.dto.CaptchaEntity;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.FastByteArrayOutputStream;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.google.code.kaptcha.Producer;
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
@@ -91,4 +96,16 @@ public class CaptchaController
|
|
|
ajax.put("img", Base64.encode(os.toByteArray()));
|
|
|
return ajax;
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/captchaCheck")
|
|
|
+ public AjaxResult validateCaptcha(@RequestBody CaptchaEntity captchaEntity) {
|
|
|
+ String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(captchaEntity.getUuid(), "");
|
|
|
+ String captcha = redisCache.getCacheObject(verifyKey);
|
|
|
+ redisCache.deleteObject(verifyKey);
|
|
|
+ if (captcha.equals(captchaEntity.getCode())){
|
|
|
+ return AjaxResult.success("success");
|
|
|
+ }else {
|
|
|
+ return AjaxResult.error("验证码校验错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|