Files
2026-04-26 22:05:21 +08:00

51 lines
2.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.
# smt 戒烟小程序 ThinkPHP 模块说明
本次在 `tp/app/smt` 下新增了一个 ThinkPHP 多应用模块,用于承接原 `wx_service``/api/v1/auth/*``/api/v1/smoke/*` 的主要能力。
## 已迁移范围
- 小程序登录:`POST /smt/v1/auth/login`
- 开发登录:`POST /smt/v1/auth/dev-login`
- 当前用户:`GET /smt/v1/auth/me`
- 更新用户资料:`PUT|POST /smt/v1/auth/profile`
- 戒烟资料:`GET|POST /smt/v1/smoke/profile`
- 抽烟记录:`/smt/v1/smoke/logs*`
- 首页与统计:
- `GET /smt/v1/smoke/home`
- `GET /smt/v1/smoke/stats`
- 下次抽烟建议:
- `GET /smt/v1/smoke/ai/next_smoke_time`
- AI 解锁与每日总结:
- `POST /smt/v1/smoke/ai/advice_unlocks`
- `GET /smt/v1/smoke/ai/daily_summary`
- 分享:
- `POST /smt/v1/smoke/share`
- `GET /smt/v1/smoke/share/:token`
- 戒烟计划:
- `POST /smt/v1/smoke/quit-plan/generate`
- `GET /smt/v1/smoke/quit-plan`
- `GET /smt/v1/smoke/quit-plan/days`
- `POST /smt/v1/smoke/quit-plan/reset`
- 成就:
- `GET /smt/v1/smoke/achievement/themes`
- `GET /smt/v1/smoke/achievement`
## 当前实现说明
- 数据库连接复用 `dbbiz`,直接对接 `users``mini_programs``user_memberships``fa_smoke_*``fa_achievement_*` 等表。
- 鉴权复用了原 Go 服务的语义:`Authorization: Bearer <session_key>`
- AI 能力优先读取环境变量:`AI_BASE_URL``AI_API_KEY``AI_MODEL``AI_TIMEOUT_SECONDS`
- 当 AI 环境变量缺失或调用失败时,已做规则版兜底,保证接口仍然可返回结果。
- 戒烟计划当前为规则生成版本,不再依赖 Go 侧的 AI 计划生成器。
## 未迁移范围
以下能力仍然在 Go 服务里,当前 `tp/app/smt` 未接入:
- `/api/v2/checkin/*` 戒烟打卡系统(quitcheckin
- 梦想目标、监督人、提醒等 v2 业务
- Go 侧的 Redis session 缓存
- Go 侧更细的 AI debug log 与测试体系
如果后续要把 `mini-programs/smt` 完全切到 `tp`,下一步应继续迁移 `wx_service/internal/quitcheckin``tp/app/smt` 或单独的 `tp/app/checkin`