datai/docs/archive/api-docs/file/SysFileInfoController/0002-export.md

107 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 导出文件列表
## 接口信息
- **接口名称**: 导出文件列表
- **接口路径**: /file/info/export
- **请求方法**: POST
- **模块归属**: file
- **版本号**: v1.0.0
- **创建日期**: 2026-01-18
- **最后更新**: 2026-01-18
## 功能描述
导出文件列表到 Excel 文件,支持条件过滤。可以根据文件名、文件路径、存储类型、文件类型等条件进行筛选,然后导出符合条件的文件列表。
## 请求参数
### 请求体 (JSON)
```json
{
"fileName": "test",
"filePath": "/upload/",
"storageType": "minio",
"fileType": "jpg"
}
```
| 参数名 | 类型 | 必填 | 描述 | 示例 |
|--------|------|------|------|------|
| fileName | String | 否 | 文件名(模糊查询) | test.jpg |
| filePath | String | 否 | 文件路径(模糊查询) | /upload/ |
| storageType | String | 否 | 存储类型 | minio, local, oss |
| fileType | String | 否 | 文件类型 | jpg, png, pdf |
## 响应数据
### 成功响应
**HTTP 状态码**: 200 OK
**Content-Type**: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
**Content-Disposition**: attachment; filename="文件数据.xlsx"
直接返回 Excel 文件流,浏览器会自动触发下载。
### 失败响应
**HTTP 状态码**: 401 Unauthorized
```json
{
"code": 401,
"msg": "没有权限访问",
"data": null
}
```
## 接口示例
### 请求示例
```bash
curl -X POST "http://localhost:8080/file/info/export" \
-H "Authorization: Bearer [token]" \
-H "Content-Type: application/json" \
-d '{
"fileName": "test",
"storageType": "minio"
}' \
-o file_list.xlsx
```
### 响应示例
**成功**: 返回 Excel 文件流,浏览器自动下载文件
**失败**: 返回错误信息
## 错误处理
- 没有权限访问时返回 401 错误
- 参数错误时返回 400 错误
## 注意事项
- 需要权限system:file:export
- 导出文件名为:文件数据.xlsx
- 使用 `@Log` 注解记录操作日志
- 只导出删除标志为 0 的文件(未删除的文件)
- 使用 `ExcelUtil` 工具类生成 Excel 文件
## 相关接口
- [查询文件列表](./0001-list.md) - 查询文件列表
- [获取文件详细信息](./0003-get-info.md) - 获取单个文件的详细信息
## 实现细节
- 使用 `ISysFileInfoService.selectSysFileInfoList()` 查询文件列表
- 使用 `ExcelUtil` 工具类生成 Excel 文件
- 使用 `@Log` 注解记录操作日志,业务类型为 EXPORT
- 使用 `@PreAuthorize` 注解进行权限控制
- 继承 `BaseController` 获取基础功能