239 lines
3.1 KiB
Markdown
239 lines
3.1 KiB
Markdown
|
|
# 关注功能模块接口文档
|
||
|
|
|
||
|
|
## 模块概述
|
||
|
|
关注功能模块提供用户关注、取消关注、关注列表、粉丝列表等功能。
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 接口列表
|
||
|
|
|
||
|
|
### 1. 关注用户
|
||
|
|
|
||
|
|
**接口路径**: `POST /api/front/follow/follow`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"userId": 目标用户ID
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"success": true,
|
||
|
|
"message": "关注成功",
|
||
|
|
"isFollowing": true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 2. 取消关注
|
||
|
|
|
||
|
|
**接口路径**: `POST /api/front/follow/unfollow`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"userId": 目标用户ID
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"success": true,
|
||
|
|
"message": "取消关注成功",
|
||
|
|
"isFollowing": false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 3. 检查关注状态
|
||
|
|
|
||
|
|
**接口路径**: `GET /api/front/follow/status/{userId}`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```
|
||
|
|
userId: 用户ID (路径参数)
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"isFollowing": true,
|
||
|
|
"userId": 用户ID
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 4. 批量检查关注状态
|
||
|
|
|
||
|
|
**接口路径**: `POST /api/front/follow/status/batch`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"userIds": [用户ID1, 用户ID2, 用户ID3]
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"statusMap": {
|
||
|
|
"用户ID1": true,
|
||
|
|
"用户ID2": false,
|
||
|
|
"用户ID3": true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 5. 获取关注列表
|
||
|
|
|
||
|
|
**接口路径**: `GET /api/front/follow/following`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```
|
||
|
|
page: 页码 (默认1)
|
||
|
|
pageSize: 每页数量 (默认20)
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"list": [
|
||
|
|
{
|
||
|
|
"userId": 用户ID,
|
||
|
|
"nickname": "昵称",
|
||
|
|
"avatar": "头像URL",
|
||
|
|
"isOnline": true,
|
||
|
|
"followTime": "关注时间"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"total": 总数,
|
||
|
|
"page": 当前页,
|
||
|
|
"pageSize": 每页数量
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 6. 获取粉丝列表
|
||
|
|
|
||
|
|
**接口路径**: `GET /api/front/follow/followers`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```
|
||
|
|
page: 页码 (默认1)
|
||
|
|
pageSize: 每页数量 (默认20)
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"list": [
|
||
|
|
{
|
||
|
|
"userId": 用户ID,
|
||
|
|
"nickname": "昵称",
|
||
|
|
"avatar": "头像URL",
|
||
|
|
"isOnline": true,
|
||
|
|
"isMutualFollow": false,
|
||
|
|
"followTime": "关注时间"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"total": 总数,
|
||
|
|
"page": 当前页,
|
||
|
|
"pageSize": 每页数量
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**isMutualFollow说明**: 是否互相关注
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 7. 获取关注统计
|
||
|
|
|
||
|
|
**接口路径**: `GET /api/front/follow/stats`
|
||
|
|
|
||
|
|
**请求头**:
|
||
|
|
```
|
||
|
|
Authorization: Bearer {token}
|
||
|
|
```
|
||
|
|
|
||
|
|
**请求参数**:
|
||
|
|
```
|
||
|
|
userId: 用户ID (可选,不传则查询当前用户)
|
||
|
|
```
|
||
|
|
|
||
|
|
**返回参数**:
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"code": 200,
|
||
|
|
"msg": "success",
|
||
|
|
"data": {
|
||
|
|
"followingCount": 关注数,
|
||
|
|
"followersCount": 粉丝数
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|