项目地址:manage.tzpcc.cn
本地地址: localhost:3001
1.管理员接口
2.用户接口
3.文章接口
4.评论接口
5.图片上传接口
参数 |
是否必须 |
类型 |
说明 |
user_name |
Y |
string |
管理员名称 |
password |
Y |
string |
管理员密码 |
super_secret |
N |
string |
超级密码 |
{
code: 0,
message: '登录成功'
}
or
{
code: 0,
message: '注册成功'
}
{
code: 0,
data: {
admin: '管理员',
avatar: '',
create_address: 'xx省 xx市',
create_time: '2018-04-08 23:49:21',
id: 19,
type: 1,
user_name: 'vdfgd'
}
}
参数 |
是否必须 |
类型 |
说明 |
limit |
N |
number |
显示的数量 |
offset |
Y |
number |
开始的数量 |
;[
{
admin: '管理员',
avatar: '',
create_address: 'xx省 xx市',
create_time: '2018-04-08 23:49:21',
id: 19,
type: 1,
user_name: 'vdfgd'
},
{
admin: '管理员',
avatar: '',
create_address: 'xx省 xx市',
create_time: '2018-04-07 23:49:21',
id: 18,
type: 1,
user_name: 'hxjsjjdxn'
},
...共limit条数据
]
{
code: 0,
message: '退出成功'
}
参数 |
是否必须 |
类型 |
说明 |
user_name |
Y |
string |
用户名称 |
password |
Y |
string |
用户密码 |
{
code: 0,
message: '登录成功',
data: {
username: 'dsfdsf',
id: 1,
avatar: '',
createAt: 1523599480,
create_time: '2018-04-13 14:04:40',
create_address: 'xx省 xx市',
}
}
or
{
code: 0,
message: '注册成功',
data: {
username: 'dsfdsf',
id: 1,
avatar: '',
createAt: 1523599480,
create_time: '2018-04-13 14:04:40',
create_address: 'xx省 xx市',
}
}
参数 |
是否必须 |
类型 |
说明 |
user_id |
Y |
number |
用户的 id |
{
code: 0,
data: {
username: 'dsfdsf',
id: 1,
avatar: '',
createAt: 1523599480,
create_time: '2018-04-13 14:04:40',
create_address: 'xx省 xx市',
}
}
参数 |
是否必须 |
类型 |
说明 |
limit |
N |
number |
显示的数量 |
offset |
Y |
number |
开始的数量 |
;[
{
avatar: '',
createAt: 1523599389809,
create_address: '浙江省 杭州市',
create_time: '2018-04-13 14:03:09',
id: 4,
username: 'gfsjkjlkds'
},
{
avatar: '',
createAt: 1523357798554,
create_address: '浙江省 杭州市',
create_time: '2018-04-10 18:56:38',
id: 3,
username: 'dhsfajhd,ja'
},
...共limit条数据
]
{
code: 0,
message: '退出成功'
}
注意:需要超级管理员登录才能创建文章
参数 |
是否必须 |
类型 |
说明 |
categorys |
Y |
array |
文章的分类 |
title |
Y |
string |
文章的标题 |
screenshot |
Y |
string |
文章的封面 |
content |
Y |
string |
文章的内容 |
description |
Y |
string |
文章的描述 |
{
code: 0,
message: '文章发布成功!'
}
参数 |
是否必须 |
类型 |
说明 |
limit |
N |
number (默认 10) |
显示的数量 |
offset |
Y |
number |
开始的数量 |
category |
N |
string (默认'all') |
文章的分类 |
sort |
N |
'recently' | 'read' |
列表的排序方式 |
;[
{
author: '辞修',
category: [{ _id: '5ac9a8f681d69d0d9c3902a0', title: 'node' }],
comment_count: 0,
create_time: '2018-04-08 13:30:30',
description: ' 广告费↵...',
id: 1,
last_update_time: '2018-04-08 13:30:30',
screenshot: '',
title: '测试',
views_count: 30
},
...共limit条
]
注意:需要超级管理员登录才能删除文章
参数 |
是否必须 |
类型 |
说明 |
id |
Y |
number |
文章的 id |
{
code: 0,
message: '文章删除成功!!!'
}
参数 |
是否必须 |
类型 |
说明 |
id |
Y |
number |
文章的 id |
update |
N |
boolean |
是否是更新 |
{
code: 0,
data: {
author: '辞修',
category: [{ _id: '5ac9a8f681d69d0d9c3902a0', title: 'node' }],
comment_count: 0,
create_time: '2018-04-08 13:30:30',
content: '<p> 广告费</p>',
description: ' 广告费↵...',
id: 1,
last_update_time: '2018-04-08 13:30:30',
screenshot: '',
title: '测试',
views_count: 30
}
}
注意:需要超级管理员登录才能修改文章
参数 |
是否必须 |
类型 |
说明 |
categorys |
Y |
array |
文章的分类 |
title |
Y |
string |
文章的标题 |
screenshot |
Y |
string |
文章的封面 |
content |
Y |
string |
文章的内容 |
id |
Y |
number |
文章的 id |
{
code: 0,
message: '更新文章成功!!'
}
/api/comments/:articleId/create
参数 |
是否必须 |
类型 |
说明 |
articleId |
Y |
number |
评论的文章的 id (作为 params 传递) |
userId |
Y |
number |
评论的用户 id |
content |
Y |
string |
评论的内容 |
{
code: 0,
data : {
content: "<p>测试评论</p>↵",
createAt: 1523605328579,
id: 1,
isLiked: false,
likedUser: [],
likesCount: 0,
respComment: false,
respUserId: 0,
respUserInfo: {id: 0, blogUser: "辞修"},
subComments: [],
subCount: 0,
topComment: [],
updateAt: "2018-04-13 15:42:08",
userId: 4,
userInfo: {
avatar: "",
createAt: 1523599389809,
create_address : "浙江省 杭州市",
create_time: "2018-04-13 14:03:09",
id: 4,
username: "gfsjkjlkds"
}
}
}
/api/comments/:articleId/list
参数 |
是否必须 |
类型 |
说明 |
articleId |
Y |
number |
评论的文章的 id (作为 params 传递) |
userId |
Y |
number |
用户的 id |
{
code: 0,
data: {
articleId: 1,
count: 1,
comments: [
{
content: "<p>测试评论</p>↵",
createAt: 1523605328579,
id: 1,
isLiked: false,
likedUser: [],
likesCount: 0,
respComment: false,
respUserId: 0,
respUserInfo: {id: 0, blogUser: "辞修"},
subComments: [],
subCount: 0,
topComment: [],
updateAt: "2018-04-13 15:42:08",
userId: 4,
userInfo: {
avatar: "",
createAt: 1523599389809,
create_address : "浙江省 杭州市",
create_time: "2018-04-13 14:03:09",
id: 4,
username: "gfsjkjlkds"
}
}
]
}
}
/api/comments/:articleId/like
参数 |
是否必须 |
类型 |
说明 |
articleId |
Y |
number |
评论的文章的 id (作为 params 传递) |
commentId |
Y |
number |
文章评论的 id |
userId |
Y |
number |
用户的 id |
{
code: 0,
isLiked: true,
likesCount: 1,
message: '点赞成功'
}
/api/comments/:articleId/:commentId/:userId/reply/:respUserId
参数 |
是否必须 |
类型 |
说明 |
articleId |
Y |
number |
评论的文章的 id (作为 params 传递) |
commentId |
Y |
number |
文章评论的 id (作为 params 传递) |
userId |
Y |
number |
用户的 id (作为 params 传递) |
respUserId |
Y |
number |
回复用户的 id (作为 params 传递) |
content |
Y |
string |
回复的内容 |
isReply |
N |
boolean (default=false) |
是否是对评论的回复 |
{
code: 0,
data: {
content: "<p>回复评论测试</p>↵",
createAt: 1523607349867,
id: 1,
isLiked: false,
likedUser: [],
likesCount: 0,
respComment: false,
respUserId: 4,
respUserInfo: {
avatar: "",
createAt: 1523599389809,
create_address : "浙江省 杭州市",
create_time: "2018-04-13 14:03:09",
id: 4,
username: "gfsjkjlkds"
},
subComments: [],
subCount: 0,
topComment: [],
updateAt: "2018-04-13 15:42:08",
userId: 4,
userInfo: {
avatar: "",
createAt: 1523599389809,
create_address : "浙江省 杭州市",
create_time: "2018-04-13 14:03:09",
id: 4,
username: "gfsjkjlkds"
}
}
}
参数 |
是否必须 |
类型 |
说明 |
formData |
Y |
FormData |
图片的 FormData |
fileInput.addEventListener('change', () => {
const formData = new FormData()
formData.append('image', fileInput.files[0])
axios.post('/api/admin/upload', formData)
}
{
code: 0,
image: {
hash: "FivStBp0zsL6E0fmqylJsHzJvVFJ",
key: "2018/04/13/1523549488070/162baa05119.jpg",
url: "https://blog.image.tzpcc.cn/2018/04/13/1523549488070/162baa05119.jpg"
}
}