@RestController
@RequestMapping("/p4")
public class p4 {
@Autowired
SmsVerificationCodeService smsVerificationCodeService;
@GetMapping("/send")
public boolean send( String mobile) {
return smsVerificationCodeService.sendVerificationCode(mobile);
}
@GetMapping("/verify")
public boolean verify(String mobile, String verificationCode) {
return smsVerificationCodeService.verifyVerificationCode(mobile, verificationCode);
}
}
package com.tan.springboot2.p4;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SmsVerificationCodeService {
@Autowired
private RedisTemplate&