Appearance
评论接口用于管理帖子的评论和回复。
GET /api/posts/{postId}/comments?page=1&limit=20&sort=latest
路径参数:
查询参数:
响应示例:
{ "success": true, "data": { "comments": [ { "id": "comment-123", "content": "评论内容", "author": { "id": "user-123", "username": "user123", "avatar": "https://example.com/avatar.jpg" }, "postId": "post-123", "parentId": null, "likesCount": 5, "repliesCount": 3, "createdAt": "2024-03-22T10:00:00.000Z", "updatedAt": "2024-03-22T10:05:00.000Z", "replies": [ { "id": "comment-456", "content": "回复内容", "author": { "id": "user-456", "username": "user456", "avatar": "https://example.com/avatar2.jpg" }, "likesCount": 2, "createdAt": "2024-03-22T10:10:00.000Z" } ] } ], "pagination": { "page": 1, "limit": 20, "total": 56, "totalPages": 3 } }, "timestamp": "2024-03-22T12:00:00.000Z" }
POST /api/posts/{postId}/comments Authorization: Bearer <token> Content-Type: application/json { "content": "评论内容", "parentId": "parent-comment-id" }
请求参数:
PUT /api/comments/{commentId} Authorization: Bearer <token> Content-Type: application/json { "content": "更新后的评论内容" }
DELETE /api/comments/{commentId} Authorization: Bearer <token>
POST /api/comments/{commentId}/like Authorization: Bearer <token>
{ "success": true, "data": { "liked": true, "likesCount": 6 }, "timestamp": "2024-03-22T12:00:00.000Z" }
DELETE /api/comments/{commentId}/like Authorization: Bearer <token>
GET /api/comments/{commentId}
GET /api/users/{userId}/comments?page=1&limit=20
POST /api/comments/batch-delete Authorization: Bearer <token> Content-Type: application/json { "commentIds": ["comment-1", "comment-2", "comment-3"] }
POST /api/comments/{commentId}/report Authorization: Bearer <token> Content-Type: application/json { "reason": "spam", "description": "评论包含垃圾信息" }
举报原因:
评论接口
评论接口用于管理帖子的评论和回复。
获取评论列表
路径参数:
查询参数:
响应示例:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
创建评论
2
3
4
5
6
7
8
请求参数:
更新评论
2
3
4
5
6
7
删除评论
2
点赞评论
2
响应示例:
2
3
4
5
6
7
8
取消点赞评论
2
获取评论详情
获取用户评论
批量删除评论
2
3
4
5
6
7
举报评论
2
3
4
5
6
7
8
举报原因:
错误码
下一步