|
|
|
@ -7,13 +7,16 @@ import com.supervision.model.FileResource;
|
|
|
|
|
import com.supervision.service.FileResourceService;
|
|
|
|
|
import com.supervision.util.MinioUtil;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class FileManageServiceImpl implements FileManageService {
|
|
|
|
@ -56,4 +59,20 @@ public class FileManageServiceImpl implements FileManageService {
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean deleteFile(String fileId) throws Exception {
|
|
|
|
|
Assert.notEmpty(fileId, "文件id不能为空");
|
|
|
|
|
|
|
|
|
|
FileResource fileResource = fileResourceService.getById(fileId);
|
|
|
|
|
if (Objects.isNull(fileResource)){
|
|
|
|
|
log.info("deleteFile: fileId:{} 未找到数据",fileId);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotEmpty(fileResource.getMinioId())){
|
|
|
|
|
log.info("deleteFile:删除minio中的数据.minioId:{}",fileResource.getMinioId());
|
|
|
|
|
MinioUtil.deleteObject(fileResource.getMinioId());
|
|
|
|
|
}
|
|
|
|
|
return fileResourceService.removeById(fileId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|