tiaozhan-exam-2/doc/API (1).md

230 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[toc]
### 请求地址
## https://fe2kao.tiaozhan.com/api/
## 用户模块
### 用户注册 `POST ${base}/user/registry`
#### request
```json
{
"name": "string",
"password": "string"
}
{
"name": "Luthics",
"password": "wenwen"
}
```
#### response
```json
{
"success": true,
"data": {
"name": "string",
"id": "number"
}
}
{
"success": true,
"data": {
"name": "Luthics",
"id": 9
}
}
```
### 用户登陆 `POST ${base}/user`
#### request
```json
{
"name": "string",
"password": "string"
}
```
#### response
```json
{
"success": true,
"data": {
"name": "string",
"id": "number"
}
}
```
### 获取用户登录信息 `GET ${base}/user/state`
#### request
```json
```
#### response
```json
{
"success": true,
"data": {
"id": "number",
"name": "string"
}
}
```
### 用户修改信息 `PUT ${base}/user`
#### request
```json
{
"name": "string",
"password": "string"
}
```
#### response
```json
{
"success": true
}
```
### 用户登出 `DELETE ${base}/user`
#### request
```json
```
#### response
```json
{
"success": true
}
```
## 文章模块
### 获取文章列表 `GET ${base}/passagelist`
**注意这里使用的参数传递方式为query传参而非请求体!**
#### request
```json
{
"type":"string", // 可选"ch"||"en",参数为可选,若传递该参数则获取全部文章列表
"page": "number",
"limit": "number",
}
```
#### response
```json
{
"success": true,
"data": {
"total": "number",//实际符合条件总数
"passages": [
{
"id": "string",
"title": "string"
},
{
...
}
]
}
}
```
### 获取文章内容 `GET ${base}/passage/:id`
**注意这里使用的参数传递方式为params传参而非请求体!**
#### request
```json
{
"id":"number"
}
```
#### response
```json
{
"success":true,
"data": {
"id":"number",
"title":"string",
"content":["string", ...], //按照段落分成数组
"comments":[
{
"id":"number",
"paragraph":"number", //评论的段落
"user":{
"name":"string" //评论者用户名
},
"marked":"string", //标记的文字
"comment":"string", //用户的评论
"createAt":"string", //创建时间
"updatedAt":"string" //修改时间
},
...
]
}
}
```
### 发布一条评论 `POST ${base}/comment`
#### request
```json
{
"passageId":"number",
"paragraph":"number",
"marked":"string",
"comment":"string"
}
```
#### response
```json
{
"success":true,
"data":{
"id":"number"
}
}
```
### 修改一条评论 `PUT ${base}/comment`
#### request
```json
{
"id":"number",
"comment":"string"
}
```
#### response
```json
{
"success":true
}
```
### 删除一条评论 `DELETE ${base}/comment`
**注意这里使用的参数传递方式为params传参而非请求体!**
#### request
```json
{
"id":"number"
}
```
#### response
```json
{
"success":true
}
```
## 错误请求
### 所有类型的错误请求将返回一个包含错误信息的返回体
#### response
```json
{
"success": false,
"error":"string"
}
```