新增点赞收藏功能:cloud_favorites 模型、查询/设置点赞状态及收藏列表接口
This commit is contained in:
@@ -29,6 +29,7 @@ app/
|
||||
clouds.py # 云图
|
||||
cloud_types.py # 云类型
|
||||
collections.py # 图鉴
|
||||
favorites.py # 照片点赞收藏
|
||||
profiles.py # 用户资料
|
||||
admin.py # 管理后台
|
||||
health.py # 健康检查
|
||||
@@ -159,6 +160,42 @@ fetch(url, { credentials: 'include' })
|
||||
|
||||
seed 会写入 10 种标准云类型(积云、层云、卷云等),含中英文名、云族与稀有度。
|
||||
|
||||
### 点赞收藏
|
||||
|
||||
对照片的点赞/收藏(与云类型「图鉴」不同)。数据表 `cloud_favorites`:`(user_id, cloud_id)` 唯一。
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `GET` | `/api/v1/clouds/{id}/favorite` | 查询喜欢状态(需登录) |
|
||||
| `PUT` | `/api/v1/clouds/{id}/favorite` | 设置或取消收藏(需登录) |
|
||||
| `GET` | `/api/v1/favorites/me` | 当前用户收藏列表分页(按收藏时间倒序) |
|
||||
|
||||
查询喜欢状态(默认当前用户;管理员可传 `user_id` 查他人):
|
||||
|
||||
```http
|
||||
GET /api/v1/clouds/{id}/favorite
|
||||
GET /api/v1/clouds/{id}/favorite?user_id=<uuid>
|
||||
```
|
||||
|
||||
设置/取消请求体:
|
||||
|
||||
```json
|
||||
{ "favorited": true }
|
||||
```
|
||||
|
||||
响应:
|
||||
|
||||
```json
|
||||
{
|
||||
"cloud_id": "…",
|
||||
"user_id": "…",
|
||||
"favorited": true,
|
||||
"favorite_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
可见性与查看云图一致:公开已审核照片,或本人/管理员可见的待审、隐藏照片。重复收藏为幂等;删除用户或云图时收藏记录级联删除。普通用户只能查自己的喜欢状态。
|
||||
|
||||
### 用户资料
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
@@ -269,11 +306,12 @@ uv run alembic upgrade head --sql
|
||||
- `tests/test_auth.py`:注册、邮箱确认、登录、刷新、登出、改密
|
||||
- `tests/test_clouds.py`:上传、缩略图、画廊、地图、更新与删除
|
||||
- `tests/test_collections.py`:图鉴解锁
|
||||
- `tests/test_favorites.py`:照片点赞收藏与取消、收藏列表
|
||||
- `tests/test_cloud_types.py`:云类型查询
|
||||
- `tests/test_profiles.py`:资料、用户云图、管理员 stats
|
||||
- `tests/test_admin.py`:统计、用户管理、审核与批量操作
|
||||
|
||||
当前约 80 个用例。生产环境仍建议在真实 PostgreSQL 上再跑一遍迁移与关键路径。
|
||||
生产环境仍建议在真实 PostgreSQL 上再跑一遍迁移与关键路径。
|
||||
|
||||
## 部署注意事项
|
||||
|
||||
|
||||
Reference in New Issue
Block a user