From 5761ba4271200a3baf2333d265175586d87c554d Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期二, 13 九月 2022 11:02:44 +0800 Subject: [PATCH] update druid 1.2.11 => 1.2.12 update hutool 5.8.5 => 5.8.6 update dynamic-ds 3.5.1 => 3.5.2 update aws-java-sdk-s3 1.12.264 => 1.12.300 update aliyun-sms 2.0.16 => 2.0.18 update tencent-sms 3.1.555 => 3.1.591 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java | 19 ++++++++----------- 1 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java index 03a6cfc..514e68e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java @@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.constant.CacheNames; import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.redis.RedisUtils; -import com.ruoyi.oss.constant.OssConstant; import com.ruoyi.oss.core.OssClient; import com.ruoyi.oss.entity.UploadResult; import com.ruoyi.oss.factory.OssFactory; @@ -19,11 +18,11 @@ import com.ruoyi.system.mapper.SysOssMapper; import com.ruoyi.system.service.ISysOssService; import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -51,13 +50,10 @@ public List<SysOssVo> listByIds(Collection<Long> ossIds) { List<SysOssVo> list = new ArrayList<>(); for (Long id : ossIds) { - String key = OssConstant.SYS_OSS_KEY + id; - SysOssVo vo = RedisUtils.getCacheObject(key); - if (ObjectUtil.isNull(vo)) { - vo = baseMapper.selectVoById(id); - RedisUtils.setCacheObject(key, vo, Duration.ofDays(30)); + SysOssVo vo = getById(id); + if (ObjectUtil.isNotNull(vo)) { + list.add(vo); } - list.add(vo); } return list; } @@ -76,9 +72,10 @@ return lqw; } + @Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId") @Override - public SysOss getById(Long ossId) { - return baseMapper.selectById(ossId); + public SysOssVo getById(Long ossId) { + return baseMapper.selectVoById(ossId); } @Override -- Gitblit v1.9.3