fix: 图片旋转完善
This commit is contained in:
@@ -2,6 +2,7 @@ package com.schisandra.auth.application.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
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.CaptchaResult;
|
||||||
import com.schisandra.auth.common.entity.Result;
|
import com.schisandra.auth.common.entity.Result;
|
||||||
import com.schisandra.auth.common.redis.RedisUtil;
|
import com.schisandra.auth.common.redis.RedisUtil;
|
||||||
@@ -11,10 +12,7 @@ import com.schisandra.auth.common.utils.SmsCodeUtils;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -79,14 +77,15 @@ public class ReactRotateCaptchaController {
|
|||||||
* @date: 2024/5/10 17:25
|
* @date: 2024/5/10 17:25
|
||||||
*/
|
*/
|
||||||
@PostMapping("verfiy")
|
@PostMapping("verfiy")
|
||||||
public CaptchaResult verfiy(String token, Double num) {
|
public CaptchaResult verfiy(@RequestBody SchisandraCaptchaDTO schisandraCaptchaDTO) {
|
||||||
if (num == null && token == null) {
|
|
||||||
|
if (schisandraCaptchaDTO.getDeg() == null && schisandraCaptchaDTO.getToken() == null) {
|
||||||
return CaptchaResult.fail();
|
return CaptchaResult.fail();
|
||||||
}
|
}
|
||||||
String prefix = redisUtil.buildKey(authRotateCaptchaPrefix, token);
|
String prefix = redisUtil.buildKey(authRotateCaptchaPrefix, schisandraCaptchaDTO.getToken());
|
||||||
if (redisUtil.exist(prefix)) {
|
if (redisUtil.exist(prefix)) {
|
||||||
double realNum = Double.parseDouble(redisUtil.get(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);
|
redisUtil.del(prefix);
|
||||||
return CaptchaResult.ok();
|
return CaptchaResult.ok();
|
||||||
} else {
|
} 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