datai/docs/archive/api-docs/integration/DataiIntegrationBatchController/0007-retry-failed-batch.md

118 lines
2.6 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.

# 接口文档:重试失败的批次
## 接口信息
- **接口名称**: 重试失败的批次
- **接口路径**: /integration/batch/{id}/retry
- **请求方法**: POST
- **模块归属**: 数据批次管理
- **版本号**: v1.0
- **创建日期**: 2026-01-09
- **最后更新**: 2026-01-09
## 功能描述
重试失败的批次同步操作,用于重新执行失败的批次数据同步。
## 请求参数
### 路径参数
| 参数名 | 类型 | 必填 | 描述 | 示例 |
|--------|------|------|------|------|
| id | Integer | 是 | 批次ID | 1 |
## 响应数据
### 成功响应
**HTTP 状态码**: 200 OK
```json
{
"code": 200,
"message": "操作成功",
"data": 1
}
```
### 失败响应
**HTTP 状态码**: 400/401/404/500
```json
{
"code": 404,
"message": "批次不存在",
"data": 0
}
```
## 接口示例
### 请求示例
```bash
curl -X POST "http://localhost:8080/integration/batch/1/retry" \
-H "Authorization: Bearer [token]"
```
### 响应示例
**成功**:
```json
{
"code": 200,
"message": "操作成功",
"data": 1
}
```
**失败**:
```json
{
"code": 404,
"message": "批次不存在",
"data": 0
}
```
## 错误处理
- **401 未授权**: 用户没有访问权限
- **404 未找到**: 批次不存在
- **500 服务器错误**: 服务器内部错误,可能是数据库连接失败或同步操作失败等
## 注意事项
- 接口需要 `integration:batch:retry` 权限
- 批次ID必须为整数类型
- 对于没有失败记录的批次,会返回成功但不执行任何操作
## 相关接口
- [获取批次同步统计信息](http://localhost:8080/integration/batch/{id}/statistics) - 获取批次同步统计信息
- [同步批次数据](http://localhost:8080/integration/batch/{id}/sync) - 同步批次数据
## 实现细节
- 接口通过调用 `dataiIntegrationBatchService.retryFailed()` 方法重试失败的批次
- 会查询批次的失败历史记录并重新执行同步操作
- 支持重试单个批次的所有失败记录
## 测试信息
### 测试环境
- **环境**: 开发环境
- **版本**: v1.0
### 测试用例
| 测试场景 | 输入参数 | 预期结果 | 实际结果 | 状态 |
|----------|----------|----------|----------|------|
| 重试存在的失败批次 | id=1存在且有失败记录 | 操作成功返回1 | 操作成功返回1 | 通过 |
| 重试不存在的批次 | id=999不存在 | 操作失败返回0 | 操作失败返回0 | 通过 |
| 重试没有失败记录的批次 | id=2存在但无失败记录 | 操作成功返回1 | 操作成功返回1 | 通过 |