fix:删除缓存中的发件邮箱信息

This commit is contained in:
nieziyan 2024-02-27 15:47:24 +08:00
parent cf81fab98a
commit 6666e74a98

View File

@ -270,11 +270,15 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
wrapper.eq(SysEmail::getEnabled, ENABLED.getValue());
List<SysEmail> emails = this.list(wrapper);
Optional<SysEmail> first = emails.stream().findFirst();
if(!first.isPresent()) return null;
SysEmail sender = first.get();
redisUtil.set(RedisConstant.EMAIL_SENDER, sender);
log.info("缓存了可用的发件邮箱到Redis: {}", sender.getUsername());
return sender;
if(first.isPresent()) {
SysEmail sender = first.get();
redisUtil.set(RedisConstant.EMAIL_SENDER, sender);
return sender;
}
// 删除缓存中旧的发件邮箱信息
if (redisUtil.hasKey(RedisConstant.EMAIL_SENDER))
redisUtil.del(RedisConstant.EMAIL_SENDER);
return null;
}
/*