Files
ccdi/doc/api-docs/ccdi-file-upload-api.md
2026-03-05 10:47:36 +08:00

228 lines
4.7 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.
# 文件上传 API 文档
## 1. 批量上传文件
### 接口地址
POST /ccdi/file-upload/batch
### 请求参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| projectId | Long | 是 | 项目ID |
| files | File[] | 是 | 文件数组最多100个单个最大50MB |
### 请求示例
```bash
curl -X POST "http://localhost:8080/ccdi/file-upload/batch" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "projectId=1" \
-F "files=@/path/to/file1.xlsx" \
-F "files=@/path/to/file2.xlsx"
```
### 返回示例
```json
{
"code": 200,
"msg": "上传任务已提交",
"data": "a1b2c3d4e5f6g7h8"
}
```
### 返回字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| code | Integer | 状态码200表示成功 |
| msg | String | 提示信息 |
| data | String | 批次ID用于追踪上传任务 |
### 错误码说明
| code | msg | 说明 |
|------|-----|------|
| 500 | 项目ID不能为空 | 缺少必填参数 |
| 500 | 请选择要上传的文件 | 文件数组为空 |
| 500 | 单次最多上传100个文件 | 文件数量超限 |
| 500 | 文件 xxx 超过50MB限制 | 文件大小超限 |
| 500 | 文件 xxx 格式不支持仅支持Excel文件 | 文件格式错误 |
| 500 | 系统繁忙,请稍后再试 | 线程池已满 |
---
## 2. 查询上传记录列表
### 接口地址
GET /ccdi/file-upload/list
### 请求参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| projectId | Long | 否 | 项目ID |
| fileStatus | String | 否 | 文件状态uploading/parsing/parsed_success/parsed_failed |
| fileName | String | 否 | 文件名称(模糊查询) |
| uploadUser | String | 否 | 上传人 |
| pageNum | Integer | 否 | 页码默认1 |
| pageSize | Integer | 否 | 每页数量默认10 |
### 请求示例
```bash
curl -X GET "http://localhost:8080/ccdi/file-upload/list?projectId=1&fileStatus=parsed_success&pageNum=1&pageSize=10" \
-H "Authorization: Bearer YOUR_TOKEN"
```
### 返回示例
```json
{
"code": 200,
"msg": "查询成功",
"rows": [
{
"id": 1,
"projectId": 1,
"lsfxProjectId": 100,
"logId": 123456,
"fileName": "流水1.xlsx",
"fileSize": 2621440,
"fileStatus": "parsed_success",
"enterpriseNames": "张三,李四",
"accountNos": "622xxx,623xxx",
"uploadTime": "2026-03-05 10:30:00",
"uploadUser": "admin"
}
],
"total": 100
}
```
### 返回字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| rows | Array | 记录列表 |
| total | Long | 总记录数 |
---
## 3. 查询上传统计
### 接口地址
GET /ccdi/file-upload/statistics/{projectId}
### 路径参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| projectId | Long | 是 | 项目ID |
### 请求示例
```bash
curl -X GET "http://localhost:8080/ccdi/file-upload/statistics/1" \
-H "Authorization: Bearer YOUR_TOKEN"
```
### 返回示例
```json
{
"code": 200,
"msg": "查询成功",
"data": {
"uploading": 2,
"parsing": 3,
"parsedSuccess": 15,
"parsedFailed": 1,
"total": 21
}
}
```
### 返回字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| uploading | Long | 上传中数量 |
| parsing | Long | 解析中数量 |
| parsedSuccess | Long | 解析成功数量 |
| parsedFailed | Long | 解析失败数量 |
| total | Long | 总数量 |
---
## 4. 查询记录详情
### 接口地址
GET /ccdi/file-upload/detail/{id}
### 路径参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | Long | 是 | 记录ID |
### 请求示例
```bash
curl -X GET "http://localhost:8080/ccdi/file-upload/detail/1" \
-H "Authorization: Bearer YOUR_TOKEN"
```
### 返回示例
```json
{
"code": 200,
"msg": "查询成功",
"data": {
"id": 1,
"projectId": 1,
"lsfxProjectId": 100,
"logId": 123456,
"fileName": "流水1.xlsx",
"fileSize": 2621440,
"fileStatus": "parsed_success",
"enterpriseNames": "张三,李四",
"accountNos": "622xxx,623xxx",
"errorMessage": null,
"uploadTime": "2026-03-05 10:30:00",
"uploadUser": "admin"
}
}
```
---
## 5. 文件状态说明
| 状态 | 说明 |
|------|------|
| uploading | 文件上传中 |
| parsing | 文件解析中 |
| parsed_success | 文件解析成功 |
| parsed_failed | 文件解析失败 |
---
## 6. 通用说明
### 认证方式
所有接口需要在请求头中携带 Token
```
Authorization: Bearer YOUR_TOKEN
```
### 获取 Token
```bash
POST /login/test?username=admin&password=admin123
```
### 响应格式
所有接口统一返回格式:
```json
{
"code": 200,
"msg": "操作成功",
"data": {}
}
```
### 错误处理
当发生错误时,返回格式:
```json
{
"code": 500,
"msg": "错误信息"
}
```