查询应用入口
1. 接口定位
- 接口名称: 查询应用入口
- 所属域: client/applet
- 业务目标: 获取当前上架中的小程序/应用入口列表
2. 请求定义
- Method:
POST - Path:
/applet/find - Content-Type: 推荐
application/json - operationID: 必填,请通过 Header
operationID传入 - 鉴权: 必填,需要通过 Header
token传入有效登录令牌 - 幂等性: 幂等(只读操作)
3. 请求参数
Header 参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| operationID | 是 | string | 链路追踪 ID |
| token | 是 | string | 登录令牌 |
Body 参数
- 无请求字段;当前协议
FindAppletReq为空对象。
4. 响应结构
通用响应包裹
| 字段 | 类型 | 说明 |
|---|---|---|
| errCode | int | 错误码,0 表示成功 |
| errMsg | string | 错误简述 |
| errDlt | string | 错误详情 |
| data | object | 业务数据 |
data 字段
| 字段 | 类型 | 说明 |
|---|---|---|
| applets | array<object> | 上架中的应用列表 |
applet 对象
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 应用 ID |
| name | string | 应用名称 |
| appID | string | 应用标识 |
| icon | string | 图标 URL |
| url | string | 入口 URL |
| md5 | string | 资源包 MD5 |
| size | int64 | 资源大小 |
| version | string | 版本号 |
| priority | uint32 | 排序优先级 |
| status | uint32 | 状态;当前仅返回上架状态 |
| createTime | int64 | 创建时间,毫秒时间戳 |
5. 业务规则
- 该接口要求已登录用户访问。
- 实际查询的是 admin 库中的 applet 集合。
- 仅返回状态为“上架”(
StatusOnShelf)的应用。 - 当前实现未做分页,也未按优先级重新排序,返回顺序依赖数据库查询结果。
6. 错误码与失败场景
| 错误码 | 场景 | 典型报错 |
|---|---|---|
| 1001 | Header 缺少 operationID | header must have operationID |
| 1001 | Header 缺少 token | token is empty |
| - | token 无法解析 | 由鉴权链路返回 |
| - | 数据库查询失败 | 由 MongoDB 查询链路返回 |
7. 示例
fetch 请求示例
javascript
fetch("http://localhost:10008/applet/find", {
method: "POST",
headers: {
operationID: "applet-find-001",
token: "user-token",
"Content-Type": "application/json",
},
body: JSON.stringify({}),
})
.then((res) => res.json())
.then((data) => console.log(data));成功响应示例
json
{
"errCode": 0,
"errMsg": "",
"errDlt": "",
"data": {
"applets": [
{
"id": "b4dd111f-12ab-4b6d-a001-ff1133445566",
"name": "审批助手",
"appID": "approval-assistant",
"icon": "https://cdn.example.com/applet/approval.png",
"url": "https://mini.example.com/approval",
"md5": "9c9f37d6d8b4ce7bb4c6db5d3a8f775f",
"size": 102400,
"version": "1.0.3",
"priority": 100,
"status": 1,
"createTime": 1774922600000
}
]
}
}8. 时序流程
- 校验
operationID和token。 - 调用 admin 服务查询所有上架中的 applet。
- 将数据库记录映射为
AppletInfo返回。
9. 变更记录
- 2026-03-31: 首版发布,基于 client API 路由与 admin applet 查询实现整理。