| | |
| | | |
| | | public boolean deleteFile(Long fileId) { |
| | | IpVolumeFile byId = getById(fileId); |
| | | String bucketName; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | bucketName = MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName(); |
| | | } else { |
| | | bucketName = MinIoConstant.BROADCAST_FILE.getBucketName() + SecurityUtils.getUserId(); |
| | | } |
| | | if (byId == null) { |
| | | throw new BusinessException("找不到对应文件"); |
| | | } |
| | | boolean b = minIoUtil.deleteFile(bucketName, byId.getFileName()); |
| | | // if (!b) { |
| | | // throw new BusinessException("服务器删除失败"); |
| | | // } |
| | | |
| | | |
| | | return removeById(fileId); |
| | | } |
| | | |
| | | public LambdaQueryWrapper<IpVolumeFile> listFile(BaseConditionVO baseConditionVO, String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<IpVolumeFile> wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getClientId, clientService.getClientId()); |
| | | LambdaQueryWrapper<IpVolumeFile> wrapper; |
| | | |
| | | if (SecurityUtils.getClientId() == null) { |
| | | wrapper = Wrappers.lambdaQuery(IpVolumeFile.class); |
| | | } else { |
| | | if (clientService.findClientId()) { |
| | | wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getUserId, SecurityUtils.getUserId()); |
| | | } else { |
| | | wrapper = Wrappers.lambdaQuery(IpVolumeFile.class).eq(IpVolumeFile::getClientId, clientService.getClientId()) |
| | | .or(file -> { |
| | | file.eq(IpVolumeFile::getClientId, SecurityUtils.getUserId()); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (keyword.isEmpty()) { |
| | | return wrapper; |
| | | } else { |
| | |
| | | * 文件上传 |
| | | * |
| | | * @param file |
| | | * @param userId |
| | | * @param |
| | | * @return |
| | | */ |
| | | public FileUploadDto upload(MultipartFile file) { |