功能→接口→集合字段映射表
字数
2398 字
阅读时间
11 分钟
概述
本映射表展示了 MindGuard 小程序的核心功能模块如何通过 API 接口操作数据库集合字段的完整链路。基于功能文档、接口占位文档、埋点文档和数据库设计文档分析整理。
1. 情绪健康闭环
1.1 情绪打卡功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 情绪打卡 | /api/moods/today | GET | checkins | mood_score, primary_emotion, mood_tags, scene_tags, context_note, checkin_date, mood_wheel_snapshot | 获取今日打卡状态 |
| 情绪打卡 | /api/checkins | POST | checkins | mood_score, primary_emotion, mood_tags, scene_tags, context_note, input_type, energy_level | 提交情绪打卡 |
| 情绪趋势 | /api/moods/trend | GET | checkins | mood_score, checkin_date, mood_tags | 获取情绪趋势数据 |
| 情绪打卡 | 云函数 checkinRecorder | CALL | checkins | 所有字段 + suggestion_ids | 打卡记录与风控处理 |
埋点事件:
mood_checkin_submit→checkins.mood_score,checkins.primary_emotion,checkins.mood_tags,checkins.input_type
1.2 微建议生成功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 微建议列表 | /api/micro-tips | GET | suggestions | title, category, priority_rank, status, source | 获取Top3建议 |
| 建议状态更新 | /api/micro-tips/{id} | PATCH | suggestions | status, accepted_task_id | 接受/跳过建议 |
| 建议生成 | 云函数 suggestionOrchestrator | CALL | suggestions | 所有字段 + feature_snapshot | AI生成建议 |
| 任务生成 | /api/tasks | POST | tasks | title, description, source, origin_reference_type, origin_reference_id, category | 一键生成任务 |
埋点事件:
suggestion_task_create→suggestions._id,tasks._id,suggestions.categoryexp_today_suggestions→suggestions.status(曝光统计)
1.3 任务管理功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 任务列表 | /api/tasks | GET | tasks | title, status, due_at, category, priority, source | 获取任务列表 |
| 任务创建 | /api/tasks | POST | tasks | 所有字段除系统生成字段 | 创建新任务 |
| 任务更新 | /api/tasks/{id} | PATCH | tasks | status, checklist_steps, linked_checkin_id | 更新任务状态 |
| 任务复盘 | /api/tasks/review | POST | tasks | review_data, linked_checkin_id | 提交复盘 |
| 任务统计 | /api/tasks/summary | GET | tasks | status, adherence_score, source | 获取任务统计 |
| 任务闭环 | 云函数 taskWorkflow | CALL | tasks + checkins | tasks.status + checkins.mood_score | 任务自动闭环 |
埋点事件:
task_status_update→tasks.status,tasks.task_status_logstask_review_submit→tasks.review_datatask_create_manual→tasks.source,tasks.category
2. 心情随笔功能
2.1 随笔记录功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 随笔列表 | /api/journals | GET | journals | title, entry_type, mood_score, share_scope, createdAt | 获取随笔列表 |
| 随笔创建 | /api/journals | POST | journals | 所有字段除系统生成字段 | 创建随笔 |
| 随笔详情 | /api/journals/{id} | GET | journals | 所有字段 | 获取随笔详情 |
| 随笔更新 | /api/journals/{id} | PATCH | journals | title, body_text, mood_score, share_scope | 更新随笔 |
| REBT提取 | /api/journals/{id}/extract-rebt | POST | journals | rebt_struct | 提取REBT结构 |
| 建议生成 | /api/journals/{id}/generate-suggestion | POST | suggestions | title, description, category | 基于随笔生成建议 |
埋点事件:
journal_entry_submit→journals.entry_type,journals.word_count,journals.mood_scorejournal_to_task→journals._id,tasks._id
2.2 多模态处理
| 功能模块 | 处理方式 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|
| 语音转写 | 云函数语音识别 | journals | body_text, audio_duration, media_refs | 语音转文本处理 |
| 图片OCR | 云函数OCR服务 | journals | ocr_text, media_refs | 图片文字提取 |
| AI摘要 | 云函数AI服务 | journals | derived_summary, word_count | 自动生成摘要 |
| 风险检测 | 云函数风控服务 | journals | risk_level, mood_score | 情绪风险评估 |
3. 社区守护系统
3.1 树洞发帖功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 帖子列表 | /api/treehole/posts | GET | posts | title, content, topic, status, risk_level | 获取帖子列表 |
| 帖子创建 | /api/treehole/posts | POST | posts | 所有字段除系统生成字段 | 发布帖子 |
| 帖子详情 | /api/treehole/posts/{id} | GET | posts | 所有字段 | 获取帖子详情 |
| 话题列表 | /api/treehole/topics | GET | posts | topic, status | 获取话题分类 |
| 内容审核 | 云函数 treeholeModeration | CALL | posts | status, risk_level, moderation_result | 自动内容审核 |
| 风险升级 | 云函数 riskSignalEscalate | CALL | posts + sos_events | posts.risk_level + sos_events.risk_level | 风险事件升级 |
埋点事件:
treehole_post_publish→posts._id,posts.risk_score,posts.anonymity_modeexp_risk_banner→posts.risk_levelact_risk_action→posts.risk_level, 风险操作类型
3.2 社区互动功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 互动操作 | /api/treehole/interactions | POST | comments | post_id, action_type, is_add | 抱抱/收藏 |
| 评论列表 | /api/treehole/posts/{id}/comments | GET | comments | content, is_anonymous, status | 获取评论 |
| 评论提交 | /api/treehole/interactions | POST | comments | 所有字段 | 提交评论 |
| 行动卡同步 | 云函数 syncActionCardTask | CALL | posts + tasks | posts.action_card_id + tasks._id | 生成行动卡任务 |
埋点事件:
treehole_care_action→comments.action_type,comments.is_addact_comment_submit→comments.content,comments.is_anonymous
4. 成长激励体系
4.1 徽章系统
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 徽章列表 | /api/badges | GET | badges | badge_code, status, progress_value, unlocked_at | 获取徽章列表 |
| 徽章进度更新 | 云函数 badgeService | CALL | badges | status, progress_value, progress_detail | 更新徽章进度 |
| 徽章解锁 | 云函数 badgeService | CALL | badges | status, unlocked_at | 解锁徽章 |
埋点事件:
badge_unlock→badges.badge_code,badges.unlock_criteria
4.2 周报系统
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 周报获取 | /api/reports/weekly | GET | reports | content, period_label, status | 获取周报 |
| 周报生成 | 云函数 weeklyReport | CALL | reports + 多个集合 | 聚合数据生成周报 | 自动生成周报 |
| 周报导出 | /api/reports/export | POST | reports | file_url, expires_at | 导出周报PDF |
数据聚合来源:
checkins: 情绪数据趋势tasks: 任务完成率journals: 随笔频率badges: 徽章解锁情况
埋点事件:
weekly_report_view→reports._id,reports.meta.view_channel
5. 安全保障机制
5.1 SOS紧急求助
| 功能模块 | 接口/云函数 | 方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| SOS触发 | 云函数 sosRelay | CALL | sos_events | 所有字段 | 记录SOS事件 |
| 风险监控 | 云函数 riskMonitor | CALL | checkins + posts + journals | 风险字段聚合 | 实时风险监控 |
| 值班响应 | 云函数 sosRelay | CALL | sos_events | handler_id, response_time, status | 分配处理人员 |
埋点事件:
sos_fab_trigger→sos_events.trigger,sos_events.risk_levelrisk_signal_escalate→sos_events.severity_level,sos_events.handler_role
5.2 资源导航
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 资源列表 | /api/resources | GET | resources | name, category, contact_info, available_hours | 获取资源列表 |
| 资源联系 | /api/resources/contact | POST | resources + feedback | resources._id + feedback.content | 记录联系反馈 |
埋点事件:
resource_map_click→resources._id,resources.categoryresource_contact→resources._id, 联系方式
6. AI对话系统
6.1 对话管理功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 对话会话列表 | /api/ask/sessions | GET | ask_sessions | session_type, trigger_source, session_summary, createdAt, satisfaction_score | 获取用户对话历史 |
| 创建对话会话 | /api/ask/sessions | POST | ask_sessions | session_type, trigger_source, initial_risk_level, cbt_focus | 启动新的AI对话 |
| 更新会话状态 | /api/ask/sessions/{id} | PATCH | ask_sessions | final_risk_level, session_summary, satisfaction_score, follow_up_needed | 更新对话结果 |
| Dify对话服务 | 云函数 difyChatService | CALL | ask_sessions + ask_messages | 会话信息 + 消息内容 | 处理AI对话逻辑 |
| 风险监控 | 云函数 askRiskMonitor | CALL | ask_sessions | initial_risk_level, final_risk_level, intervention_triggered | 实时风险监控 |
埋点事件:
ask_session_start→ask_sessions.session_type,ask_sessions.trigger_source,ask_sessions.initial_risk_levelask_session_end→ask_sessions.satisfaction_score,ask_sessions.duration_seconds,ask_sessions.intervention_triggered
6.2 CBT应用功能
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| CBT应用列表 | /api/cbt/applications | GET | cbt_applications | technique_type, application_context, completion_status, effectiveness_rating | 获取CBT应用记录 |
| 创建CBT应用 | /api/cbt/applications | POST | cbt_applications | technique_type, application_context, target_issue, intervention_plan | 记录新的CBT技巧应用 |
| 更新CBT进度 | /api/cbt/applications/{id} | PATCH | cbt_applications | completion_status, effectiveness_rating, implementation_notes | 更新CBT应用进度 |
| 个性化推荐 | 云函数 cbtRecommendationEngine | CALL | cbt_applications + ask_sessions | 技巧效果 + 会话内容 | CBT技巧个性化推荐 |
| 效果分析 | 云函数 cbtEffectivenessAnalytics | CALL | cbt_applications | technique_type, effectiveness_rating, skill_mastery_level | CBT应用效果分析 |
埋点事件:
cbt_application_start→cbt_applications.technique_type,cbt_applications.application_context,cbt_applications.difficulty_levelcbt_technique_complete→cbt_applications.effectiveness_rating,cbt_applications.skill_mastery_level,cbt_applications.duration_minutes
7. 数据分析系统
7.1 埋点收集
| 功能模块 | 云函数 | 输入 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 埋点聚合 | analyticsIngest | 埋点事件 | events | 所有字段 | 事件数据聚合 |
| 用户画像 | 数据分析任务 | events + 多个集合 | 用户特征字段 | 生成用户画像 | |
| 行为分析 | 数据分析任务 | events | 行为相关字段 | 用户行为分析 |
7.3 通知系统
| 功能模块 | 接口 | HTTP方法 | 集合 | 字段映射 | 说明 |
|---|---|---|---|---|---|
| 通知列表 | /api/notifications | GET | notifications | title, content, status, send_at | 获取通知列表 |
| 未读数量 | /api/notifications/unread-count | GET | notifications | status, message_type | 获取未读数量 |
| 通知发送 | 云函数 notificationService | CALL | notifications | 所有字段 | 发送推送通知 |
关键映射关系总结
核心数据流向
- 情绪数据流:
checkins→suggestions→tasks→reports - 内容数据流:
journals→suggestions/tasks→posts→comments - 行为数据流: 用户操作 →
events→ 数据分析 → 产品优化 - 风险数据流:
checkins+posts+journals→ 风险评估 →sos_events
主要集合依赖关系
- users: 核心用户信息,被所有集合引用
- checkins: 情绪数据,驱动建议生成和周报
- tasks: 任务数据,连接建议和实际行为
- posts: 社区内容,触发互动和行动卡
- events: 行为数据,支撑分析和优化
权限控制模式
- P0级: 公开信息,所有用户可访问
- P1级: 基础信息,本人可访问
- P2级: 敏感信息,需要授权访问
- P3级: 高敏信息,严格权限控制
文档版本: v1.0.0 最后更新: 2025-09-22 对齐文档: 功能文档、接口占位文档、埋点与数据分析、数据库设计