datai/datai-scenes/datai-scene-salesforce/docs/api-docs/2026-02-05-002-05-api.md

425 lines
12 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 文档Flow 覆盖率功能
## 元数据
- 需求编号002-05
- 需求名称Flow 覆盖率
- 创建时间2026-02-05
- 创建人AI Assistant
- 版本号v1.0.0
## API 概述
Flow 覆盖率 API 提供 Salesforce Apex Flow 覆盖率数据的查询、管理和统计功能。支持 Flow 覆盖率记录的分页查询、详情查询、导出,以及 Flow 覆盖率警告的查询和管理。
### 功能特性
- **Flow 覆盖率查询**:支持分页查询 Flow 覆盖率记录,可按多种条件筛选
- **Flow 覆盖率详情**:查询单个 Flow 覆盖率记录的详细信息
- **Flow 覆盖率导出**:支持将 Flow 覆盖率数据导出为 Excel
- **Flow 覆盖率警告**:查询 Flow 覆盖率相关的警告信息
- **CRUD 操作**:支持 Flow 覆盖率记录的增删改查
### 权限控制
所有接口都需要相应的权限才能访问:
- `apex:apexflowcoverage:list` - 查询 Flow 覆盖率列表
- `apex:apexflowcoverage:query` - 查询 Flow 覆盖率详情
- `apex:apexflowcoverage:add` - 新增 Flow 覆盖率
- `apex:apexflowcoverage:edit` - 修改 Flow 覆盖率
- `apex:apexflowcoverage:remove` - 删除 Flow 覆盖率
- `apex:apexflowcoverage:export` - 导出 Flow 覆盖率
- `apex:apexflowwarning:list` - 查询 Flow 覆盖率警告列表
- `apex:apexflowwarning:query` - 查询 Flow 覆盖率警告详情
## 接口列表
### 1. 查询 Flow 覆盖率列表
- **功能描述**:分页查询 Flow 覆盖率记录列表,支持多种筛选条件
- **请求方式**GET
- **请求路径**`/apex/apexflowcoverage/list`
- **权限要求**`apex:apexflowcoverage:list`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| pageNum | Integer | 否 | 当前页码,默认 1 |
| pageSize | Integer | 否 | 每页记录数,默认 10 |
| testResultId | Long | 否 | 测试结果 ID |
| flowName | String | 否 | Flow 名称,支持模糊查询 |
| flowId | String | 否 | Flow ID |
| type | String | 否 | Flow 类型 |
| namespace | String | 否 | 命名空间 |
| minCoverage | Double | 否 | 最小覆盖率(百分比) |
| maxCoverage | Double | 否 | 最大覆盖率(百分比) |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
| rows | Array | Flow 覆盖率记录列表 |
| total | Long | 总记录数 |
#### 响应数据项
| 参数名 | 类型 | 说明 |
|--------|------|------|
| id | Long | 记录 ID |
| testResultId | Long | 测试结果 ID |
| flowName | String | Flow 名称 |
| flowId | String | Flow ID |
| type | String | Flow 类型 |
| namespace | String | 命名空间 |
| coveragePercent | Double | 覆盖率百分比 |
| numElements | Integer | 总元素数 |
| coveredElements | Integer | 已覆盖元素数 |
| numElementsNotCovered | Integer | 未覆盖元素数 |
| createTime | String | 创建时间 |
| updateTime | String | 更新时间 |
#### 成功示例
```json
{
"code": 200,
"msg": "查询成功",
"rows": [
{
"id": 1,
"testResultId": 100,
"flowName": "Account_Automation",
"flowId": "301xx000000abcd",
"type": "AutoLaunchedFlow",
"namespace": "",
"coveragePercent": 85.5,
"numElements": 20,
"coveredElements": 17,
"numElementsNotCovered": 3,
"createTime": "2026-02-05 10:30:00",
"updateTime": "2026-02-05 10:30:00"
}
],
"total": 1
}
```
### 2. 查询 Flow 覆盖率详情
- **功能描述**:根据 ID 查询单个 Flow 覆盖率记录的详细信息
- **请求方式**GET
- **请求路径**`/apex/apexflowcoverage/{id}`
- **权限要求**`apex:apexflowcoverage:query`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| id | Long | 是 | Flow 覆盖率记录 ID路径参数 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
| data | Object | Flow 覆盖率详细信息 |
#### 响应数据项
| 参数名 | 类型 | 说明 |
|--------|------|------|
| id | Long | 记录 ID |
| testResultId | Long | 测试结果 ID |
| flowName | String | Flow 名称 |
| flowId | String | Flow ID |
| type | String | Flow 类型 |
| namespace | String | 命名空间 |
| coveragePercent | Double | 覆盖率百分比 |
| numElements | Integer | 总元素数 |
| coveredElements | Integer | 已覆盖元素数 |
| numElementsNotCovered | Integer | 未覆盖元素数 |
| createTime | String | 创建时间 |
| updateTime | String | 更新时间 |
#### 成功示例
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"testResultId": 100,
"flowName": "Account_Automation",
"flowId": "301xx000000abcd",
"type": "AutoLaunchedFlow",
"namespace": "",
"coveragePercent": 85.5,
"numElements": 20,
"coveredElements": 17,
"numElementsNotCovered": 3,
"createTime": "2026-02-05 10:30:00",
"updateTime": "2026-02-05 10:30:00"
}
}
```
### 3. 新增 Flow 覆盖率
- **功能描述**:新增一条 Flow 覆盖率记录
- **请求方式**POST
- **请求路径**`/apex/apexflowcoverage`
- **权限要求**`apex:apexflowcoverage:add`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| testResultId | Long | 是 | 测试结果 ID |
| flowName | String | 是 | Flow 名称 |
| flowId | String | 是 | Flow ID |
| type | String | 否 | Flow 类型 |
| namespace | String | 否 | 命名空间 |
| coveragePercent | Double | 否 | 覆盖率百分比 |
| numElements | Integer | 否 | 总元素数 |
| coveredElements | Integer | 否 | 已覆盖元素数 |
| numElementsNotCovered | Integer | 否 | 未覆盖元素数 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
#### 成功示例
```json
{
"code": 200,
"msg": "操作成功"
}
```
### 4. 修改 Flow 覆盖率
- **功能描述**:修改指定的 Flow 覆盖率记录
- **请求方式**PUT
- **请求路径**`/apex/apexflowcoverage`
- **权限要求**`apex:apexflowcoverage:edit`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| id | Long | 是 | 记录 ID |
| testResultId | Long | 否 | 测试结果 ID |
| flowName | String | 否 | Flow 名称 |
| flowId | String | 否 | Flow ID |
| type | String | 否 | Flow 类型 |
| namespace | String | 否 | 命名空间 |
| coveragePercent | Double | 否 | 覆盖率百分比 |
| numElements | Integer | 否 | 总元素数 |
| coveredElements | Integer | 否 | 已覆盖元素数 |
| numElementsNotCovered | Integer | 否 | 未覆盖元素数 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
#### 成功示例
```json
{
"code": 200,
"msg": "操作成功"
}
```
### 5. 删除 Flow 覆盖率
- **功能描述**:删除指定的 Flow 覆盖率记录(支持批量删除)
- **请求方式**DELETE
- **请求路径**`/apex/apexflowcoverage/{ids}`
- **权限要求**`apex:apexflowcoverage:remove`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| ids | String | 是 | 记录 ID 列表,多个 ID 用逗号分隔,路径参数 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
#### 成功示例
```json
{
"code": 200,
"msg": "操作成功"
}
```
### 6. 导出 Flow 覆盖率
- **功能描述**:将 Flow 覆盖率数据导出为 Excel 文件
- **请求方式**POST
- **请求路径**`/apex/apexflowcoverage/export`
- **权限要求**`apex:apexflowcoverage:export`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| testResultId | Long | 否 | 测试结果 ID |
| flowName | String | 否 | Flow 名称,支持模糊查询 |
| flowId | String | 否 | Flow ID |
| type | String | 否 | Flow 类型 |
| namespace | String | 否 | 命名空间 |
| minCoverage | Double | 否 | 最小覆盖率(百分比) |
| maxCoverage | Double | 否 | 最大覆盖率(百分比) |
#### 响应参数
- 返回 Excel 文件流,文件名为 "Apex Flow覆盖率数据.xlsx"
### 7. 查询 Flow 覆盖率警告列表
- **功能描述**:分页查询 Flow 覆盖率警告记录列表
- **请求方式**GET
- **请求路径**`/apex/apexflowwarning/list`
- **权限要求**`apex:apexflowwarning:list`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| pageNum | Integer | 否 | 当前页码,默认 1 |
| pageSize | Integer | 否 | 每页记录数,默认 10 |
| flowCoverageId | Long | 否 | Flow 覆盖率 ID |
| message | String | 否 | 警告消息,支持模糊查询 |
| warningType | String | 否 | 警告类型 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
| rows | Array | Flow 覆盖率警告记录列表 |
| total | Long | 总记录数 |
#### 响应数据项
| 参数名 | 类型 | 说明 |
|--------|------|------|
| id | Long | 记录 ID |
| flowCoverageId | Long | Flow 覆盖率 ID |
| message | String | 警告消息 |
| warningType | String | 警告类型 |
| createTime | String | 创建时间 |
#### 成功示例
```json
{
"code": 200,
"msg": "查询成功",
"rows": [
{
"id": 1,
"flowCoverageId": 1,
"message": "Flow coverage limit reached",
"warningType": "LIMIT_WARNING",
"createTime": "2026-02-05 10:30:00"
}
],
"total": 1
}
```
### 8. 查询 Flow 覆盖率警告详情
- **功能描述**:根据 ID 查询单个 Flow 覆盖率警告记录的详细信息
- **请求方式**GET
- **请求路径**`/apex/apexflowwarning/{id}`
- **权限要求**`apex:apexflowwarning:query`
#### 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| id | Long | 是 | Flow 覆盖率警告记录 ID路径参数 |
#### 响应参数
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功,其他失败) |
| msg | String | 提示信息 |
| data | Object | Flow 覆盖率警告详细信息 |
#### 响应数据项
| 参数名 | 类型 | 说明 |
|--------|------|------|
| id | Long | 记录 ID |
| flowCoverageId | Long | Flow 覆盖率 ID |
| message | String | 警告消息 |
| warningType | String | 警告类型 |
| createTime | String | 创建时间 |
#### 成功示例
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1,
"flowCoverageId": 1,
"message": "Flow coverage limit reached",
"warningType": "LIMIT_WARNING",
"createTime": "2026-02-05 10:30:00"
}
}
```
## 错误码
### 通用错误码
| 错误码 | 说明 |
|--------|------|
| 200 | 操作成功 |
| 500 | 系统内部错误 |
| 401 | 未授权,需要登录 |
| 403 | 禁止访问,权限不足 |
| 404 | 资源不存在 |
| 405 | 请求方法不允许 |
### 业务错误码
| 错误码 | 说明 |
|--------|------|
| 1001 | 参数校验失败 |
| 1002 | 记录不存在 |
| 1003 | 记录已存在 |
| 1004 | 操作失败 |
## 相关文档
- [需求文档](../requirements/sub/2026-01-28-002-05-Flow覆盖率.md)
- [设计文档](../design/2026-02-03-002-05-Flow覆盖率-设计.md)
- [决策记录](../decisions/2026-02-03-002-05-ADR-Flow覆盖率技术选型.md)
- [变更日志](../changelog/2026-02-05-002-05-changelog.md)
- [复盘文档](../retros/2026-02-05-002-05-retro.md)