Skip to content

集合:用户反馈(feedback)

字数
1601 字
阅读时间
8 分钟

1. 目的与使用场景

  • 收集用户对资源使用、功能体验、内容举报等各类反馈,支持产品优化、内容审核、风险监测和用户满意度分析。由反馈入口、举报流程、运营后台使用。

2. Schema 定义

字段类型必填默认值约束/校验说明隐私分级
_idstring-TCB 自动主键P2
_openidstring-TCB 自动用户标识P2
user_id指针id-指向 users._id业务关联用户IDP2
feedback_typestringresource_feedback枚举(resource_feedback,content_report,bug_report,feature_suggestion,complaint,compliment)反馈类型P2
target_typestring-枚举(resource,post,comment,task,feature,content,general)目标类型P2
target_idstring--目标对象IDP2
categorystring-枚举(quality,accessibility,content,functionality,service,other)分类P1
titlestring-长度 ≤ 60反馈标题P1
contentstring-长度 10-1000详细描述P3
severitystringlow枚举(low,medium,high,critical)严重程度P2
attachmentsarray[]元素为 object {type,url,metadata}附件P3
contact_preferencestringnone枚令(none,in_app,email,phone)回复方式P2
contact_infostring-长度 ≤ 100联系信息P3
is_anonymousboolfalse-匿名反馈P2
statusstringpending枚举(pending,reviewing,resolved,rejected,escalated,closed)处理状态P1
assignee_idstring--处理人IDP2
assignee_rolestring-枚举(moderator,counselor,ops,dev)处理人角色P1
response_contentstring-长度 ≤ 2000回复内容P2
response_atdate-ISO 字符串回复时间P1
resolution_actionobject-{action_type,action_details}解决方案P2
tagsarray[]元素为 string内部标签P1
prioritynumber501-100处理优先级P1
metadataobject-{source,platform,version,network}元数据P1
created_ipstring--创建IP(脱敏)P3
created_locationobject-{country,region,city}创建位置P3
createdAtdate-服务端时间创建时间P1
updatedAtdate-服务端时间更新时间P1
resolved_atdate-ISO 字符串解决时间P1

3. 索引与唯一约束

  • 单字段索引:_openiduser_idfeedback_typestatustarget_typeseverity
  • 复合索引:[feedback_type, status, createdAt desc][target_type, target_id, status][assignee_id, status]
  • 全文索引:titlecontent(支持搜索)
  • 设计理由:按类型和状态分拣反馈;目标对象关联查询;处理人工作量统计。

4. 访问控制(TCB 权限)

json
{
  "read": "_openid == auth.openid || auth.role in ['moderator','ops','counselor']",
  "write": "_openid == auth.openid || auth.role in ['feedback_service','moderator','ops']"
}

用户可提交和查看自身反馈;审核员可查看和分配反馈。

5. 关系与级联

  • user_idusers
  • target_id → 关联集合(resources、posts、comments等)
  • assignee_id → users(处理人)
  • 删除策略:用户注销时匿名化处理;保留关键反馈用于分析。
  • 反范式:resolution_action 内嵌解决方案详情;metadata 存储客户端信息。

6. 数据生命周期与合规

  • 留存:一般反馈保留1年;举报记录保留3年;解决方案保留用于知识库。
  • 匿名化:匿名反馈移除用户标识;导出时脱敏IP和位置信息。
  • 用户导出:提供用户自身的反馈记录。
  • 审计字段:createdAtupdatedAtassignee_idstatus变更日志。

7. API/云函数契约映射

| 接口/函数 | 读/写 | 使用字段 | 过滤条件 | 排序/分页 | 备注 | | /api/feedback POST | 写 | feedback_type, target_type, target_id, content, is_anonymous | - | - | 提交反馈 | | /api/feedback/:id GET | 读 | 所有字段 | _id, (user_id == auth.uid || auth.role) | - | 查看反馈详情 | | 运营后台 manageFeedback | 写 | status, assignee_id, response_content, resolution_action | _id | - | 处理反馈 | | 自动分配 autoAssignFeedback | 写 | assignee_id, status, priority | status='pending' | - | 智能分配 | | 风险监测 checkRiskFeedback | 读 | content, severity, target_type | severity in ['high','critical'] | - | 风险识别 | | 统计分析 feedbackAnalytics | 读 | feedback_type, status, resolution_action | 时间范围 | - | 趋势分析 |

8. 示例文档(≥3条)

