fix: 图片旋转完善
This commit is contained in:
@@ -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 {
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package com.schisandra.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SchisandraCaptchaDTO {
|
||||
private String token;
|
||||
private Double deg;
|
||||
}
|
Reference in New Issue
Block a user