187 lines
5.1 KiB
Markdown
187 lines
5.1 KiB
Markdown
|
|
# API 文档 - 描述特定对象
|
|||
|
|
|
|||
|
|
## 元数据
|
|||
|
|
- 需求编号:001
|
|||
|
|
- 子需求编号:001-01
|
|||
|
|
- 接口编号:002
|
|||
|
|
- 创建时间:2026-02-02
|
|||
|
|
- 创建人:AI Assistant
|
|||
|
|
- 状态:已完成
|
|||
|
|
|
|||
|
|
## 接口概述
|
|||
|
|
获取特定对象的详细定义,包含字段列表、子关系、权限信息等。
|
|||
|
|
|
|||
|
|
## 基本信息
|
|||
|
|
|
|||
|
|
- **功能描述**:获取特定对象的详细定义
|
|||
|
|
- **请求方式**:POST
|
|||
|
|
- **请求路径**:`/partner/describe/sobject`
|
|||
|
|
- **权限要求**:`@PreAuthorize("@ss.hasPermi('partner:describe:sobject')")`
|
|||
|
|
|
|||
|
|
## 请求参数
|
|||
|
|
|
|||
|
|
### 请求体(JSON)
|
|||
|
|
|
|||
|
|
| 参数名 | 类型 | 必填 | 说明 | 示例值 |
|
|||
|
|
|--------|------|------|------|--------|
|
|||
|
|
| objectType | String | 是 | 对象类型(如 Account、Contact) | Account |
|
|||
|
|
|
|||
|
|
### 请求示例
|
|||
|
|
|
|||
|
|
```json
|
|||
|
|
{
|
|||
|
|
"objectType": "Account"
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 响应参数
|
|||
|
|
|
|||
|
|
| 参数名 | 类型 | 说明 |
|
|||
|
|
|--------|------|------|
|
|||
|
|
| code | Integer | 状态码(200 成功,其他失败) |
|
|||
|
|
| msg | String | 提示信息 |
|
|||
|
|
| data | Object | 响应数据 |
|
|||
|
|
| data.sObject | Object | 对象描述 |
|
|||
|
|
| data.sObject.name | String | 对象名称 |
|
|||
|
|
| data.sObject.label | String | 对象标签 |
|
|||
|
|
| data.sObject.keyPrefix | String | 对象键前缀 |
|
|||
|
|
| data.sObject.custom | Boolean | 是否为自定义对象 |
|
|||
|
|
| data.sObject.createable | Boolean | 是否可创建 |
|
|||
|
|
| data.sObject.updateable | Boolean | 是否可更新 |
|
|||
|
|
| data.sObject.deletable | Boolean | 是否可删除 |
|
|||
|
|
| data.sObject.queryable | Boolean | 是否可查询 |
|
|||
|
|
| data.sObject.fields | Array | 字段列表 |
|
|||
|
|
| data.sObject.fields[].name | String | 字段名称 |
|
|||
|
|
| data.sObject.fields[].label | String | 字段标签 |
|
|||
|
|
| data.sObject.fields[].type | String | 字段类型 |
|
|||
|
|
| data.sObject.fields[].length | Integer | 字段长度 |
|
|||
|
|
| data.sObject.fields[].custom | Boolean | 是否为自定义字段 |
|
|||
|
|
| data.sObject.fields[].createable | Boolean | 是否可创建 |
|
|||
|
|
| data.sObject.fields[].updateable | Boolean | 是否可更新 |
|
|||
|
|
| data.sObject.fields[].nillable | Boolean | 是否可为空 |
|
|||
|
|
| data.sObject.fields[].defaultedOnCreate | Boolean | 创建时是否有默认值 |
|
|||
|
|
| data.sObject.childRelationships | Array | 子关系列表 |
|
|||
|
|
| data.success | Boolean | 是否成功 |
|
|||
|
|
| data.errors | Array | 错误信息列表 |
|
|||
|
|
|
|||
|
|
### 成功响应示例
|
|||
|
|
|
|||
|
|
```json
|
|||
|
|
{
|
|||
|
|
"code": 200,
|
|||
|
|
"msg": "操作成功",
|
|||
|
|
"data": {
|
|||
|
|
"sObject": {
|
|||
|
|
"name": "Account",
|
|||
|
|
"label": "Account",
|
|||
|
|
"keyPrefix": "001",
|
|||
|
|
"custom": false,
|
|||
|
|
"createable": true,
|
|||
|
|
"updateable": true,
|
|||
|
|
"deletable": true,
|
|||
|
|
"queryable": true,
|
|||
|
|
"fields": [
|
|||
|
|
{
|
|||
|
|
"name": "Id",
|
|||
|
|
"label": "Account ID",
|
|||
|
|
"type": "id",
|
|||
|
|
"length": 18,
|
|||
|
|
"custom": false,
|
|||
|
|
"createable": false,
|
|||
|
|
"updateable": false,
|
|||
|
|
"nillable": false,
|
|||
|
|
"defaultedOnCreate": false
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"name": "Name",
|
|||
|
|
"label": "Account Name",
|
|||
|
|
"type": "string",
|
|||
|
|
"length": 255,
|
|||
|
|
"custom": false,
|
|||
|
|
"createable": true,
|
|||
|
|
"updateable": true,
|
|||
|
|
"nillable": false,
|
|||
|
|
"defaultedOnCreate": false
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"name": "Industry",
|
|||
|
|
"label": "Industry",
|
|||
|
|
"type": "picklist",
|
|||
|
|
"length": 40,
|
|||
|
|
"custom": false,
|
|||
|
|
"createable": true,
|
|||
|
|
"updateable": true,
|
|||
|
|
"nillable": true,
|
|||
|
|
"defaultedOnCreate": false
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
"childRelationships": [
|
|||
|
|
{
|
|||
|
|
"relationshipName": "Contacts",
|
|||
|
|
"childSObject": "Contact",
|
|||
|
|
"field": "AccountId"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"relationshipName": "Opportunities",
|
|||
|
|
"childSObject": "Opportunity",
|
|||
|
|
"field": "AccountId"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
},
|
|||
|
|
"success": true,
|
|||
|
|
"errors": null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 失败响应示例
|
|||
|
|
|
|||
|
|
```json
|
|||
|
|
{
|
|||
|
|
"code": 500,
|
|||
|
|
"msg": "描述特定对象失败",
|
|||
|
|
"data": {
|
|||
|
|
"sObject": null,
|
|||
|
|
"success": false,
|
|||
|
|
"errors": [
|
|||
|
|
{
|
|||
|
|
"statusCode": "INVALID_TYPE",
|
|||
|
|
"message": "Invalid object type: InvalidObject"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 错误码
|
|||
|
|
|
|||
|
|
| 错误码 | 说明 | 处理建议 |
|
|||
|
|
|--------|------|----------|
|
|||
|
|
| 200 | 操作成功 | - |
|
|||
|
|
| 400 | 请求参数错误 | 检查请求参数格式和必填项 |
|
|||
|
|
| 401 | 未登录或登录已过期 | 请重新登录 |
|
|||
|
|
| 403 | 无权限访问 | 请检查用户权限 |
|
|||
|
|
| 500 | 服务器内部错误 | 请联系管理员或稍后重试 |
|
|||
|
|
|
|||
|
|
## 注意事项
|
|||
|
|
|
|||
|
|
1. 对象名称区分大小写
|
|||
|
|
2. 返回的字段列表包含当前用户有权限访问的所有字段
|
|||
|
|
3. 字段类型包括:string、int、double、boolean、date、datetime、picklist 等
|
|||
|
|
4. 子关系列表可用于查询相关对象
|
|||
|
|
5. 某些字段可能因为权限限制不可访问
|
|||
|
|
6. 对象描述可能很大,建议缓存结果
|
|||
|
|
|
|||
|
|
## 使用场景
|
|||
|
|
|
|||
|
|
- 获取对象的完整元数据
|
|||
|
|
- 动态生成表单
|
|||
|
|
- 验证字段是否存在
|
|||
|
|
- 构建查询构建器
|
|||
|
|
- 权限检查和验证
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
- [需求文档](../../requirements/2026-01-28-001-PartnerAPI源org实现.md)
|
|||
|
|
- [设计文档](../../design/2026-01-29-001-01-认证和会话管理-设计.md)
|
|||
|
|
- [决策记录](../../decisions/2026-01-29-001-01-ADR-认证和会话管理技术选型.md)
|