From 9a468600867a1e28847313c7509c395a7a7cd2f9 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Fri, 30 Dec 2022 15:04:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E9=87=8D=E5=A4=8D=20file=20?= =?UTF-8?q?=E8=B7=AF=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 | 6 ++++-- 1 file changed, 4 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 c4dcfe8a0..e38acf2cf 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 @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.infra.dal.mysql.file; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.file.core.client.db.DBFileContentFrameworkDAO; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.stereotype.Repository; import javax.annotation.Resource; +import java.util.List; @Repository public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @@ -27,9 +29,9 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @Override public byte[] selectContent(Long configId, String path) { - FileContentDO fileContentDO = fileContentMapper.selectOne( + List fileContentDOs = fileContentMapper.selectList( buildQuery(configId, path).select(FileContentDO::getContent)); - return fileContentDO != null ? fileContentDO.getContent() : null; + return CollUtil.isNotEmpty(fileContentDOs) ? CollUtil.getFirst(fileContentDOs).getContent() : null; } private LambdaQueryWrapper buildQuery(Long configId, String path) { From 639c7820f92e0368e94f63a762f9ef5fc96e44ec Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Fri, 30 Dec 2022 16:07:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E9=87=8D=E5=A4=8D=20file=20?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=20Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e38acf2cf..5213edc7a 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 @@ -30,7 +30,7 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @Override public byte[] selectContent(Long configId, String path) { List fileContentDOs = fileContentMapper.selectList( - buildQuery(configId, path).select(FileContentDO::getContent)); + buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId)); return CollUtil.isNotEmpty(fileContentDOs) ? CollUtil.getFirst(fileContentDOs).getContent() : null; } 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 3/3] =?UTF-8?q?fix:=20=E9=87=8D=E5=A4=8D=20file=20?= =?UTF-8?q?=E8=B7=AF=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) {