- baseURL:
http://xxx.xxx.xxx.xxx
- 所有前端向服务器发送的post数据的
Content-Type
为multipart/form-data
- 所有服务器返回数据均为json(即服务器返回数据的Content-Type为
application/json
),统一格式如下:
{
"code": xxx,/*本次返回数据的状态码*/
"msg": xxx,/*本次返回数据的附加信息*/
"data": { /*这里是返回的有效数据*/ }
}
具体要求:
若正常返回,code为200,msg设为success即可;
若出现错误,code为错误代码,msg字段说明错误原因。
具体对应接口、功能及细节如下
功能 | 接口 | 参数 | 输出 | 说明 |
登录 | /account/login/ | username:用户名 password: 密码 | { "code": 200, "msg": "successfully", "data": { "user_id": 1 } } | user_id用于之后与用户相关的操作 |
注册 | username:用户名password1:密码 password2: 密码 email:邮箱 | { "code": 200, "msg": "successfully", "data": { "user_id": 2 } } |
| |
添加笔记本 | /file/add_notebook/ | name:笔记本名称 user_id: 用户id | { "code": 200, "msg": "successful", "data": { "name": notebook5", "user_id": "1" } } | 其中data为成功添加的笔记本信息 |
获取所有笔记本 | /file/get_notebook/ | user_id: 用户id | { "code": 200, "msg": "successful", "data": [ { "name": "notebook1", "user_id": "1" }, { "name": "notebook3", "user_id": "1" } ] } |
|
删除选定笔记本 | /file/delete_notebook/ | name:笔记本名称 user_id: 用户id | { "code": 200, "msg": "successful", "data": { "name": notebook5", "user_id": "1" } } | 其中data为成功删除的笔记本信息 |
更改笔记本名称 | /file/update_notebook/ | name:笔记本名称 user_id: 用户id new_name:新的笔记本名称
| { "code": 200, "msg": "successful", "data": [ { "name": "notebook1", "user_id": "1" }, { "name": "notebook3", "user_id": "1" } ] } | 返回更新后的所有文件夹 |
添加新的笔记 | /file/add_note/ | title:笔记名称 user_id: 用户id content:笔记内容 tag: 标签 notebook:笔记本名称
| { "code": 200, "msg": "successful", "data": { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } } | tag是笔记的标签,如果可以用于后期的检索,现在直接将tag值设为’default’传过来即可 |
获取用户所有的笔记 | /file/getget_note_by_notebook_note/ | user_id: 用户id | { "code": 200, "msg": "successful", "data": [ { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content5", "notebook": "notebook3" }, { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } ] } |
|
根据笔记的title获取笔记细节 | /file/select_note/ | title:笔记名称 user_id: 用户id notebook:笔记本名称 | { "code": 200, "msg": "successful", "data": { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } } |
|
删除选定笔记 | /file/delete_note/ | title:笔记名称 user_id: 用户id notebook:笔记本名称 | { "code": 200, "msg": "successful", "data": { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } } | Data为删除的笔记 |
更改笔记信息/移动文件夹 | /file/update_note/ | title:笔记名称 user_id: 用户id notebook:笔记本名称 new_title:新的标题 new_content: 新的内容 new_tag:新的标签 new_notebook:新的笔记名称
| { "code": 200, "msg": "successful", "data": { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } } | 使用了三元表达式,如果有对应参数即完成对应更新操作。如果对应参数为空则表示不进行改变 返回的data为已经进行更新之后的对应数据。 |
获取指定笔记本霞所有笔记 | /file/get_note_by_notebook/ | notebook:笔记本名称 user_id: 用户id | { "code": 200, "msg": "successful", "data": [ { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content5", "notebook": "notebook3" }, { "user_id": "1", "tag": "tag1", "title": "title5", "content": "content1", "notebook": "notebook1" } ] } |
|
根据关键字查询 | /file/search_keywords/ | keywords: 关键字d user_id:用户id | { "code": 200, "msg": "successful", "data": [ { "user_id": "1", "tag": "tag1", "title": "title1", "notebook": "notebook1" }, { "user_id": "1", "tag": "tag2", "title": "title2", "notebook": "notebook2" } ] } | 关键字类型为str
|
上传图片生成笔记 | /file/img_to_note/ | user_id:用户id img:图片的base64位编码 | { "code": 200, "msg": "successful", "data": [ { "user_id": "1", "tag": "", "title": "title1", "content": "content1", "notebook": "已生成的笔记" }, ] } | 其中tag默认返回为空字串,notebook为固定值 |