2021与蓝度共同重构项目,服务端
liuhaonan
2022-04-11 e861c8ea2fd047f31d5b4827fb2a598af60e9378
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeFileService.java
@@ -53,15 +53,42 @@
    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 {
@@ -74,7 +101,7 @@
     * 文件上传
     *
     * @param file
     * @param userId
     * @param
     * @return
     */
    public FileUploadDto upload(MultipartFile file) {