feat(smoke): support reason tags on smoke logs

This commit is contained in:
nepiedg
2026-04-16 11:06:14 +08:00
parent 411ded8a0c
commit 6e0a06cfcf
8 changed files with 158 additions and 65 deletions
+7 -1
View File
@@ -13,6 +13,7 @@
{
"smoke_time": "2025-12-31",
"smoke_at": "2025-12-31 08:30:00",
"reason_tags": ["stress", "social"],
"remark": "压力大",
"level": 2,
"num": 3
@@ -22,6 +23,7 @@
说明:
- `smoke_time` 可选;不传则默认“当天”。
- `smoke_at` 可选;真实抽烟时间(格式 `YYYY-MM-DD HH:MM:SS`)。用于“按时间节点分析/AI 建议”;不传则可用 `createtime` 近似。
- `reason_tags` 可选;结构化原因标签,传 JSON 数组,例如 `["stress","after_meal"]`
- `level/num` 可选;不传时后端会按 `1` 处理。
- `POST /api/v1/smoke/logs` 仅用于“抽烟记录”,`num` 必须 `>0`
- “想抽但忍住了”请使用 `POST /api/v1/smoke/logs/resisted`;系统以 `level=0 且 num=0` 作为“忍住”的判断条件。
@@ -32,7 +34,7 @@ curl 示例:
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","smoke_at":"2025-12-31 08:30:00","remark":"压力大","level":2,"num":3}'
-d '{"smoke_time":"2025-12-31","smoke_at":"2025-12-31 08:30:00","reason_tags":["stress","social"],"remark":"压力大","level":2,"num":3}'
```
成功响应示例(字段以实际为准):
@@ -46,6 +48,7 @@ curl -X POST 'http://127.0.0.1:8080/api/v1/smoke/logs' \
"smoke_time": "2025-12-31T00:00:00+08:00",
"smoke_at": "2025-12-31T08:30:00+08:00",
"remark": "压力大",
"reason_tags": ["stress", "social"],
"createtime": 1735600000,
"updatetime": 1735600000,
"deletetime": null,
@@ -149,6 +152,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \
"smoke_time": "2026-01-05T00:00:00+08:00",
"smoke_at": "2026-01-05T09:12:00+08:00",
"remark": "压力大",
"reason_tags": ["stress"],
"level": 3,
"num": 2,
"createtime": 1736049120
@@ -168,6 +172,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \
{
"smoke_time": "2026-01-01",
"smoke_at": "2026-01-01 21:10:00",
"reason_tags": ["social"],
"remark": "聚会",
"level": 3,
"num": 1
@@ -464,6 +469,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \
{
"smoke_time": "2026-01-05",
"smoke_at": "2026-01-05 10:20:00",
"reason_tags": ["deep_breath", "water"],
"remark": "压力大,想抽但忍住了",
"level": 0,
"num": 0