api 接口设计,地址:domain.com/api
/login
Post:
{
"user": "admin",
"passwd": "1233456"
}
Response:
{
"state": "0",
"msg": "登录成功",
"data": {
"token": "assreiorcxljdfhlcmlskorelcsmxlj"
}
}
/book/new
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"data": {
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8"
}
}
Response:
{
"state": "0",
"msg": "新增成功",
"data": {
"id": "291"
}
}
/book/update
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"data": {
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8"
}
}
Response:
{
"state": "0",
"msg": "更新成功",
"data": {
"id": "291"
}
}
/book/del
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"data": {
"id": "291",
}
}
Response:
{
"state": "0",
"msg": "删除成功",
"data": {
"id": "291"
}
}
/book/read
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"data": {
"id": "291",
"schedule": "236"
}
}
Response:
{
"state": "0",
"msg": "更新进度成功",
"data": {
"id": "291",
"percent": "100"
}
}
/book/list
Post:
{
"query": {
"key": "value",
},
"index": "0",
"count": "10",
"field": [ "id", "dbid", "img", "name", "author", "page", "pub", "ISBN", "pubdate", "lend", "read" ] // 可选
}
Response:
{
"state": "0",
"msg": "查询成功",
"data": [
{
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8",
"lend": "true",
"state": "readed", // readed - 已读, reading - 在读, unread - 未读
"schedule": "236"
},
{
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8",
"lend": "true",
"state": "readed", // readed - 已读, reading - 在读, unread - 未读
"schedule": "236"
}
]
}
/book/get/:id
Post(可选):
{
"field": [ "id", "dbid", "img", "name", "author", "page", "pub", "ISBN", "pubdate" ]
}
Response:
{
"state": "0",
"msg": "查询成功",
"data": [
{
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8"
},
{
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8"
}
]
}
/lend/book
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"data": {
"id": "291",
"user": "姓名",
"return": "2017-04-17"
}
}
Response:
{
"state": "0",
"msg": "借阅成功",
"data": {
"id": "291",
}
}
/lend/list
Post:
{
"token": "assreiorcxljdfhlcmlskorelcsmxlj",
"query": {
"key": "value",
},
"index": "0",
"count": "10",
"field": [ "id", "dbid", "img", "name", "author", "page", "pub", "ISBN", "pubdate", "state" ] // 可选, 默认返回 id, name
}
Response:
{
"state": "0",
"msg": "查询成功",
"data": [
{
"lend": {
"user": "姓名",
"create": "2017-01-04",
"return": "2017-04-17",
},
"book": {
"id": "291",
"dbid": "25927585",
"img": "https://img3.doubanio.com/lpic/s27445100.jpg",
"name": "代码之髓",
"author": "[日] 西尾泰和",
"page": "236",
"pub": "人民邮电出版社",
"ISBN": "9787115361530",
"pubdate": "2014-8",
"state": "readed", // readed - 已读, reading - 在读, unread - 未读
}
}
]
}