| | |
| | | package com.ruoyi.basic.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.StorageAttachmentDTO; |
| | | import com.ruoyi.basic.dto.StorageAttachmentVO; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过记录类型获取文件信息 attachment(分页) |
| | | * |
| | | * @param page 分页参数 |
| | | * @param storageAttachmentDTO 关联记录信息 |
| | | */ |
| | | public IPage<StorageAttachmentVO> getStorageAttachmentVosPageListByApplicationAndRecordTypeAndRecordId(Page page, StorageAttachmentDTO storageAttachmentDTO) { |
| | | // 分页查询符合条件的 StorageAttachment 记录 |
| | | LambdaQueryWrapper<StorageAttachment> queryWrapper = new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordType, storageAttachmentDTO.getRecordType()) |
| | | .eq(StorageAttachment::getRecordId, storageAttachmentDTO.getRecordId()); |
| | | if (storageAttachmentDTO.getApplication() != null) { |
| | | queryWrapper.eq(StorageAttachment::getApplication, storageAttachmentDTO.getApplication()); |
| | | } |
| | | IPage<StorageAttachmentVO> storageAttachmentIPage = storageAttachmentMapper.selectPage(page, queryWrapper); |
| | | |
| | | // 转换为 StorageAttachmentVO 并获取对应的 StorageBlobVO |
| | | List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(storageAttachmentIPage.getRecords())) { |
| | | for (StorageAttachment storageAttachment : storageAttachmentIPage.getRecords()) { |
| | | StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO(); |
| | | BeanUtils.copyProperties(storageAttachment, storageAttachmentVO); |
| | | List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId())); |
| | | if (CollectionUtils.isEmpty(storageBlobVOS)) { |
| | | storageAttachmentVO.setStorageBlobVOS(new ArrayList<>()); |
| | | } else { |
| | | storageAttachmentVO.setStorageBlobVOS(storageBlobVOS); |
| | | } |
| | | storageAttachmentVOS.add(storageAttachmentVO); |
| | | } |
| | | } |
| | | |
| | | // 构建分页结果 |
| | | IPage<StorageAttachmentVO> resultPage = new Page<>(); |
| | | BeanUtils.copyProperties(storageAttachmentIPage, resultPage); |
| | | resultPage.setRecords(storageAttachmentVOS); |
| | | |
| | | return resultPage; |
| | | } |
| | | |
| | | /** |
| | | * 通过文件用途、关联记录类型、关联记录id获取文件关联信息 attachment |
| | | * |
| | | * @param application 文件用途 |