Commit 906a3a2c50fd5daa01a5e57893b09d06a7c10135

Authored by gaibu
1 parent 639c7820

fix: 重复 file 路径 Bug

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; @@ -8,6 +8,7 @@ import org.springframework.stereotype.Repository;
8 8
9 import javax.annotation.Resource; 9 import javax.annotation.Resource;
10 import java.util.List; 10 import java.util.List;
  11 +import java.util.Optional;
11 12
12 @Repository 13 @Repository
13 public class FileContentDAOImpl implements DBFileContentFrameworkDAO { 14 public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
@@ -29,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { @@ -29,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
29 30
30 @Override 31 @Override
31 public byte[] selectContent(Long configId, String path) { 32 public byte[] selectContent(Long configId, String path) {
32 - List<FileContentDO> fileContentDOs = fileContentMapper.selectList( 33 + List<FileContentDO> list = fileContentMapper.selectList(
33 buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId)); 34 buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId));
34 - return CollUtil.isNotEmpty(fileContentDOs) ? CollUtil.getFirst(fileContentDOs).getContent() : null; 35 + return Optional.ofNullable(CollUtil.getFirst(list))
  36 + .map(FileContentDO::getContent)
  37 + .orElse(null);
35 } 38 }
36 39
37 private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) { 40 private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) {