时间:2021-07-01 10:21:17 帮助过:25人阅读
场景列表:
// A 发布 了 文章 xxx
‘action‘ => NEW,
‘user_id‘ => A的ID,
‘object_id‘ => 文章ID,
‘object_user‘ => A的ID,
‘object_type‘ => ARTICLE,
‘ext‘ => [],
// A 发布 了 N张 图片
‘action‘ => NEW,
‘user_id‘ => A的ID,
‘object_id‘ => 图片ID(数组,以逗号隔开),
‘object_user‘ => A的ID,
‘object_type‘ => PICTURE,
‘ext‘ => [],
// 4. A 提了 问题 xxxx
‘action‘ => NEW,
‘user_id‘ => A的ID,
‘object_id‘ => 问题ID,
‘object_user‘ => A的ID,
‘object_type‘ => QUESTION,
‘ext‘ => [],
// 5. A 在 文章 中回复了 B 的 评论
‘action‘ => REPLY,
‘user_id‘ => A的ID,
‘object_id‘ => 评论ID,
‘object_user‘ => B的ID,
‘object_type‘ => COMMENT,
‘ext‘ => [
‘text‘ => $text,
‘comment_target_id‘ => ‘文章ID‘, //评论所属对象
‘comment_target_type‘ => ‘ARTICLE‘,//评论所属对象类型
‘reply_id‘ => 回复ID,
],
// 6. A 评论 了 B的 文章 xxxx
‘action‘ => COMMENT,
‘user_id‘ => A的ID,
‘object_id‘ => 文章ID,
‘object_user‘ => B的ID,
‘object_type‘ => ‘ARTICLE‘,
‘ext‘ => [
‘comment_id‘ => ‘评论ID‘,
],
// 7. A 回答 了 B 的 提问 xxx
‘action‘ => RESPOND,
‘user_id‘ => A的ID,
‘object_id‘ => 问题ID,
‘object_user‘ => B的ID,
‘object_type‘ => QUESTION,
‘ext‘ => [
‘answer_id‘ => ‘答案ID‘,
],
最终我参考开源中国做了调整,以完成我们的需求:
动态的结构:
{
user_id:13,
action: 行为,
object_id: 对象ID,
object_type: 对象类型,
object_user_id: 对象用户ID,
parent_object_id: 对象父级ID,
parent_object_type: 对象父级类型,
parent_object_user_id: 对象父级用户ID,
reply_id: 回复ID, // action为回复时有用
parent_reply_id: 回复的父级回复ID, // action为回复时有用,回复了别人对评论的回复
text: ‘转发或者分享时附加文字‘,
view_count: 0,
created_at: 创建时间,
deleted_at: 删除时间,
}
说明:
1. object_*
只存储主要模块内容信息,不含评论;
2. parent_object_*
存储有嵌套关系的对象,比如当object_*
为答案时,parent_object_*
为问题;
3. reply_id
用于直接回复评论时用到;
4. parent_reply_id
父回复ID;
5. 两个回复ID,使用情况是:当回复了别人的回复时,根据comment_id
拉取评论与全部回复,在模板显示时只显示对话的两个回复。
场景列表:
一级结构:
‘action‘ => NEW,
‘user_id‘ => 安正超ID,
‘object_id‘ => 文章ID,
‘object_user_id‘ => 安正超ID,
‘object_type‘ => ARTICLE,
‘action‘ => NEW,
‘user_id‘ => 安正超ID,
‘object_id‘ => 图片ID(数组,以逗号隔开),
‘object_user_id‘ => 安正超ID,
‘object_type‘ => PICTURE,
‘action‘ => NEW,
‘user_id‘ => 安正超ID,
‘object_id‘ => 问题ID,
‘object_user_id‘ => 安正超ID,
‘object_type‘ => QUESTION
二级结构:
展示:
文章: xxxxx
评论:xxxxx (李林评论的)
‘action‘ => COMMENT,
‘user_id‘ => 安正超ID,
‘object_id‘ => 评论ID,
‘object_type‘ => COMMENT,
‘object_user_id‘ => 安正超ID
‘parent_object_id‘ => 文章ID,
‘parent_object_user_id‘ => 作者ID
‘parent_object_type‘ => ARTICLE,
三级结构:
展示:
文章: xxxxx
评论:xxxxx (李林评论的)
回复:xxxx (安正超)
‘action‘ => REPLY,
‘user_id‘ => 安正超ID,
‘object_id‘ => 评论ID,
‘object_type‘ => COMMENT,
‘object_user_id‘ => 李林ID
‘parent_object_id‘ => 文章ID,
‘parent_object_user_id‘ => 作者ID
‘parent_object_type‘ => ARTICLE,
‘reply_id‘ => 安正超的回复ID
四级结构:
说明:问题信息从答案接口取回
展示:
问题: xxxxx
答案1...
答案2...
答案3...(李林回答的)
评论:xxxxx (李文凯评论的)
回复:xxxx (安正超)
‘action‘ => RESPOND,
‘user_id‘ => 安正超ID,
‘object_id‘ => 评论ID,
‘object_type‘ => COMMENT,
‘object_user_id‘ => 李文凯的ID
‘parent_object_id‘ => 答案ID,
‘parent_object_type‘ => ANSWER,
‘parent_object_user_id‘ => 李林ID
‘reply_id‘ => 安正超的回复ID
说明:问题信息从答案接口取回
展示:
问题: xxxxx
答案1...
答案2...
答案3...(李林回答的)
评论:xxxxx (A评论的)
李文凯 回复 A:xxxx
安正超 回复 李文凯:xxxx
‘action‘ => RESPOND,
‘user_id‘ => 安正超ID,
‘object_id‘ => 评论ID,
‘object_type‘ => COMMENT,
‘object_user_id‘ => A的ID
‘parent_object_id‘ => 答案ID,
‘parent_object_type‘ => QUESTION,
‘parent_object_user_id‘ => 李林ID,
// 以下两个回复只在模板中用到用以决定显示哪两个回复,因为根据comment_id带着回复会全部拉回来
‘parent_reply_id‘ => 李文凯的回复ID,
‘reply_id‘ => 安正超的回复ID,
评论在数据库中存储!!
标签: