zhibo/test_gift_api.md
2026-01-03 19:22:42 +08:00

60 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 测试礼物管理API
## 1. 测试后端接口
在浏览器中打开开发者工具F12然后访问礼物管理页面查看Network标签页中的请求
### 检查请求
- URL: `/api/admin/gift/list?page=1&limit=20`
- Method: GET
- Status: 应该是 200
### 检查响应格式
后端应该返回这样的格式:
```json
{
"code": 200,
"message": "success",
"data": {
"list": [...],
"total": 20,
"page": 1,
"limit": 20,
"totalPage": 1
}
}
```
## 2. 如果返回格式不对
检查后端日志,看是否有错误信息。
## 3. 直接测试SQL
在数据库中执行:
```sql
SELECT id, name, image, diamond_price as diamondPrice, intimacy, status,
is_heartbeat as isHeartbeat, buy_type as buyType, belong, remark,
level, sort, create_time as createTime, update_time as updateTime
FROM eb_gift
WHERE is_deleted = 0
ORDER BY sort ASC, id DESC
LIMIT 20 OFFSET 0;
```
应该能看到20条礼物记录。
## 4. 常见问题
### 问题1: 404错误
- 确认后端服务已重启
- 确认GiftAdminController已编译
### 问题2: 数据为空
- 检查数据库中是否有数据
- 检查is_deleted字段是否都是0
### 问题3: 前端报错
- 清除浏览器缓存
- 重新构建前端:`npm run build:prod`