File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
src/main/java/com/achobeta/domain/email/service/impl Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 22
22
@ RequiredArgsConstructor
23
23
public class EmailServiceImpl implements EmailService {
24
24
25
+ // todo: 将配置写于配置文件
25
26
private static final int IDENTIFYING_CODE_MINUTES = 5 ;//过期分钟数
26
27
27
28
private static final long IDENTIFYING_CODE_INTERVAL_Limit = 1 * 60 * 1000 ; // 两次发送验证码的最短时间间隔
@@ -70,13 +71,13 @@ public void sendIdentifyingCode(String email, String code) {
70
71
@ Override
71
72
public void checkIdentifyingCode (String email , String code ) {
72
73
String redisKey = IdentifyingCodeValidator .REDIS_EMAIL_IDENTIFYING_CODE + email ;
73
- Object data = null ;
74
- data = emailRepository .getIdentifyingCode (redisKey ).orElseThrow (() -> {
75
- String message = String .format ("Redis 中不存在邮箱[%s]的相关记录" , email );
76
- return new GlobalServiceException (message , GlobalServiceStatusCode .EMAIL_NOT_EXIST_RECORD );
77
- });
74
+ Map <String , Object > map = emailRepository .getIdentifyingCode (redisKey )
75
+ .map (value -> (Map <String , Object >)value )
76
+ .orElseThrow (() -> {
77
+ String message = String .format ("Redis 中不存在邮箱[%s]的相关记录" , email );
78
+ return new GlobalServiceException (message , GlobalServiceStatusCode .EMAIL_NOT_EXIST_RECORD );
79
+ });
78
80
// 取出验证码和过期时间点
79
- Map <String , Object > map = (Map <String , Object >) data ;
80
81
String codeValue = (String ) map .get (IdentifyingCodeValidator .IDENTIFYING_CODE );
81
82
int opportunities = (int ) map .get (IdentifyingCodeValidator .IDENTIFYING_OPPORTUNITIES );
82
83
// 还有没有验证机会
You can’t perform that action at this time.
0 commit comments