feat: add campaign model and API integration with price and tags
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# WonderQ-MiniAPP Public API 对接文档
|
||||
|
||||
最后更新:2026-06-30
|
||||
最后更新:2026-07-02
|
||||
|
||||
本文档定义 `WonderQ-MiniAPP` 前台 H5/小程序对接 `WonderQ-Admin` 后端所需的 Public API 契约。当前 MiniAPP 主动调用站点配置、产品列表和线索提交 3 个接口;后端已存在的健康检查、产品详情和目的地列表接口建议继续保留,供后续前台按需接入。
|
||||
|
||||
@@ -60,6 +60,32 @@
|
||||
| `targetValue` | `string \| null` | 否 | 点击目标值 |
|
||||
| `isActive` | `boolean` | 否 | 是否启用 |
|
||||
|
||||
### `Campaign`
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `string` | 是 | 活动 ID |
|
||||
| `slug` | `string` | 是 | 活动标识 |
|
||||
| `title` | `string` | 是 | 活动标题 |
|
||||
| `description` | `string \| null` | 否 | 活动描述 |
|
||||
| `coverImage` | `string \| null` | 否 | 活动封面图 |
|
||||
| `priceAmount` | `number \| null` | 否 | 参考起价,单位按 `priceUnit` 展示 |
|
||||
| `priceUnit` | `string \| null` | 否 | 价格单位文案,默认 `起/人` |
|
||||
| `tags` | `string[]` | 否 | 活动卡片标签,最多 3 个 |
|
||||
| `status` | `string` | 是 | 活动状态;Public API 只返回 `published` |
|
||||
| `startsAt` | `string \| null` | 否 | 活动开始时间 |
|
||||
| `endsAt` | `string \| null` | 否 | 活动结束时间 |
|
||||
|
||||
### `RouteSection`
|
||||
|
||||
`RouteSection` 用于描述首页“精选线路”下的分组。`经典人文打卡线路`、`极限山野户外野咖线路`、`人文+户外综合混搭线路` 等属于“精选线路”的子集,不是独立一级模块。
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `string` | 是 | 分组 ID,例如 `routes`、`routes-outdoor`、`routes-mix` |
|
||||
| `title` | `string` | 是 | 分组标题 |
|
||||
| `productIds` | `string[]` | 是 | 该分组包含的产品 ID,产品详情来自 `/api/public/products` 的 `items` |
|
||||
|
||||
### `PublicProduct`
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
@@ -131,10 +157,21 @@
|
||||
| --- | --- | --- |
|
||||
| `heroSlides` | `HeroSlide[]` | 首页顶部轮播 |
|
||||
| `destinations` | `Destination[]` | 首页目的地入口 |
|
||||
| `map` | `Array<{ id: string; image: string; isActive?: boolean }>` | 贵州地图图片;MiniAPP 当前消费 `map[0].image` |
|
||||
| `themes` | `Theme[]` | 主题甄选入口 |
|
||||
| `ctaBanners` | `CtaBanner[]` | 底部 CTA Banner |
|
||||
| `campaigns` | `unknown[]` | 后端现有扩展字段,可保留 |
|
||||
| `routeSections` | `Array<{ id: string; title: string; productIds: string[] }>` | 后端现有扩展字段,可保留 |
|
||||
| `campaigns` | `Campaign[]` | 活动元信息,可用于“特价优惠”入口;当前不包含活动产品结果列表 |
|
||||
| `routeSections` | `RouteSection[]` | “精选线路”子分组定义 |
|
||||
|
||||
#### 首页模块数据归属
|
||||
|
||||
| 首页模块 | 当前接口归属 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| 特价优惠 | `site-config.campaigns` + `/api/public/products` | 当前 Public API 只返回活动元信息,不直接返回“特价优惠结果列表”。MiniAPP 若要展示活动线路,可按活动标题、标签或后续扩展的活动产品关联从 `/api/public/products` 中筛选。 |
|
||||
| 精选线路 | `site-config.routeSections` + `/api/public/products` | `routeSections` 只返回分组与 `productIds`;具体产品卡片数据由 `/api/public/products.items` 提供。 |
|
||||
| 经典人文打卡线路 | `routeSections` 子集 | 属于“精选线路”子分组,当前后端分组 ID 为 `routes`。 |
|
||||
| 极限山野户外野咖线路 | `routeSections` 子集 | 属于“精选线路”子分组,当前后端分组 ID 为 `routes-outdoor`。 |
|
||||
| 人文+户外综合混搭线路 | `routeSections` 子集 | 属于“精选线路”子分组,当前后端分组 ID 为 `routes-mix`。 |
|
||||
|
||||
#### 响应示例
|
||||
|
||||
@@ -161,8 +198,47 @@
|
||||
"aliases": [{ "id": "alias-1", "alias": "小七孔" }]
|
||||
}
|
||||
],
|
||||
"map": [
|
||||
{
|
||||
"id": "map-1",
|
||||
"image": "/assets/guizhou/guizhou-map.jpg",
|
||||
"isActive": true
|
||||
}
|
||||
],
|
||||
"themes": [],
|
||||
"ctaBanners": []
|
||||
"ctaBanners": [],
|
||||
"campaigns": [
|
||||
{
|
||||
"id": "campaign-1",
|
||||
"slug": "classic-deal",
|
||||
"title": "经典打卡特惠",
|
||||
"description": "经典首游活动",
|
||||
"coverImage": "/assets/guizhou/libo-xiaoqikong.jpg",
|
||||
"priceAmount": 162500,
|
||||
"priceUnit": "起/人",
|
||||
"tags": ["臻藏旅位", "赛事庆典"],
|
||||
"status": "published",
|
||||
"startsAt": null,
|
||||
"endsAt": null
|
||||
}
|
||||
],
|
||||
"routeSections": [
|
||||
{
|
||||
"id": "routes",
|
||||
"title": "经典人文打卡线路",
|
||||
"productIds": ["8a6e7c4f-0000-4000-9000-000000000001"]
|
||||
},
|
||||
{
|
||||
"id": "routes-outdoor",
|
||||
"title": "极限山野户外野咖线路",
|
||||
"productIds": []
|
||||
},
|
||||
{
|
||||
"id": "routes-mix",
|
||||
"title": "人文+户外综合混搭线路",
|
||||
"productIds": []
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -338,6 +414,8 @@
|
||||
|
||||
- `site-config` 与 `products` 会在应用启动时并行请求;任一请求失败时,MiniAPP 会回退到本地静态内容。
|
||||
- `products.items` 为空时,MiniAPP 会使用本地产品兜底数据。
|
||||
- “精选线路”由 `site-config.routeSections` 定义分组,由 `/api/public/products.items` 提供产品详情;`经典人文打卡线路`、`极限山野户外野咖线路`、`人文+户外综合混搭线路` 是“精选线路”的子集。
|
||||
- “特价优惠”当前没有独立 Public 结果列表字段;`site-config.campaigns` 只提供活动元信息,活动线路需通过产品标签/关键词筛选或后续扩展活动产品关联字段。
|
||||
- 产品搜索当前主要在前端执行,依赖 `title`、`tags`、`destination.name`、`summary`。
|
||||
- 产品详情页当前使用已加载的产品列表数据;后续可改为进入详情页时请求 `GET /api/public/products/{product_id}`。
|
||||
- 收藏、浏览历史和最近咨询记录由 MiniAPP 本地存储处理,不需要后端接口。
|
||||
@@ -346,7 +424,8 @@
|
||||
## 后端验证建议
|
||||
|
||||
- 为 `GET /health` 增加或保留健康检查测试。
|
||||
- 为 `GET /api/public/site-config` 验证返回 JSON 包含 `heroSlides`、`destinations`、`themes`、`ctaBanners` 数组字段。
|
||||
- 为 `GET /api/public/site-config` 验证返回 JSON 包含 `heroSlides`、`destinations`、`map`、`themes`、`ctaBanners`、`campaigns`、`routeSections` 数组字段。
|
||||
- 为 `GET /api/public/site-config` 验证 `routeSections` 表达“精选线路”子分组,并包含 `routes`、`routes-outdoor`、`routes-mix` 三个当前约定分组。
|
||||
- 为 `GET /api/public/products` 验证响应结构为 `{ items: [...] }`,并覆盖 `keyword`、`destinationId`、`status`、`take` 参数。
|
||||
- 为 `GET /api/public/products/{product_id}` 验证 UUID、数字 `sourceId` 和 404 场景。
|
||||
- 为 `GET /api/public/destinations` 验证只返回启用目的地及别名字段。
|
||||
|
||||
Reference in New Issue
Block a user