|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
package cn.iocoder.yudao.module.system.service.fileInfo; |
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
|
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi; |
|
|
|
|
import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -12,7 +14,6 @@ import java.util.stream.Collectors;
|
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.fileInfo.vo.*; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; |
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; |
|
|
|
@ -80,9 +81,9 @@ public class FileInfoServiceImpl implements FileInfoService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, String>> getFileList(String dictType, String dictData, String unitId) { |
|
|
|
|
public List<InfraFileInfoDTO> getFileList(Long dictType, Long dictData, String unitId) { |
|
|
|
|
|
|
|
|
|
List<Map<String, String>> mapList = new ArrayList<>(); |
|
|
|
|
List<InfraFileInfoDTO> mapList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<FileInfoDO> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(FileInfoDO::getDictType, dictType); |
|
|
|
@ -91,13 +92,50 @@ public class FileInfoServiceImpl implements FileInfoService {
|
|
|
|
|
final List<Long> collect = fileInfoMapper.selectList(wrapper).stream().map(res -> res.getInfraFileId()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (!collect.isEmpty()) { |
|
|
|
|
final List<Map<String,String>> list = fileApi.listFile(collect); |
|
|
|
|
final List<InfraFileInfoDTO> list = fileApi.listFile(collect); |
|
|
|
|
mapList.addAll(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return mapList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String,List<InfraFileInfoDTO>> getFileListMap(Long dictType, Long dictData, Collection<String> unitId) { |
|
|
|
|
|
|
|
|
|
Map<String,List<InfraFileInfoDTO>> result =new HashMap<>(); |
|
|
|
|
LambdaQueryWrapperX<FileInfoDO> wrapper = new LambdaQueryWrapperX<FileInfoDO>(); |
|
|
|
|
wrapper.eqIfPresent(FileInfoDO::getDictType, dictType); |
|
|
|
|
wrapper.eqIfPresent(FileInfoDO::getDictData, dictData); |
|
|
|
|
wrapper.inIfPresent(FileInfoDO::getUnitId, unitId); |
|
|
|
|
List<FileInfoDO> fileInfoDOS = fileInfoMapper.selectList(wrapper); |
|
|
|
|
if(fileInfoDOS.isEmpty()){ |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
Map<String, List<Long>> stringListMap = CollectionUtils.convertMultiMap(fileInfoDOS, FileInfoDO::getUnitId,FileInfoDO::getInfraFileId); |
|
|
|
|
List<Long> longs = CollectionUtils.convertList(fileInfoDOS, FileInfoDO::getInfraFileId); |
|
|
|
|
|
|
|
|
|
if (!longs.isEmpty()) { |
|
|
|
|
List<InfraFileInfoDTO> infraFileInfoDTOS = fileApi.listFile(longs); |
|
|
|
|
|
|
|
|
|
Map<Long, InfraFileInfoDTO> longInfraFileInfoDTOMap = CollectionUtils.convertMap(infraFileInfoDTOS, InfraFileInfoDTO::getId); |
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<Long>> entry : stringListMap.entrySet()) { |
|
|
|
|
List<InfraFileInfoDTO> list = new ArrayList<>(); |
|
|
|
|
for (Long aLong : entry.getValue()) { |
|
|
|
|
InfraFileInfoDTO infraFileInfoDTO = longInfraFileInfoDTOMap.get(aLong); |
|
|
|
|
if (infraFileInfoDTO != null) { |
|
|
|
|
list.add(infraFileInfoDTO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
result.put(entry.getKey(),list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据字典类型和字典数据保存附件信息 |
|
|
|
|
* |
|
|
|
@ -109,8 +147,8 @@ public class FileInfoServiceImpl implements FileInfoService {
|
|
|
|
|
* @Date 2025-02-16 上午9:34 |
|
|
|
|
**/ |
|
|
|
|
@Override |
|
|
|
|
public void saveFilesByDictData(Long[] fileIds, Long dictType, Long dictData, String unitId) { |
|
|
|
|
if (fileIds != null && fileIds.length > 0) { |
|
|
|
|
public void saveFilesByDictData(Collection<Long> fileIds, Long dictType, Long dictData, String unitId) { |
|
|
|
|
if (!CollectionUtils.isAnyEmpty(fileIds)) { |
|
|
|
|
List<FileInfoDO> list = new ArrayList<>(); |
|
|
|
|
for (Long fileId : fileIds) { |
|
|
|
|
FileInfoDO fileInfoDO = new FileInfoDO(); |
|
|
|
@ -124,4 +162,13 @@ public class FileInfoServiceImpl implements FileInfoService {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void deleteFilesByDictData(Long dictType, Long dictData, String unitId) { |
|
|
|
|
LambdaQueryWrapperX<FileInfoDO> list=new LambdaQueryWrapperX<FileInfoDO>(); |
|
|
|
|
list.eq(FileInfoDO::getDictType,dictType); |
|
|
|
|
list.eq(FileInfoDO::getDictData,dictData); |
|
|
|
|
list.eq(FileInfoDO::getUnitId,unitId); |
|
|
|
|
fileInfoMapper.delete(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|