| | |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.business.dto.ArchiveDto; |
| | | import com.ruoyi.business.entity.Archive; |
| | | import com.ruoyi.business.entity.Tree; |
| | | import com.ruoyi.business.mapper.ArchiveMapper; |
| | | import com.ruoyi.business.mapper.TreeMapper; |
| | | import com.ruoyi.business.service.ArchiveService; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.file.MinioUtils; |
| | |
| | | |
| | | private final ArchiveMapper archiveMapper; |
| | | |
| | | private final TreeMapper treeMapper; |
| | | |
| | | private final StorageAttachmentService storageAttachmentService; |
| | | |
| | | private final StorageBlobMapper storageBlobMapper; |
| | | |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | |
| | | private final MinioUtils minioUtils; |
| | | |
| | | |
| | | @Override |
| | | public IPage<ArchiveDto> selectArchiveList(Page page, ArchiveDto archiveDto) { |
| | | public IPage<ArchiveDto> selectArchiveList(Page<Archive> page, ArchiveDto archiveDto) { |
| | | // 1. 分页查询主数据 |
| | | LambdaQueryWrapper<Archive> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(Archive::getCreateTime); |
| | | if (archiveDto.getTreeId() != null) { |
| | | Long treeId = archiveDto.getTreeId(); |
| | | // 判断是否为主ID |
| | | Tree tree = treeMapper.selectById(archiveDto.getTreeId()); |
| | | boolean isMainId = tree != null && tree.getParentId() == null; |
| | | |
| | | if (isMainId) { |
| | | // 获取主ID的所有递归子节点ID |
| | | List<Long> recursiveSubIds = treeMapper.listRecursiveSubNodeIds(treeId); |
| | | |
| | | // 将主ID本身和所有子节点ID加入查询条件 |
| | | recursiveSubIds.add(treeId); |
| | | queryWrapper.in(Archive::getTreeId, recursiveSubIds); |
| | | } else { |
| | | // 非主ID,直接按原条件查询 |
| | | queryWrapper.eq(Archive::getTreeId, treeId); |
| | | } |
| | | } |
| | | if (archiveDto.getSearchAll() != null) { |
| | | queryWrapper.like(Archive::getName, archiveDto.getSearchAll()); |
| | | } |
| | | IPage<Archive> archivePage = archiveMapper.selectPage(page, queryWrapper); |
| | | |
| | | // 2. 无数据提前返回 |
| | |
| | | .map(blob -> { |
| | | StorageBlobDTO blobDTO = new StorageBlobDTO(); |
| | | BeanUtils.copyProperties(blob, blobDTO); |
| | | |
| | | |
| | | // 动态生成预览地址和下载地址 |
| | | // 设置预览URL |
| | | blobDTO.setUrl(minioUtils.getPreviewUrls( |
| | |
| | | |
| | | // 7. 构建返回分页对象 |
| | | IPage<ArchiveDto> resultPage = new Page<>(); |
| | | BeanUtils.copyProperties(archivePage, resultPage); |
| | | resultPage.setRecords(dtoList); |
| | | return resultPage; |
| | | } |