docs:修改文档
This commit is contained in:
parent
6bc0ac71ee
commit
bd7badf3b5
@ -47,16 +47,10 @@
|
|||||||
│ nickname │
|
│ nickname │
|
||||||
│ avatar_url │
|
│ avatar_url │
|
||||||
└─────────────────┘
|
└─────────────────┘
|
||||||
│
|
```
|
||||||
│ LEFT JOIN
|
|
||||||
▼
|
> 注:`activity_contributions.item_id` 已存储道具 ID,查询时无需 JOIN activity_items 表。
|
||||||
┌─────────────────┐
|
> 前端传递 item_id,后端根据 item_id 单独查询 activity_items 获取 item_name、item_icon。
|
||||||
│ activity_items │
|
|
||||||
│─────────────────│
|
|
||||||
│ id │
|
|
||||||
│ item_name │
|
|
||||||
│ icon_url │
|
|
||||||
└─────────────────┘
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.2 表结构
|
### 2.2 表结构
|
||||||
@ -194,15 +188,16 @@ Gateway 调用 ActivityService(直接查 Repository)
|
|||||||
查询 activity_contributions 表,并联表查询用户信息和道具信息
|
查询 activity_contributions 表,并联表查询用户信息和道具信息
|
||||||
SELECT c.id, c.activity_id, c.user_id,
|
SELECT c.id, c.activity_id, c.user_id,
|
||||||
u.nickname as user_nickname, u.avatar_url as user_avatar,
|
u.nickname as user_nickname, u.avatar_url as user_avatar,
|
||||||
i.item_type, i.item_name, i.icon_url as item_icon,
|
c.item_type, c.item_id,
|
||||||
c.quantity, c.contribution_points, c.created_at
|
c.quantity, c.contribution_points, c.created_at
|
||||||
FROM activity_contributions c
|
FROM activity_contributions c
|
||||||
LEFT JOIN users u ON c.user_id = u.id
|
LEFT JOIN users u ON c.user_id = u.id
|
||||||
LEFT JOIN activity_items i ON c.item_id = i.id
|
|
||||||
WHERE c.activity_id = ?
|
WHERE c.activity_id = ?
|
||||||
AND (c.created_at > ? OR (c.created_at = ? AND c.id > ?))
|
AND (c.created_at > ? OR (c.created_at = ? AND c.id > ?))
|
||||||
ORDER BY c.created_at DESC, c.id DESC
|
ORDER BY c.created_at DESC, c.id DESC
|
||||||
LIMIT limit
|
LIMIT limit
|
||||||
|
|
||||||
|
-- 再根据返回的 item_id 列表,单独查询 activity_items 获取 item_name、item_icon
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
组装响应
|
组装响应
|
||||||
@ -651,7 +646,8 @@ onHide(() => {
|
|||||||
## 9. 实施步骤
|
## 9. 实施步骤
|
||||||
|
|
||||||
### 9.1 后端实现
|
### 9.1 后端实现
|
||||||
1. [x] 在 `activity_contributions` 表联表查询用户信息和道具信息(LEFT JOIN users, LEFT JOIN activity_items)
|
1. [x] 在 `activity_contributions` 表查询用户信息(仅 LEFT JOIN users)
|
||||||
|
2. [ ] 根据 item_id 单独查询 activity_items 获取 item_name、item_icon
|
||||||
2. [ ] 在 Redis 中实现连击计数器 `combo:{user_id}:{item_type}`,TTL 3秒
|
2. [ ] 在 Redis 中实现连击计数器 `combo:{user_id}:{item_type}`,TTL 3秒
|
||||||
3. [ ] 在 `activity_repository.go` 添加 `GetLatestContributions` 方法
|
3. [ ] 在 `activity_repository.go` 添加 `GetLatestContributions` 方法
|
||||||
4. [ ] 在 Gateway 层添加 `contribution_controller.go`
|
4. [ ] 在 Gateway 层添加 `contribution_controller.go`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user