Commit 427d031ba5c2aa3aeb629ec8d7c0e9fd83b76e6e
Committed by
Gitee
!346 file路径Bug
Merge pull request !346 from 与或非/issues/I5KG6T
Showing
1 changed file
with
8 additions
and
3 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.dal.mysql.file; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.file.core.client.db.DBFileContentFrameworkDAO; |
| 4 | 5 | import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; |
| 5 | 6 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 6 | 7 | import org.springframework.stereotype.Repository; |
| 7 | 8 | |
| 8 | 9 | import javax.annotation.Resource; |
| 10 | +import java.util.List; | |
| 11 | +import java.util.Optional; | |
| 9 | 12 | |
| 10 | 13 | @Repository |
| 11 | 14 | public class FileContentDAOImpl implements DBFileContentFrameworkDAO { |
| ... | ... | @@ -27,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { |
| 27 | 30 | |
| 28 | 31 | @Override |
| 29 | 32 | public byte[] selectContent(Long configId, String path) { |
| 30 | - FileContentDO fileContentDO = fileContentMapper.selectOne( | |
| 31 | - buildQuery(configId, path).select(FileContentDO::getContent)); | |
| 32 | - return fileContentDO != null ? fileContentDO.getContent() : null; | |
| 33 | + List<FileContentDO> list = fileContentMapper.selectList( | |
| 34 | + buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId)); | |
| 35 | + return Optional.ofNullable(CollUtil.getFirst(list)) | |
| 36 | + .map(FileContentDO::getContent) | |
| 37 | + .orElse(null); | |
| 33 | 38 | } |
| 34 | 39 | |
| 35 | 40 | private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) { | ... | ... |