提交 90c727ee authored 作者: YunaiV's avatar YunaiV

346 file路径Bug

上级 76bed802
package cn.iocoder.yudao.module.infra.dal.mysql.file; 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.framework.file.core.client.db.DBFileContentFrameworkDAO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
@Repository @Repository
public class FileContentDAOImpl implements DBFileContentFrameworkDAO { public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
...@@ -27,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO { ...@@ -27,9 +30,11 @@ public class FileContentDAOImpl implements DBFileContentFrameworkDAO {
@Override @Override
public byte[] selectContent(Long configId, String path) { public byte[] selectContent(Long configId, String path) {
FileContentDO fileContentDO = fileContentMapper.selectOne( List<FileContentDO> list = fileContentMapper.selectList(
buildQuery(configId, path).select(FileContentDO::getContent)); buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId));
return fileContentDO != null ? fileContentDO.getContent() : null; return Optional.ofNullable(CollUtil.getFirst(list))
.map(FileContentDO::getContent)
.orElse(null);
} }
private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) { private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论