json
{
  "_id": "fb_res_001",
  "user_id": "usr_001",
  "feedback_type": "resource_feedback",
  "target_type": "resource",
  "target_id": "res_campus_counseling_001",
  "category": "service",
  "title": "心理中心预约体验很好",
  "content": "预约流程很顺畅,老师很专业,建议增加线上咨询选项。",
  "severity": "low",
  "contact_preference": "in_app",
  "is_anonymous": false,
  "status": "resolved",
  "assignee_id": "ops_zhang",
  "assignee_role": "ops",
  "response_content": "感谢您的反馈!我们已经收到您对心理中心的积极评价,正在研究增加线上咨询的可行性。",
  "response_at": "2024-04-07T10:30:00Z",
  "resolution_action": {
    "action_type": "forward_to_service",
    "action_details": "转发给心理中心服务优化团队"
  },
  "tags": ["positive", "service_improvement"],
  "priority": 30,
  "metadata": {
    "source": "resource_map",
    "platform": "miniapp",
    "version": "1.3.0"
  },
  "createdAt": "2024-04-06T15:20:00Z",
  "updatedAt": "2024-04-07T10:30:00Z",
  "resolved_at": "2024-04-07T10:30:00Z"
}
{
  "_id": "fb_post_001",
  "_openid": "oAbcd456",
  "user_id": "usr_002",
  "feedback_type": "content_report",
  "target_type": "post",
  "target_id": "post_900",
  "category": "content",
  "title": "举报不当内容",
  "content": "该帖子包含可能引发不当行为的内容,建议审核处理。",
  "severity": "high",
  "is_anonymous": true,
  "status": "reviewing",
  "assignee_id": "moderator_li",
  "assignee_role": "moderator",
  "priority": 80,
  "metadata": {
    "source": "post_detail",
    "platform": "miniapp"
  },
  "createdAt": "2024-04-06T16:45:00Z",
  "updatedAt": "2024-04-06T17:00:00Z"
}
{
  "_id": "fb_bug_001",
  "user_id": "usr_002",
  "feedback_type": "bug_report",
  "target_type": "feature",
  "category": "functionality",
  "title": "情绪打卡页面卡顿",
  "content": "在提交情绪打卡时,页面经常卡顿无法提交,重试几次才能成功。使用的是iPhone 13,iOS 17.3.1。",
  "severity": "medium",
  "attachments": [
    {
      "type": "screenshot",
      "url": "cos://feedback/bug_001_screenshot.png",
      "metadata": {"width": 390, "height": 844}
    }
  ],
  "contact_preference": "email",
  "contact_info": "student@example.com",
  "status": "pending",
  "tags": ["performance", "ios"],
  "priority": 60,
  "metadata": {
    "source": "today_page",
    "platform": "miniapp",
    "version": "1.3.0",
    "network": "wifi"
  },
  "createdAt": "2024-04-07T09:15:00Z",
  "updatedAt": "2024-04-07T09:15:00Z"
}

9. 常用查询样例(≥3条)

javascript
// 获取用户的反馈历史
const userFeedback = await db.collection('feedback').where({
  _openid: auth.openid
}).orderBy('createdAt', 'desc').get();

// 查看待处理的举报
const pendingReports = await db.collection('feedback').where({
  feedback_type: 'content_report',
  status: 'pending'
}).orderBy('severity', 'desc').get();

// 统计资源反馈满意度
const positiveFeedback = await db.collection('feedback').where({
  feedback_type: 'resource_feedback',
  tags: db.command.in(['positive', 'compliment']),
  createdAt: db.command.gte(new Date(Date.now() - 30 * 86400000).toISOString())
}).count();

10. 边界与错误码

  • 重复提交:相同用户在短时间内对同一目标重复反馈返回 E_FEEDBACK_DUPLICATE
  • 内容违规:反馈内容包含不当信息返回 E_FEEDBACK_CONTENT_VIOLATION
  • 越权访问:非本人或授权角色查看反馈返回 E_FORBIDDEN

11. 变更影响评估

  • 新增反馈类型需同步前端表单、后台处理流程、统计分析报表。
  • 处理流程变更需更新相关人员的权限和工作流配置。
  • 字段调整影响反馈搜索和筛选功能。

12. 假设与待确认

  • 假设匿名反馈通过 _openid 标识,完全匿名则不存储用户信息;待确认是否需要支持完全匿名模式。
  • 待确认是否需要与工单系统集成,实现更复杂的处理流程。
  • 待确认反馈是否需要关联到具体的会话或操作记录。

贡献者

The avatar of contributor named as Cai Hongyu Cai Hongyu

文件历史

撰写