【System模块】短信验证码前置补零对其endCode长度

Signed-off-by: aqiangaqiang <11317238+aqiangaqiang@user.noreply.gitee.com>
This commit is contained in:
aqiangaqiang 2024-05-10 00:59:31 +00:00 committed by Gitee
parent 4ca583cbe8
commit b4151b62eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -67,7 +67,8 @@ public class SmsCodeServiceImpl implements SmsCodeService {
} }
// 创建验证码记录 // 创建验证码记录
String code = String.valueOf(randomInt(smsCodeProperties.getBeginCode(), smsCodeProperties.getEndCode() + 1)); String code = String.format("%0" + smsCodeProperties.getEndCode().toString().length() + "d",
randomInt(smsCodeProperties.getBeginCode(), smsCodeProperties.getEndCode() + 1));
SmsCodeDO newSmsCode = SmsCodeDO.builder().mobile(mobile).code(code).scene(scene) SmsCodeDO newSmsCode = SmsCodeDO.builder().mobile(mobile).code(code).scene(scene)
.todayIndex(lastSmsCode != null && isToday(lastSmsCode.getCreateTime()) ? lastSmsCode.getTodayIndex() + 1 : 1) .todayIndex(lastSmsCode != null && isToday(lastSmsCode.getCreateTime()) ? lastSmsCode.getTodayIndex() + 1 : 1)
.createIp(ip).used(false).build(); .createIp(ip).used(false).build();