RESTful 接口文档
基础路径:/tc/v1,返回格式统一为
{"status": <HTTP状态码>, "message": "OK", "data": {...}}。
数据以 Teamcenter 风格的 UID 标识(如 item-p1000、bl-p1000-1),
可用物料编号查询后获取 UID,再查询 BOM 结构。
特殊接口:物料 LITHO-001(光刻机整机)的 BOM
直接返回外部上传的原始 JSON 文件 20260808-bom1-2.json(3316 行,不做包装,
顶层为数组,字段含 bom_level / parent_uid / child_uid
/ part_id / part_name / quantity)。
只读查询接口:/tc/v1/fixtures*
提供同一文件的列表、完整读取与按物料查询,返回统一包装的结构化 JSON;
未知 fixture / 物料返回 404,非法参数返回 400,防目录穿越。
接口一览
| 方法 | 路径 | 说明 | 主要参数 |
|---|---|---|---|
| GET | /tc/v1/health | 健康检查 | - |
| GET | /tc/v1/items | 物料列表 / 搜索 | item_id, q, item_type, project, status, limit, offset |
| POST | /tc/v1/items | 创建物料(测试用) | JSON body |
| GET | /tc/v1/items/<uid> | 物料详情 | - |
| GET | /tc/v1/items/<uid>/revisions | 物料版本列表 | - |
| GET | /tc/v1/items/<uid>/revisions/<rev_uid> | 版本详情 | - |
| GET | /tc/v1/items/<uid>/bom | BOM 结构(单层) | depth=0 默认,depth=-1 全展开 |
| GET | /tc/v1/items/<uid>/bom/expand | BOM 全展开(多层) | - |
| GET | /tc/v1/structures/<item_uid> | BOM 结构别名接口 | depth=0 默认 |
| GET | /tc/v1/bomlines/<uid> | BOM 行详情 | - |
| GET | /tc/v1/bomlines/<uid>/children | BOM 行的子行 | depth=0 默认 |
| GET | /tc/v1/fixtures | 已加载 fixture 列表(只读) | - |
| GET | /tc/v1/fixtures/<name> | 完整 fixture 读取(只读) | raw=1 返回原始字节 |
| GET | /tc/v1/fixtures/<name>/query | 按物料/字段查询(只读) | part_id, part_name, q, bom_level, revision_id, parent_id, child_uid, parent_uid, exact, limit, offset |
| GET | /tc/v1/fixtures/<name>/materials/<part_id> | 物料详情(只读,不存在 404) | - |
| GET | /tc/v1/export.xlsx | 一键下载全部MockTC数据(Excel) | - |
| GET | /tc/v1/fixtures/<name>/download | 下载单个外部BOM原始JSON | - |
| PATCH | /tc/v1/fixtures/<name>/rows/<child_uid> | 修改外部 BOM 节点(管理员) | JSON 字段 |
| POST | /tc/v1/fixtures/<name>/rows | 新增外部 BOM 子节点(管理员) | parent_uid, part_id, quantity... |
| DELETE | /tc/v1/fixtures/<name>/rows/<child_uid> | 删除外部 BOM 节点(管理员) | cascade=1 |
| PATCH | /tc/v1/bomlines/<uid> | 修改标准 BOM 行(管理员) | position, quantity, unit... |
示例
1. 搜索物料
curl "/tc/v1/items?q=变速箱"
2. 查询单层 BOM
curl "/tc/v1/items/item-p1000/bom?depth=0"
3. 查询完整 BOM(多级展开)
curl "/tc/v1/items/item-p1000/bom/expand"
4. 按物料编号直接获取 BOM
curl "/tc/v1/structures/item-p1000?depth=-1"
5. 创建物料
curl -X POST "/tc/v1/items" -H "Content-Type: application/json" -d '{
"item_id": "TEST-001",
"item_name": "测试零件",
"item_type": "Part",
"project": "XM-MOCK",
"revision_id": "A"
}'
6. 外部 BOM 数据(LITHO-001,返回 20260808-bom1-2.json 原始内容)
curl "/tc/v1/items/item-litho-001/bom/expand"
7. 查看可用 fixture 列表
curl "/tc/v1/fixtures"
8. 按物料编号查询(精确匹配,附带父级信息)
curl "/tc/v1/fixtures/20260808-bom1-2.json/query?part_id=S01&exact=1"
9. 完整读取 fixture(结构化)
curl "/tc/v1/fixtures/20260808-bom1-2.json"
10. 物料详情(不存在返回 404)
curl "/tc/v1/fixtures/20260808-bom1-2.json/materials/S01"