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 8  
9 9 import javax.annotation.Resource;
10 10 import java.util.List;
  11 +import java.util.Optional;
11 12  
12 13 @Repository
13 14 public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
... ... @@ -29,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
29 30  
30 31 @Override
31 32 public byte[] selectContent(Long configId, String path) {
32   - List<FileContentDO> fileContentDOs = fileContentMapper.selectList(
  33 + List<FileContentDO> list = fileContentMapper.selectList(
33 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 40 private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) {
... ...