Skip to content

社区论坛插件 ​

插件信息

名称:社区论坛插件(community) 版本:v0.1.0 类型:官方插件 状态:已内置

概述 ​

社区论坛插件为 MengStack 提供完整的社区论坛功能,支持板块管理、帖子发布与审核、回帖互动、精华帖推荐等社区运营能力。所有实体自动继承多租户隔离和软删除。

功能特性 ​

  • 板块管理:创建和管理论坛板块,支持排序、图标、封面图配置
  • 帖子管理:支持草稿、待审核、已发布、已归档四种状态
  • 回帖系统:支持嵌套回复(ReplyTo),回帖可审核
  • 精华帖推荐:标记精华帖和置顶帖
  • 统计计数:帖子自动统计回帖数、浏览数、点赞数
  • 事件驱动:帖子和回帖操作触发领域事件,支持扩展

数据模型 ​

板块(Board) ​

字段类型说明
iduuid主键(继承自 BaseModel)
tenant_iduuid租户 ID(继承自 BaseModel)
namestring板块名称
slugstringURL 友好标识(唯一)
descriptionstring板块描述
iconstring板块图标
cover_imagestring封面图 URL
sort_orderint排序权重(越小越靠前)
post_countint帖子数量(自动维护)
is_activebool是否启用
created_attime创建时间(继承自 BaseModel)
updated_attime更新时间(继承自 BaseModel)
deleted_attime软删除时间(继承自 BaseModel)

帖子(Post) ​

字段类型说明
iduuid主键
tenant_iduuid租户 ID
board_iduuid所属板块 ID
author_iduuid作者用户 ID
titlestring帖子标题
contenttext帖子内容
summarystring摘要
statusstring状态:draft / pending / published / archived
is_pinnedbool是否置顶
is_featuredbool是否精华
view_countint浏览次数
reply_countint回帖次数
like_countint点赞次数
last_reply_attime最后回帖时间
created_attime创建时间
updated_attime更新时间
deleted_attime软删除时间

回帖(PostReply) ​

字段类型说明
iduuid主键
tenant_iduuid租户 ID
post_iduuid所属帖子 ID
user_iduuid回帖用户 ID
contenttext回帖内容
reply_to_iduuid?回复目标回帖 ID(嵌套回复)
like_countint点赞次数
is_approvedbool是否审核通过
created_attime创建时间
updated_attime更新时间
deleted_attime软删除时间

API 接口 ​

公开接口 ​

方法路径说明
GET/api/v1/community/boards获取活跃板块列表
GET/api/v1/community/boards/:id获取板块详情
GET/api/v1/community/boards/:id/posts获取板块下的帖子列表
GET/api/v1/community/posts获取已发布帖子列表
GET/api/v1/community/posts/featured获取精华帖列表
GET/api/v1/community/posts/:id获取帖子详情
POST/api/v1/community/posts/:id/view增加浏览次数
GET/api/v1/community/posts/:id/replies获取帖子的回帖列表(分页)

需认证接口 ​

方法路径权限说明
GET/api/v1/community/boards/listcommunity.board.read获取全部板块列表(含禁用)
POST/api/v1/community/boardscommunity.board.write创建板块
PUT/api/v1/community/boards/:idcommunity.board.write更新板块
DELETE/api/v1/community/boards/:idcommunity.board.write删除板块
GET/api/v1/community/posts/listcommunity.post.read获取全部帖子列表(含草稿)
POST/api/v1/community/postscommunity.post.write发布帖子
PUT/api/v1/community/posts/:idcommunity.post.write更新帖子
DELETE/api/v1/community/posts/:idcommunity.post.write删除帖子
POST/api/v1/community/posts/:id/repliescommunity.post.write发布回帖
DELETE/api/v1/community/replies/:idcommunity.post.write删除回帖

事件 ​

事件名触发时机
post.created帖子创建时
post.published帖子发布时
reply.created回帖创建时

数据库表 ​

表名说明
community_boards板块表
community_posts帖子表
community_post_replies回帖表

权限 ​

权限标识说明
community.board.write管理板块(创建、编辑、删除)
community.post.write管理帖子(发布、编辑、删除、回帖)
community.post.moderate审核帖子

依赖 ​

  • auth:用户认证和权限校验
  • rbac:权限模型
  • org:多租户隔离

Released under the Apache 2.0 License.