CaptchaUtils.java 693 B

12345678910111213141516171819202122
  1. package com.ruoyi.system.utils;
  2. import com.ruoyi.common.constant.CacheConstants;
  3. import com.ruoyi.common.core.redis.RedisCache;
  4. import com.ruoyi.common.utils.StringUtils;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. public class CaptchaUtils {
  7. @Autowired
  8. private RedisCache redisCache;
  9. public Boolean validateCaptcha(String code, String uuid) {
  10. String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
  11. String captcha = redisCache.getCacheObject(verifyKey);
  12. redisCache.deleteObject(verifyKey);
  13. if (captcha.equals(code)){
  14. return true;
  15. }else {
  16. return false;
  17. }
  18. }
  19. }