Update documentation structure and enhance API descriptions
- Revised README.md to provide a clearer documentation structure for multiple mini programs, including a new table of contents. - Added references to common authentication documentation in both the remove watermark API and README files. - Improved clarity of the login interface description and error handling messages in the remove watermark API documentation.
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
# 戒烟/抽烟记录 API
|
||||
|
||||
所有接口前缀:`/api/v1/smoke`
|
||||
除登录外都需要:`Authorization: Bearer <session_key>`(见:`docs/common/auth.md`)
|
||||
|
||||
## 1) 新增记录
|
||||
|
||||
`POST /api/v1/smoke/logs`
|
||||
|
||||
请求体:
|
||||
|
||||
```json
|
||||
{
|
||||
"smoke_time": "2025-12-31",
|
||||
"remark": "压力大",
|
||||
"level": 2,
|
||||
"num": 3
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
- `smoke_time` 可选;不传则默认“当天”。
|
||||
- `level/num` 可选;不传或传 `<=0` 时会按 `1` 处理。
|
||||
|
||||
curl 示例:
|
||||
|
||||
```bash
|
||||
curl -X POST 'http://127.0.0.1:8080/api/v1/smoke/logs' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer wx-session-key' \
|
||||
-d '{"smoke_time":"2025-12-31","remark":"压力大","level":2,"num":3}'
|
||||
```
|
||||
|
||||
成功响应示例(字段以实际为准):
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"id": 5202,
|
||||
"smoke_time": "2025-12-31T00:00:00+08:00",
|
||||
"remark": "压力大",
|
||||
"createtime": 1735600000,
|
||||
"updatetime": 1735600000,
|
||||
"deletetime": null,
|
||||
"level": 2,
|
||||
"num": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 2) 获取单条记录
|
||||
|
||||
`GET /api/v1/smoke/logs/:id`
|
||||
|
||||
curl 示例:
|
||||
|
||||
```bash
|
||||
curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \
|
||||
-H 'Authorization: Bearer wx-session-key'
|
||||
```
|
||||
|
||||
## 3) 列表查询(分页)
|
||||
|
||||
`GET /api/v1/smoke/logs?page=1&page_size=20&start=2025-12-01&end=2025-12-31`
|
||||
|
||||
参数:
|
||||
- `page`:页码,默认 `1`
|
||||
- `page_size`:每页数量,默认 `20`,最大 `200`
|
||||
- `start/end`:可选,按 `smoke_time` 过滤(格式 `YYYY-MM-DD`)
|
||||
|
||||
成功响应示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"items": [],
|
||||
"total": 0,
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4) 更新记录
|
||||
|
||||
`PUT /api/v1/smoke/logs/:id`
|
||||
|
||||
请求体(字段可选,按需传):
|
||||
|
||||
```json
|
||||
{
|
||||
"smoke_time": "2026-01-01",
|
||||
"remark": "聚会",
|
||||
"level": 3,
|
||||
"num": 1
|
||||
}
|
||||
```
|
||||
|
||||
注意:
|
||||
- 如果你想“清空 smoke_time”,请传空字符串:`{"smoke_time":""}`。
|
||||
- 如果传 `null` 或者不传 `smoke_time`,后端会认为你没有修改该字段。
|
||||
|
||||
## 5) 删除记录(软删除)
|
||||
|
||||
`DELETE /api/v1/smoke/logs/:id`
|
||||
|
||||
成功响应:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"deleted": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# 戒烟/抽烟记录小程序
|
||||
|
||||
本小程序用于记录抽烟情况(日期、原因、烟瘾程度、数量等)。
|
||||
|
||||
## 依赖
|
||||
|
||||
- 公共登录与认证:`docs/common/auth.md`
|
||||
- 通用响应结构:`docs/common/response.md`
|
||||
|
||||
## 数据表
|
||||
|
||||
主表:`fa_smoke_log`(DDL 见:`docs/sql/smoke.sql`)。
|
||||
|
||||
说明:
|
||||
- 该表使用旧系统字段:`createtime/updatetime/deletetime`(秒级时间戳),并非 GORM 默认的 `created_at/updated_at/deleted_at`。
|
||||
- 接口层通过 Token 识别用户,`uid` 由后端从登录用户推导,不允许前端传入。
|
||||
|
||||
Reference in New Issue
Block a user