EVA-Tea/doc/api.md

261 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 接口文档
## 基本格式
### 成功响应格式
```json
{
"success": true,
"data": {
"foo": "bar"
}
}
```
**NOTE:** 若无特殊说明,`POST`请求的响应`data`字段为空(`{}`),可以不用管。
### 失败响应格式
```json
{
"success": false,
"err": "some error"
}
```
### `GET`请求默认格式(若无特殊说明)
```json
{
"token": "token_test"
}
```
## 主页面
### 统计数据 `GET /admin/stats`
data:
```json
{
"success": true,
"data": {
"notInOreo": 114,
"total": 514
}
}
```
### 当前值班信息 `GET /admin/duty/current`
data:
```json
{
"isInDuty": true,
"currentDuty": "2",
"inDutyCnt": 3,
"otherDutyTime": "",
"offDutyReason": "",
"place": "204",
"dutyRecoverTime": ""
}
```
## 主席团页面
### 值班表管理
#### 更新值班表 `POST /admin/sheet/create`
request:
```json
{
"name": "2024 春学期值班表",
"sheet": [
{
"weekday": 1,
"shift": 1,
"workers": ["马嘉祺", "丁程鑫", "宋亚轩"],
"leader": "蔡徐坤"
},
{
"weekday": 1,
"shift": 2,
"workers": ["王俊凯", "易烊千玺", "王源"],
"leader": "丁真珍珠"
}
// ...
]
}
```
#### 更新值班表 `POST /admin/sheet/update`
request:
```json
{
"id": 114514,
"name": "2024 春学期值班表",
"sheet": [
{
"weekday": 1,
"shift": 1,
"workers": ["马嘉祺", "丁程鑫", "宋亚轩"],
"leader": "蔡徐坤"
},
{
"weekday": 1,
"shift": 2,
"workers": ["王俊凯", "易烊千玺", "王源"],
"leader": "丁真珍珠"
}
// ...
]
}
```
#### 获取当前值班表 `GET /admin/sheet/current`
data:
```json
{
"name": "2024 春学期值班表",
"id": 114514,
"createdTime": "2024-03-07T19:52:48.523303",
"sheet": [
{
"weekday": 1,
"shift": 1,
"workers": ["马嘉祺", "丁程鑫", "宋亚轩"],
"leader": "蔡徐坤"
},
{
"weekday": 1,
"shift": 2,
"workers": ["王俊凯", "易烊千玺", "王源"],
"leader": "丁真珍珠"
}
// ...
]
}
```
#### 获取所有值班表 `GET /admin/sheet/list`
data:
```json
{
"current": 114514,
"list": [
{
"name": "2024 春学期值班表",
"id": 114514,
"createdTime": "2024-03-07T19:52:48.523303",
"sheet": [
{
"weekday": 1,
"shift": 1,
"workers": ["马嘉祺", "丁程鑫", "宋亚轩"],
"leader": "蔡徐坤"
},
{
"weekday": 1,
"shift": 2,
"workers": ["王俊凯", "易烊千玺", "王源"],
"leader": "丁真珍珠"
}
// ...
]
}
// ...
]
}
```
### 特殊值班
#### 获取当前值班情况 `GET /admin/duty/current`
data:
```json
{
"isInDuty": true,
"currentDuty": "2",
"inDutyCnt": 3,
"otherDutyTime": "",
"offDutyReason": "",
"place": "",
"dutyRecoverTime": "",
},
```
#### 更新当前值班情况 `POST /admin/duty/update`
无关项返回空字符串,后端手动校验
request:
```json
{
"isInDuty": true,
"currentDuty": "2",
"inDutyCnt": 3,
"otherDutyTime": "",
"offDutyReason": "",
"place": "204",
"dutyRecoverTime": "",
},
```
## 日志页面
### 获取日志列表 `GET /admin/loglist`
request:
```json
{
"pageIndex": 1,
"size": 10,
}
```
data:
```json
{
"page": 1,
"total": 24,
"success": true,
"data": [
{
"op": "宇航员",
"avatar": "https://...",
"time": "2024-03-07T19:52:48.523303",
"operation": 2,
"target": 1,
"prev": {
"id": 114,
"info": "马嘉祺"
},
"curr": {
"id": 514,
"info": "何君琳"
}
},
// ...
]
}
```
前端显示的信息:"{op} 于 {time} {operation} 了 {target}{prev.info} -> {curr.info}"