diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/ReactRotateCaptchaController.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/ReactRotateCaptchaController.java index e3262bb..34f5461 100644 --- a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/ReactRotateCaptchaController.java +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/controller/ReactRotateCaptchaController.java @@ -2,6 +2,7 @@ package com.schisandra.auth.application.controller; import cn.hutool.core.lang.Assert; +import com.schisandra.auth.application.dto.SchisandraCaptchaDTO; import com.schisandra.auth.common.entity.CaptchaResult; import com.schisandra.auth.common.entity.Result; import com.schisandra.auth.common.redis.RedisUtil; @@ -11,10 +12,7 @@ import com.schisandra.auth.common.utils.SmsCodeUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -79,14 +77,15 @@ public class ReactRotateCaptchaController { * @date: 2024/5/10 17:25 */ @PostMapping("verfiy") - public CaptchaResult verfiy(String token, Double num) { - if (num == null && token == null) { + public CaptchaResult verfiy(@RequestBody SchisandraCaptchaDTO schisandraCaptchaDTO) { + + if (schisandraCaptchaDTO.getDeg() == null && schisandraCaptchaDTO.getToken() == null) { return CaptchaResult.fail(); } - String prefix = redisUtil.buildKey(authRotateCaptchaPrefix, token); + String prefix = redisUtil.buildKey(authRotateCaptchaPrefix, schisandraCaptchaDTO.getToken()); if (redisUtil.exist(prefix)) { double realNum = Double.parseDouble(redisUtil.get(prefix)); - if (Math.abs(realNum - num) / realNum < 0.05) { + if (Math.abs(realNum - schisandraCaptchaDTO.getDeg()) / realNum < 0.05) { redisUtil.del(prefix); return CaptchaResult.ok(); } else { diff --git a/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/dto/SchisandraCaptchaDTO.java b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/dto/SchisandraCaptchaDTO.java new file mode 100644 index 0000000..d79bba3 --- /dev/null +++ b/schisandra-cloud-storage-auth/schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller/src/main/java/com/schisandra/auth/application/dto/SchisandraCaptchaDTO.java @@ -0,0 +1,9 @@ +package com.schisandra.auth.application.dto; + +import lombok.Data; + +@Data +public class SchisandraCaptchaDTO { + private String token; + private Double deg; +}