From 906a3a2c50fd5daa01a5e57893b09d06a7c10135 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Mon, 2 Jan 2023 12:27:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E5=A4=8D=20file=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=20Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/infra/dal/mysql/file/FileContentDAOImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java index 5213edc7a..2492c803d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Repository; import javax.annotation.Resource; import java.util.List; +import java.util.Optional; @Repository public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @@ -29,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @Override public byte[] selectContent(Long configId, String path) { - List fileContentDOs = fileContentMapper.selectList( + List list = fileContentMapper.selectList( buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId)); - return CollUtil.isNotEmpty(fileContentDOs) ? CollUtil.getFirst(fileContentDOs).getContent() : null; + return Optional.ofNullable(CollUtil.getFirst(list)) + .map(FileContentDO::getContent) + .orElse(null); } private LambdaQueryWrapper buildQuery(Long configId, String path) {