测试接口
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.get('https://napi.luizhen.xyz/')
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://napi.luizhen.xyz/');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X GET https://napi.luizhen.xyz/
响应示例
{
"code": 200,
"message": "Hello World",
"data": {}
}
用户登录
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | String | 必填 | 用户名 |
| password | String | 必填 | 密码 |
请求示例
fetch('https://napi.luizhen.xyz/user/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'testuser',
password: 'password123'
})
})
.then(response => response.json())
.then(data => {
console.log('Token:', data.data.token);
localStorage.setItem('token', data.data.token);
})
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/login', {
username: 'testuser',
password: 'password123'
})
.then(response => {
console.log('Token:', response.data.data.token);
localStorage.setItem('token', response.data.data.token);
})
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/login');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
const data = JSON.parse(xhr.responseText);
console.log('Token:', data.data.token);
localStorage.setItem('token', data.data.token);
}
};
xhr.send(JSON.stringify({
username: 'testuser',
password: 'password123'
}));
curl -X POST https://napi.luizhen.xyz/user/login \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"password": "password123"
}'
响应示例
{
"code": 200,
"message": "登录成功",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
用户注册
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | String | 必填 | 用户名(唯一) |
| password | String | 必填 | 密码 |
| String | 可选 | 邮箱地址 | |
| nickname | String | 可选 | 昵称 |
请求示例
fetch('https://napi.luizhen.xyz/user/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'newuser',
password: 'password123',
email: 'user@example.com',
nickname: '新用户'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/signup', {
username: 'newuser',
password: 'password123',
email: 'user@example.com',
nickname: '新用户'
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/signup');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
username: 'newuser',
password: 'password123',
email: 'user@example.com',
nickname: '新用户'
}));
curl -X POST https://napi.luizhen.xyz/user/signup \
-H "Content-Type: application/json" \
-d '{
"username": "newuser",
"password": "password123",
"email": "user@example.com",
"nickname": "新用户"
}'
响应示例
{
"code": 200,
"message": "注册成功",
"data": {
"username": "newuser",
"uid": "xxx-xxx-xxx"
}
}
上传文件
⚠️ 请求头设置
此接口需要 multipart/form-data 格式,并且需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| file | File | 必填 | 要上传的文件(form-data格式) |
| fileName | String | 必填 | 文件名称 |
| bucketName | String | 可选 | Bucket名称,未指定则使用默认bucket |
请求示例
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('fileName', 'myfile');
formData.append('bucketName', 'my-bucket'); // 可选
fetch('https://napi.luizhen.xyz/file/upload', {
method: 'POST',
headers: {
'token': string
},
body: formData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('fileName', 'myfile');
formData.append('bucketName', 'my-bucket'); // 可选
axios.post('https://napi.luizhen.xyz/file/upload', formData, {
headers: {
'token': string,
'Content-Type': 'multipart/form-data'
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('fileName', 'myfile');
formData.append('bucketName', 'my-bucket'); // 可选
xhr.open('POST', 'https://napi.luizhen.xyz/file/upload');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(formData);
curl -X POST https://napi.luizhen.xyz/file/upload \ -H "token: YOUR_TOKEN_HERE" \ -F "file=@/path/to/file.jpg" \ -F "fileName=myfile" \ -F "bucketName=my-bucket"
响应示例
{
"code": 200,
"message": "上传文件成功",
"data": {
"fileData": {
"username": "testuser",
"name": "myfile.jpg",
"path": "https://...",
"size": 1024,
"type": "image/jpeg",
"bucketName": "my-bucket",
"uploadDate": 1234567890,
"lastUpdateDate": 1234567890
}
}
}
查询文件
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| find | String | 可选 | 搜索关键词(文件名) |
| page.pageNumber | Number | 可选 | 页码,默认1 |
| page.pageSize | Number | 可选 | 每页数量,默认10 |
| filter | String | 可选 | 日期分类:year/month/day |
| bucketName | String | 可选 | Bucket名称,未指定则查询所有bucket |
请求示例
fetch('https://napi.luizhen.xyz/file/queryFiles', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
find: 'test',
page: {
pageNumber: 1,
pageSize: 10
},
filter: 'month', // 可选: year/month/day
bucketName: 'my-bucket' // 可选
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/file/queryFiles', {
find: 'test',
page: {
pageNumber: 1,
pageSize: 10
},
filter: 'month',
bucketName: 'my-bucket'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/file/queryFiles');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
find: 'test',
page: {
pageNumber: 1,
pageSize: 10
},
filter: 'month',
bucketName: 'my-bucket'
}));
curl -X POST https://napi.luizhen.xyz/file/queryFiles \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"find": "test",
"page": {
"pageNumber": 1,
"pageSize": 10
},
"filter": "month",
"bucketName": "my-bucket"
}'
响应示例
{
"code": 200,
"message": "共查询到5条信息",
"data": {
"files": [...],
"total": 5,
"pageNumber": 1,
"pageSize": 10,
"pageTotal": 1
}
}
创建Bucket
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| bucketName | String | 必填 | Bucket名称 |
| region | String | 可选 | 区域,默认使用配置中的region |
请求示例
fetch('https://napi.luizhen.xyz/file/createBucket', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
bucketName: 'my-new-bucket',
region: 'oss-cn-guangzhou' // 可选
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/file/createBucket', {
bucketName: 'my-new-bucket',
region: 'oss-cn-guangzhou'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/file/createBucket');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
bucketName: 'my-new-bucket',
region: 'oss-cn-guangzhou'
}));
curl -X POST https://napi.luizhen.xyz/file/createBucket \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"bucketName": "my-new-bucket",
"region": "oss-cn-guangzhou"
}'
响应示例
{
"code": 200,
"message": "创建bucket成功",
"data": {
"bucket": {
"name": "my-new-bucket",
"region": "oss-cn-guangzhou",
"username": "testuser",
"createDate": 1234567890,
"isDefault": false
}
}
}
查询所有用户
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/user/queryUser')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.get('https://napi.luizhen.xyz/user/queryUser')
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://napi.luizhen.xyz/user/queryUser');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X GET https://napi.luizhen.xyz/user/queryUser
响应示例
{
"code": 200,
"message": "查询所有用户成功",
"data": [...]
}
查询用户信息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
此接口无需参数,用户信息从token中获取
请求示例
fetch('https://napi.luizhen.xyz/user/queryUserInfo', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/queryUserInfo', {}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/queryUserInfo');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X POST https://napi.luizhen.xyz/user/queryUserInfo \ -H "Content-Type: application/json" \ -H "token: YOUR_TOKEN_HERE"
响应示例
{
"code": 200,
"message": "查询用户信息成功",
"data": {
"uid": "xxx",
"username": "testuser",
"nickname": "测试用户",
"email": "test@example.com",
"phone": "",
"avatar": "",
"password": "保密,不给看"
}
}
更新用户信息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| nickname | String | 可选 | 昵称 |
| String | 可选 | 邮箱地址 | |
| phone | String | 可选 | 手机号 |
请求示例
fetch('https://napi.luizhen.xyz/user/updateUserInfo', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
nickname: '新昵称',
email: 'newemail@example.com',
phone: '13800138000'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/updateUserInfo', {
nickname: '新昵称',
email: 'newemail@example.com',
phone: '13800138000'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/updateUserInfo');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
nickname: '新昵称',
email: 'newemail@example.com',
phone: '13800138000'
}));
curl -X POST https://napi.luizhen.xyz/user/updateUserInfo \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"nickname": "新昵称",
"email": "newemail@example.com",
"phone": "13800138000"
}'
响应示例
{
"code": 200,
"message": "修改用户信息成功",
"data": {
"uid": "xxx",
"username": "testuser",
"nickname": "新昵称",
"email": "newemail@example.com",
"phone": "13800138000"
}
}
修改密码
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| oldPassword | String | 必填 | 旧密码 |
| newPassword | String | 必填 | 新密码 |
请求示例
fetch('https://napi.luizhen.xyz/user/updatePassword', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
oldPassword: 'oldpass123',
newPassword: 'newpass123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/updatePassword', {
oldPassword: 'oldpass123',
newPassword: 'newpass123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/updatePassword');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
oldPassword: 'oldpass123',
newPassword: 'newpass123'
}));
curl -X POST https://napi.luizhen.xyz/user/updatePassword \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"oldPassword": "oldpass123",
"newPassword": "newpass123"
}'
响应示例
{
"code": 200,
"message": "修改密码成功"
}
更新头像
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| avatar | String | 必填 | 头像链接(必须以http://或https://开头) |
请求示例
fetch('https://napi.luizhen.xyz/user/updateAvatar', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
avatar: 'https://example.com/avatar.jpg'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/user/updateAvatar', {
avatar: 'https://example.com/avatar.jpg'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/user/updateAvatar');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
avatar: 'https://example.com/avatar.jpg'
}));
curl -X POST https://napi.luizhen.xyz/user/updateAvatar \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"avatar": "https://example.com/avatar.jpg"
}'
响应示例
{
"code": 200,
"message": "修改头像成功",
"data": {
"uid": "xxx",
"username": "testuser",
"avatar": "https://example.com/avatar.jpg"
}
}
发送消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| content | String | 必填 | 消息内容 |
| name | String | 可选 | 显示名称,默认使用用户昵称 |
请求示例
fetch('https://napi.luizhen.xyz/message/sendMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
content: '这是一条测试消息',
name: '我的昵称'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/sendMessage', {
content: '这是一条测试消息',
name: '我的昵称'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/sendMessage');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
content: '这是一条测试消息',
name: '我的昵称'
}));
curl -X POST https://napi.luizhen.xyz/message/sendMessage \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"content": "这是一条测试消息",
"name": "我的昵称"
}'
响应示例
{
"code": 200,
"message": "发送消息成功",
"data": {
"insertedId": "..."
}
}
查询消息
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/message/queryMessage')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.get('https://napi.luizhen.xyz/message/queryMessage')
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://napi.luizhen.xyz/message/queryMessage');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X GET https://napi.luizhen.xyz/message/queryMessage
响应示例
{
"code": 200,
"message": "查询消息成功",
"data": [
{
"mid": "xxx",
"content": "消息内容",
"user": {...},
"remarks": [...],
"likeCount": 5,
"replyCount": 3
}
]
}
按用户查询消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| uid | String | 必填 | 用户ID |
请求示例
fetch('https://napi.luizhen.xyz/message/queryMessageByUid', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
uid: 'user-uid-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/queryMessageByUid', {
uid: 'user-uid-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/queryMessageByUid');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
uid: 'user-uid-123'
}));
curl -X POST https://napi.luizhen.xyz/message/queryMessageByUid \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"uid": "user-uid-123"
}'
响应示例
{
"code": 200,
"message": "查询消息成功",
"data": [...]
}
删除消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mid | String | 必填 | 消息ID |
请求示例
fetch('https://napi.luizhen.xyz/message/deleteMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
mid: 'message-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/deleteMessage', {
mid: 'message-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/deleteMessage');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
mid: 'message-id-123'
}));
curl -X POST https://napi.luizhen.xyz/message/deleteMessage \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"mid": "message-id-123"
}'
响应示例
{
"code": 200,
"message": "删除消息成功",
"data": {
"deletedCount": 1
}
}
添加回复
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mid | String | 必填 | 消息ID |
| content | String | 必填 | 回复内容 |
| name | String | 可选 | 显示名称,默认使用用户昵称 |
请求示例
fetch('https://napi.luizhen.xyz/message/remark', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
mid: 'message-id-123',
content: '这是一条回复',
name: '我的昵称'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/remark', {
mid: 'message-id-123',
content: '这是一条回复',
name: '我的昵称'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/remark');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
mid: 'message-id-123',
content: '这是一条回复',
name: '我的昵称'
}));
curl -X POST https://napi.luizhen.xyz/message/remark \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"mid": "message-id-123",
"content": "这是一条回复",
"name": "我的昵称"
}'
响应示例
{
"code": 200,
"message": "添加回复成功",
"data": {
"insertedId": "..."
}
}
查询回复
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mid | String | 必填 | 消息ID(查询参数) |
请求示例
fetch('https://napi.luizhen.xyz/message/queryRemark?mid=message-id-123')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.get('https://napi.luizhen.xyz/message/queryRemark', {
params: {
mid: 'message-id-123'
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://napi.luizhen.xyz/message/queryRemark?mid=message-id-123');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X GET "https://napi.luizhen.xyz/message/queryRemark?mid=message-id-123"
响应示例
{
"code": 200,
"message": "查询回复成功",
"data": [
{
"rid": "xxx",
"mid": "message-id-123",
"content": "回复内容",
"user": {...},
"time": 1234567890
}
]
}
添加点赞
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mid | String | 必填 | 消息ID |
请求示例
fetch('https://napi.luizhen.xyz/message/addLike', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
mid: 'message-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/addLike', {
mid: 'message-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/addLike');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
mid: 'message-id-123'
}));
curl -X POST https://napi.luizhen.xyz/message/addLike \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"mid": "message-id-123"
}'
响应示例
{
"code": 200,
"message": "点赞成功",
"data": {
"insertedId": "..."
}
}
切换点赞
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mid | String | 必填 | 消息ID |
请求示例
fetch('https://napi.luizhen.xyz/message/toggleLike', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
mid: 'message-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/message/toggleLike', {
mid: 'message-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/message/toggleLike');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
mid: 'message-id-123'
}));
curl -X POST https://napi.luizhen.xyz/message/toggleLike \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"mid": "message-id-123"
}'
响应示例
{
"code": 200,
"message": "操作成功",
"data": {
"action": "added" // 或 "removed"
}
}
删除文件
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| _id | String | 必填 | 文件数据库ID |
| fileName | String | 必填 | 文件名 |
| bucketName | String | 可选 | Bucket名称,未指定则从数据库查询或使用默认 |
请求示例
fetch('https://napi.luizhen.xyz/file/delete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
_id: 'file-id-123',
fileName: 'myfile.jpg',
bucketName: 'my-bucket' // 可选
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/file/delete', {
_id: 'file-id-123',
fileName: 'myfile.jpg',
bucketName: 'my-bucket'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/file/delete');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
_id: 'file-id-123',
fileName: 'myfile.jpg',
bucketName: 'my-bucket'
}));
curl -X POST https://napi.luizhen.xyz/file/delete \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"_id": "file-id-123",
"fileName": "myfile.jpg",
"bucketName": "my-bucket"
}'
响应示例
{
"code": 200,
"message": "删除文件成功"
}
下载文件
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| fileName | String | 必填 | 文件名(查询参数) |
| bucketName | String | 可选 | Bucket名称,未指定则使用默认bucket(查询参数) |
请求示例
fetch('https://napi.luizhen.xyz/file/download?fileName=myfile.jpg&bucketName=my-bucket')
.then(response => response.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'myfile.jpg';
a.click();
})
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.get('https://napi.luizhen.xyz/file/download', {
params: {
fileName: 'myfile.jpg',
bucketName: 'my-bucket'
},
responseType: 'blob'
})
.then(response => {
const url = window.URL.createObjectURL(response.data);
const a = document.createElement('a');
a.href = url;
a.download = 'myfile.jpg';
a.click();
})
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://napi.luizhen.xyz/file/download?fileName=myfile.jpg&bucketName=my-bucket');
xhr.responseType = 'blob';
xhr.onload = function() {
if (xhr.status === 200) {
const url = window.URL.createObjectURL(xhr.response);
const a = document.createElement('a');
a.href = url;
a.download = 'myfile.jpg';
a.click();
}
};
xhr.send();
curl -X GET "https://napi.luizhen.xyz/file/download?fileName=myfile.jpg&bucketName=my-bucket" \ -o downloaded_file.jpg
响应示例
文件流(直接下载)
查询Bucket列表
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/file/queryBuckets', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/file/queryBuckets')
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/file/queryBuckets');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X POST https://napi.luizhen.xyz/file/queryBuckets \ -H "Content-Type: application/json"
响应示例
{
"code": 200,
"message": "查询bucket列表成功",
"data": {
"buckets": [...],
"total": 5
}
}
删除Bucket
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| bucketName | String | 必填 | Bucket名称 |
请求示例
fetch('https://napi.luizhen.xyz/file/deleteBucket', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
bucketName: 'my-bucket'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/file/deleteBucket', {
bucketName: 'my-bucket'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/file/deleteBucket');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
bucketName: 'my-bucket'
}));
curl -X POST https://napi.luizhen.xyz/file/deleteBucket \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"bucketName": "my-bucket"
}'
响应示例
{
"code": 200,
"message": "删除bucket成功"
}
发送消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| receiverId | String | 必填 | 接收方用户ID |
| content | String | 必填 | 消息内容 |
| type | String | 可选 | 消息类型,默认 "text" |
请求示例
fetch('https://napi.luizhen.xyz/chat/sendMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
receiverId: 'user-uid-123',
content: '你好,这是一条消息',
type: 'text'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/sendMessage', {
receiverId: 'user-uid-123',
content: '你好,这是一条消息',
type: 'text'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/sendMessage');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
receiverId: 'user-uid-123',
content: '你好,这是一条消息',
type: 'text'
}));
curl -X POST https://napi.luizhen.xyz/chat/sendMessage \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"receiverId": "user-uid-123",
"content": "你好,这是一条消息",
"type": "text"
}'
响应示例
{
"code": 200,
"message": "发送消息成功",
"data": {
"chatId": "xxx",
"senderId": "current-user-uid",
"receiverId": "user-uid-123",
"content": "你好,这是一条消息",
"type": "text",
"createTime": 1234567890
}
}
查询聊天记录
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | String | 必填 | 好友用户ID |
| pageNumber | Number | 可选 | 页码,默认1 |
| pageSize | Number | 可选 | 每页数量,默认50 |
请求示例
fetch('https://napi.luizhen.xyz/chat/queryChatHistory', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendId: 'user-uid-123',
pageNumber: 1,
pageSize: 50
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/queryChatHistory', {
friendId: 'user-uid-123',
pageNumber: 1,
pageSize: 50
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/queryChatHistory');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendId: 'user-uid-123',
pageNumber: 1,
pageSize: 50
}));
curl -X POST https://napi.luizhen.xyz/chat/queryChatHistory \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendId": "user-uid-123",
"pageNumber": 1,
"pageSize": 50
}'
响应示例
{
"code": 200,
"message": "查询聊天记录成功",
"data": {
"messages": [...],
"total": 100,
"pageNumber": 1,
"pageSize": 50,
"pageTotal": 2
}
}
撤回消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| chatId | String | 必填 | 聊天消息ID |
请求示例
fetch('https://napi.luizhen.xyz/chat/withdrawMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
chatId: 'chat-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/withdrawMessage', {
chatId: 'chat-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/withdrawMessage');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
chatId: 'chat-id-123'
}));
curl -X POST https://napi.luizhen.xyz/chat/withdrawMessage \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"chatId": "chat-id-123"
}'
响应示例
{
"code": 200,
"message": "撤回消息成功"
}
删除消息
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| chatId | String | 必填 | 聊天消息ID |
请求示例
fetch('https://napi.luizhen.xyz/chat/deleteMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
chatId: 'chat-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/deleteMessage', {
chatId: 'chat-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/deleteMessage');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
chatId: 'chat-id-123'
}));
curl -X POST https://napi.luizhen.xyz/chat/deleteMessage \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"chatId": "chat-id-123"
}'
响应示例
{
"code": 200,
"message": "删除消息成功"
}
标记消息已读
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| chatIds | Array | 必填 | 消息ID数组 |
| senderId | String | 必填 | 发送方用户ID |
请求示例
fetch('https://napi.luizhen.xyz/chat/markAsRead', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
chatIds: ['chat-id-1', 'chat-id-2'],
senderId: 'user-uid-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/markAsRead', {
chatIds: ['chat-id-1', 'chat-id-2'],
senderId: 'user-uid-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/markAsRead');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
chatIds: ['chat-id-1', 'chat-id-2'],
senderId: 'user-uid-123'
}));
curl -X POST https://napi.luizhen.xyz/chat/markAsRead \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"chatIds": ["chat-id-1", "chat-id-2"],
"senderId": "user-uid-123"
}'
响应示例
{
"code": 200,
"message": "标记已读成功"
}
查询未读数量
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/chat/queryUnreadCount', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/chat/queryUnreadCount', {}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/chat/queryUnreadCount');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X POST https://napi.luizhen.xyz/chat/queryUnreadCount \ -H "Content-Type: application/json" \ -H "token: YOUR_TOKEN_HERE"
响应示例
{
"code": 200,
"message": "查询未读消息数量成功",
"data": {
"unreadCount": 5
}
}
添加好友
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendUserId | String | 必填 | 好友用户ID |
| remark | String | 可选 | 备注信息 |
请求示例
fetch('https://napi.luizhen.xyz/friend/addFriend', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendUserId: 'user-uid-123',
remark: '这是我的朋友'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/addFriend', {
friendUserId: 'user-uid-123',
remark: '这是我的朋友'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/addFriend');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendUserId: 'user-uid-123',
remark: '这是我的朋友'
}));
curl -X POST https://napi.luizhen.xyz/friend/addFriend \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendUserId": "user-uid-123",
"remark": "这是我的朋友"
}'
响应示例
{
"code": 200,
"message": "发送好友请求成功",
"data": {
"friendId": "xxx",
"userId": "current-user-uid",
"friendUserId": "user-uid-123",
"status": "pending",
"createTime": 1234567890
}
}
同意好友请求
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | String | 必填 | 好友关系ID |
请求示例
fetch('https://napi.luizhen.xyz/friend/acceptFriend', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendId: 'friend-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/acceptFriend', {
friendId: 'friend-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/acceptFriend');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendId: 'friend-id-123'
}));
curl -X POST https://napi.luizhen.xyz/friend/acceptFriend \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendId": "friend-id-123"
}'
响应示例
{
"code": 200,
"message": "同意好友请求成功"
}
拒绝好友请求
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | String | 必填 | 好友关系ID |
请求示例
fetch('https://napi.luizhen.xyz/friend/rejectFriend', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendId: 'friend-id-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/rejectFriend', {
friendId: 'friend-id-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/rejectFriend');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendId: 'friend-id-123'
}));
curl -X POST https://napi.luizhen.xyz/friend/rejectFriend \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendId": "friend-id-123"
}'
响应示例
{
"code": 200,
"message": "拒绝好友请求成功"
}
查询好友列表
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
此接口无需参数
请求示例
fetch('https://napi.luizhen.xyz/friend/queryFriends', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/queryFriends', {}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/queryFriends');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send();
curl -X POST https://napi.luizhen.xyz/friend/queryFriends \ -H "Content-Type: application/json" \ -H "token: YOUR_TOKEN_HERE"
响应示例
{
"code": 200,
"message": "查询好友列表成功",
"data": {
"friends": [
{
"friendId": "xxx",
"friendUserId": "user-uid-123",
"remark": "我的朋友",
"user": {
"uid": "user-uid-123",
"username": "frienduser",
"nickname": "朋友昵称",
"avatar": "https://...",
"email": "friend@example.com"
},
"acceptTime": 1234567890
}
],
"total": 1
}
}
查询好友请求
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| type | String | 可选 | 请求类型:received(收到的请求)或 sent(发送的请求),默认 "received" |
请求示例
fetch('https://napi.luizhen.xyz/friend/queryFriendRequests', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
type: 'received' // 或 'sent'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/queryFriendRequests', {
type: 'received'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/queryFriendRequests');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
type: 'received'
}));
curl -X POST https://napi.luizhen.xyz/friend/queryFriendRequests \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"type": "received"
}'
响应示例
{
"code": 200,
"message": "查询好友请求列表成功",
"data": {
"requests": [
{
"friendId": "xxx",
"userId": "user-uid-123",
"friendUserId": "current-user-uid",
"remark": "备注",
"user": {
"uid": "user-uid-123",
"username": "requestuser",
"nickname": "请求者昵称",
"avatar": "https://..."
},
"createTime": 1234567890
}
],
"total": 1
}
}
删除好友
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendUserId | String | 必填 | 好友用户ID |
请求示例
fetch('https://napi.luizhen.xyz/friend/deleteFriend', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendUserId: 'user-uid-123'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/deleteFriend', {
friendUserId: 'user-uid-123'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/deleteFriend');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendUserId: 'user-uid-123'
}));
curl -X POST https://napi.luizhen.xyz/friend/deleteFriend \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendUserId": "user-uid-123"
}'
响应示例
{
"code": 200,
"message": "删除好友成功"
}
更新好友备注
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendUserId | String | 必填 | 好友用户ID |
| remark | String | 可选 | 备注信息 |
请求示例
fetch('https://napi.luizhen.xyz/friend/updateFriendRemark', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
friendUserId: 'user-uid-123',
remark: '新备注'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/updateFriendRemark', {
friendUserId: 'user-uid-123',
remark: '新备注'
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/updateFriendRemark');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
friendUserId: 'user-uid-123',
remark: '新备注'
}));
curl -X POST https://napi.luizhen.xyz/friend/updateFriendRemark \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"friendUserId": "user-uid-123",
"remark": "新备注"
}'
响应示例
{
"code": 200,
"message": "更新好友备注成功"
}
查询在线状态
⚠️ 请求头设置
需要在请求头中添加 token 字段用于身份验证。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userIds | Array | 必填 | 用户ID数组 |
请求示例
fetch('https://napi.luizhen.xyz/friend/queryOnlineStatus', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'token': string
},
body: JSON.stringify({
userIds: ['user-uid-1', 'user-uid-2']
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import axios from 'axios';
axios.post('https://napi.luizhen.xyz/friend/queryOnlineStatus', {
userIds: ['user-uid-1', 'user-uid-2']
}, {
headers: {
'token': string
}
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://napi.luizhen.xyz/friend/queryOnlineStatus');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('token', string);
xhr.onload = function() {
if (xhr.status === 200) {
console.log(JSON.parse(xhr.responseText));
}
};
xhr.send(JSON.stringify({
userIds: ['user-uid-1', 'user-uid-2']
}));
curl -X POST https://napi.luizhen.xyz/friend/queryOnlineStatus \
-H "Content-Type: application/json" \
-H "token: YOUR_TOKEN_HERE" \
-d '{
"userIds": ["user-uid-1", "user-uid-2"]
}'
响应示例
{
"code": 200,
"message": "查询在线状态成功",
"data": {
"onlineStatus": {
"user-uid-1": true,
"user-uid-2": false
},
"onlineUsers": ["user-uid-1"]
}
}