2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-04-20 c00a73b74e67dbeb508865c3da4ed8d57c8631db
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeFileService.java
@@ -53,20 +53,40 @@
    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());
        if (keyword.isEmpty()) {
            return wrapper;
        } else {
            return wrapper.like(IpVolumeFile::getFileName, keyword);
        LambdaQueryWrapper<IpVolumeFile> wrapper = Wrappers.lambdaQuery(IpVolumeFile.class);
        //不是超管
        if (SecurityUtils.getClientId() != null) {
            wrapper = wrapper.eq(IpVolumeFile::getClientId, SecurityUtils.getUserId())
                    .or(file -> {
                        file.eq(IpVolumeFile::getUserId, SecurityUtils.getUserId());
                    });
        }
        if (keyword != null && !keyword.isEmpty()) {
            wrapper.like(IpVolumeFile::getFileName, keyword);
        }
        return wrapper;
    }
@@ -74,7 +94,7 @@
     * 文件上传
     *
     * @param file
     * @param userId
     * @param
     * @return
     */
    public FileUploadDto upload(MultipartFile file) {