新增数据接口,数据内容包括 评论id,评论人id,评论人昵称,短评内容,短评图片,来源,评论内省,媒资id,被举报原因,举报人id,举报人昵称,被举报时间,审核处理状态,操作这些内容,生成一份接口文档
时间: 2023-08-10 12:06:00 浏览: 48
接口名称:评论管理接口
接口地址:/api/comment
请求方法:GET/POST/PUT/DELETE
请求参数:
| 参数名 | 类型 | 是否必须 | 描述 |
| ------ | ---- | -------- | ---- |
| comment_id | int | 否 | 评论ID |
| user_id | int | 否 | 评论人ID |
| user_nickname | string | 否 | 评论人昵称 |
| comment_content | string | 是 | 短评内容 |
| comment_pic | string | 否 | 短评图片 |
| source | string | 否 | 来源 |
| comment_reflection | string | 否 | 评论内省 |
| media_id | int | 否 | 媒资ID |
| report_reason | string | 否 | 被举报原因 |
| reporter_id | int | 否 | 举报人ID |
| reporter_nickname | string | 否 | 举报人昵称 |
| reported_time | datetime | 否 | 被举报时间 |
| audit_status | int | 否 | 审核处理状态(0-待审核,1-审核通过,2-审核不通过) |
| page | int | 否 | 分页页码,默认为1 |
| limit | int | 否 | 分页大小,默认为10 |
响应参数:
| 参数名 | 类型 | 描述 |
| ------ | ---- | ---- |
| code | int | 状态码(0-成功,1-失败) |
| msg | string | 状态信息 |
| data | array | 数据列表 |
| total | int | 总记录数 |
数据列表:
| 参数名 | 类型 | 描述 |
| ------ | ---- | ---- |
| comment_id | int | 评论ID |
| user_id | int | 评论人ID |
| user_nickname | string | 评论人昵称 |
| comment_content | string | 短评内容 |
| comment_pic | string | 短评图片 |
| source | string | 来源 |
| comment_reflection | string | 评论内省 |
| media_id | int | 媒资ID |
| report_reason | string | 被举报原因 |
| reporter_id | int | 举报人ID |
| reporter_nickname | string | 举报人昵称 |
| reported_time | datetime | 被举报时间 |
| audit_status | int | 审核处理状态(0-待审核,1-审核通过,2-审核不通过) |
示例:
1. 查询评论列表
请求方式:GET
请求地址:/api/comment?page=1&limit=10
响应内容:
```json
{
"code": 0,
"msg": "成功",
"data": [
{
"comment_id": 1,
"user_id": 1001,
"user_nickname": "小明",
"comment_content": "这是一条短评",
"comment_pic": "",
"source": "网站",
"comment_reflection": "",
"media_id": 10001,
"report_reason": "",
"reporter_id": 0,
"reporter_nickname": "",
"reported_time": "",
"audit_status": 0
},
{
"comment_id": 2,
"user_id": 1002,
"user_nickname": "小红",
"comment_content": "这是另一条短评",
"comment_pic": "",
"source": "APP",
"comment_reflection": "",
"media_id": 10002,
"report_reason": "",
"reporter_id": 0,
"reporter_nickname": "",
"reported_time": "",
"audit_status": 0
}
],
"total": 2
}
```
2. 添加一条评论
请求方式:POST
请求地址:/api/comment
请求参数:
```json
{
"user_id": 1001,
"user_nickname": "小明",
"comment_content": "这是新增的一条短评",
"source": "网站",
"media_id": 10001
}
```
响应内容:
```json
{
"code": 0,
"msg": "成功",
"data": {
"comment_id": 3,
"user_id": 1001,
"user_nickname": "小明",
"comment_content": "这是新增的一条短评",
"comment_pic": "",
"source": "网站",
"comment_reflection": "",
"media_id": 10001,
"report_reason": "",
"reporter_id": 0,
"reporter_nickname": "",
"reported_time": "",
"audit_status": 0
}
}
```
3. 修改一条评论
请求方式:PUT
请求地址:/api/comment
请求参数:
```json
{
"comment_id": 3,
"user_id": 1001,
"user_nickname": "小明",
"comment_content": "这是修改后的短评",
"source": "网站",
"media_id": 10001
}
```
响应内容:
```json
{
"code": 0,
"msg": "成功",
"data": {
"comment_id": 3,
"user_id": 1001,
"user_nickname": "小明",
"comment_content": "这是修改后的短评",
"comment_pic": "",
"source": "网站",
"comment_reflection": "",
"media_id": 10001,
"report_reason": "",
"reporter_id": 0,
"reporter_nickname": "",
"reported_time": "",
"audit_status": 0
}
}
```
4. 删除一条评论
请求方式:DELETE
请求地址:/api/comment
请求参数:
```json
{
"comment_id": 3
}
```
响应内容:
```json
{
"code": 0,
"msg": "成功",
"data": null
}
```