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()); wrapper.eq(SysEmail::getEnabled, ENABLED.getValue());
List<SysEmail> emails = this.list(wrapper); List<SysEmail> emails = this.list(wrapper);
Optional<SysEmail> first = emails.stream().findFirst(); Optional<SysEmail> first = emails.stream().findFirst();
if(!first.isPresent()) return null; if(first.isPresent()) {
SysEmail sender = first.get(); SysEmail sender = first.get();
redisUtil.set(RedisConstant.EMAIL_SENDER, sender); redisUtil.set(RedisConstant.EMAIL_SENDER, sender);
log.info("缓存了可用的发件邮箱到Redis: {}", sender.getUsername()); return sender;
return sender; }
// 删除缓存中旧的发件邮箱信息
if (redisUtil.hasKey(RedisConstant.EMAIL_SENDER))
redisUtil.del(RedisConstant.EMAIL_SENDER);
return null;
} }
/* /*