端口说明: 📱 小程序 | 🖥 管理后台 | 📋 规划师端 | ⚙️ 系统自动
flowchart TD
%% ============ 颜色定义 ============
classDef actor fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
classDef action fill:#fff3e0,stroke:#f57c00,stroke-width:1px
classDef system fill:#e8f5e9,stroke:#388e3c,stroke-width:1px
classDef decision fill:#fce4ec,stroke:#d32f2f,stroke-width:1px
classDef role fill:#f3e5f5,stroke:#7b1fa2,stroke-width:1px
classDef endpoint fill:#f5f5f5,stroke:#616161,stroke-width:1px
classDef portMiniApp fill:#e3f2fd,stroke:#1565c0,stroke-width:1px,stroke-dasharray:3 2
classDef portAdmin fill:#fce4ec,stroke:#c62828,stroke-width:1px,stroke-dasharray:3 2
classDef portGuide fill:#fff8e1,stroke:#f57f17,stroke-width:1px,stroke-dasharray:3 2
classDef portSystem fill:#f3e5f5,stroke:#6a1b9a,stroke-width:1px,stroke-dasharray:3 2
subgraph 注册登录
A1(("👤 用户")):::portMiniApp --> A2{📱 已有账号?}:::portMiniApp
A2 -->|否| A3{📱 注册方式}:::portMiniApp
A3 -->|微信授权| A4[📱 微信静默登录 /silent-login]:::portMiniApp
A3 -->|手机号| A5[📱 发送验证码 /send-code]:::portMiniApp
A5 --> A6[📱 手机号验证码登录 /phone-login]:::portMiniApp
A3 -->|手机号+身份证| A7[📱 注册登录 /register-with-idcard]:::portMiniApp
A3 -->|邀请码| A8[📱 邀请码注册 /register-with-invite]:::portMiniApp
A3 -->|直接注册| A9[📱 直接注册 /direct-register]:::portMiniApp
A4 --> A10[⚙️ 系统自动创建账号]:::portSystem
A6 --> A10
A7 --> A10
A8 --> A10
A9 --> A10
A2 -->|是| A11{📱 登录方式}:::portMiniApp
A11 -->|微信| A12[📱 微信code登录 /wechat-login]:::portMiniApp
A11 -->|手机号| A13[📱 手机验证码登录 /phone-login]:::portMiniApp
A11 -->|openid| A14[📱 openid自动登录 /auto-login]:::portMiniApp
A12 --> A15[⚙️ JWT签发]:::portSystem
A13 --> A15
A14 --> A15
A10 --> A15
end
subgraph 认证与安全
A15 --> B1[⚙️ 验证JWT Token /verify]:::portSystem
B1 --> B2{⚙️ Token有效?}:::portSystem
B2 -->|有效| B3[📱 获取用户信息 /info]:::portMiniApp
B2 -->|过期| B4[📱 重新登录]:::portMiniApp
B3 --> B5[📱 设置密码 /set-password]:::portMiniApp
B3 --> B6[📱 验证密码 /verify-password]:::portMiniApp
B3 --> B7[📱 检查手机号 /check-phone]:::portMiniApp
end
subgraph 角色切换
B3 --> C1{📱 当前角色}:::portMiniApp
C1 -->|家长| C2[📱 切换到孩子视图 /switch-role]:::portMiniApp
C1 -->|孩子| C3[📱 切换回家长 /switch-back-to-parent]:::portMiniApp
C1 -->|带密码校验| C4[📱 密码校验切换 /switch-back-verify]:::portMiniApp
C2 --> C5[📱 获取用户角色列表 /roles]:::portMiniApp
C3 --> C5
end
R1(("👤 用户")):::actor
R2(("🔐 JWT认证")):::system
A1 -.- R1
A15 -.- R2
| 端点 | 说明 | 端口 |
|---|---|---|
/api/auth/send-code |
发送短信验证码 | ⚙️系统自动 |
/api/auth/phone-login |
手机号+验证码登录 | 📱小程序 |
/api/auth/wechat-phone-login |
微信手机号登录 | 📱小程序 |
/api/auth/silent-login |
微信静默登录 | 📱小程序 |
/api/auth/auto-login |
openid自动登录 | 📱小程序 |
/api/auth/register-with-idcard |
手机号+身份证注册登录 | 📱小程序 |
/api/auth/wechat-login |
微信code登录 | 📱小程序 |
/api/auth/info |
获取当前用户信息 | 📱小程序 |
/api/auth/set-password |
设置密码 | 📱小程序 |
/api/auth/verify |
验证JWT Token有效性 | ⚙️系统自动 |
/api/auth/verify-password |
验证密码 | 📱小程序 |
/api/auth/check-phone |
检查手机号是否已注册 | 📱小程序 |
/api/auth/direct-register |
直接注册用户 | 📱小程序 |
/api/auth/register-with-invite |
使用邀请码注册 | 📱小程序 |
/api/auth/switch-role |
切换角色 | 📱小程序 |
/api/user/info |
获取用户信息 | 📱小程序 |
/api/user/update |
更新用户信息 | 📱小程序 |
/api/user/children/list |
获取子女列表 | 📱小程序 |
/api/user/family-members |
获取家庭成员列表 | 📱小程序 |
/api/user/action-stats |
获取用户行动统计 | 📱小程序 |