fix: 微信小程序接口对接修改,联调测试问题修复。
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intc.common.sms.config.properties.SmsProperties;
|
||||
import com.intc.common.web.config.properties.CaptchaProperties;
|
||||
import com.intc.common.web.enums.CaptchaType;
|
||||
import com.intc.web.domain.vo.CaptchaVo;
|
||||
import com.intc.fishery.domain.bo.ReqVerifySmsCode;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,6 +33,8 @@ import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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 java.time.Duration;
|
||||
@@ -105,6 +108,31 @@ public class CaptchaController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证短信验证码
|
||||
*
|
||||
* @param request 手机号和验证码数据
|
||||
* @return 验证结果
|
||||
*/
|
||||
@PostMapping("/resource/sms/verify")
|
||||
public R<Void> verifySmsCode(@Validated @RequestBody ReqVerifySmsCode request) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + request.getMobilePhone();
|
||||
String cachedCode = RedisUtils.getCacheObject(key);
|
||||
|
||||
if (StringUtils.isBlank(cachedCode)) {
|
||||
return R.fail("短信验证码已过期");
|
||||
}
|
||||
|
||||
if (!cachedCode.equals(request.getSmsCode())) {
|
||||
return R.fail("短信验证码错误");
|
||||
}
|
||||
|
||||
// 验证成功后删除验证码(根据 C# 代码中的 true 参数)
|
||||
RedisUtils.deleteObject(key);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱验证码
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user