Appearance
社区论坛插件
插件信息
名称:社区论坛插件(community) 版本:v0.1.0 类型:官方插件 状态:已内置
概述
社区论坛插件为 MengStack 提供完整的社区论坛功能,支持板块管理、帖子发布与审核、回帖互动、精华帖推荐等社区运营能力。所有实体自动继承多租户隔离和软删除。
功能特性
- 板块管理:创建和管理论坛板块,支持排序、图标、封面图配置
- 帖子管理:支持草稿、待审核、已发布、已归档四种状态
- 回帖系统:支持嵌套回复(ReplyTo),回帖可审核
- 精华帖推荐:标记精华帖和置顶帖
- 统计计数:帖子自动统计回帖数、浏览数、点赞数
- 事件驱动:帖子和回帖操作触发领域事件,支持扩展
数据模型
板块(Board)
| 字段 | 类型 | 说明 |
|---|---|---|
id | uuid | 主键(继承自 BaseModel) |
tenant_id | uuid | 租户 ID(继承自 BaseModel) |
name | string | 板块名称 |
slug | string | URL 友好标识(唯一) |
description | string | 板块描述 |
icon | string | 板块图标 |
cover_image | string | 封面图 URL |
sort_order | int | 排序权重(越小越靠前) |
post_count | int | 帖子数量(自动维护) |
is_active | bool | 是否启用 |
created_at | time | 创建时间(继承自 BaseModel) |
updated_at | time | 更新时间(继承自 BaseModel) |
deleted_at | time | 软删除时间(继承自 BaseModel) |
帖子(Post)
| 字段 | 类型 | 说明 |
|---|---|---|
id | uuid | 主键 |
tenant_id | uuid | 租户 ID |
board_id | uuid | 所属板块 ID |
author_id | uuid | 作者用户 ID |
title | string | 帖子标题 |
content | text | 帖子内容 |
summary | string | 摘要 |
status | string | 状态:draft / pending / published / archived |
is_pinned | bool | 是否置顶 |
is_featured | bool | 是否精华 |
view_count | int | 浏览次数 |
reply_count | int | 回帖次数 |
like_count | int | 点赞次数 |
last_reply_at | time | 最后回帖时间 |
created_at | time | 创建时间 |
updated_at | time | 更新时间 |
deleted_at | time | 软删除时间 |
回帖(PostReply)
| 字段 | 类型 | 说明 |
|---|---|---|
id | uuid | 主键 |
tenant_id | uuid | 租户 ID |
post_id | uuid | 所属帖子 ID |
user_id | uuid | 回帖用户 ID |
content | text | 回帖内容 |
reply_to_id | uuid? | 回复目标回帖 ID(嵌套回复) |
like_count | int | 点赞次数 |
is_approved | bool | 是否审核通过 |
created_at | time | 创建时间 |
updated_at | time | 更新时间 |
deleted_at | time | 软删除时间 |
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/list | community.board.read | 获取全部板块列表(含禁用) |
POST | /api/v1/community/boards | community.board.write | 创建板块 |
PUT | /api/v1/community/boards/:id | community.board.write | 更新板块 |
DELETE | /api/v1/community/boards/:id | community.board.write | 删除板块 |
GET | /api/v1/community/posts/list | community.post.read | 获取全部帖子列表(含草稿) |
POST | /api/v1/community/posts | community.post.write | 发布帖子 |
PUT | /api/v1/community/posts/:id | community.post.write | 更新帖子 |
DELETE | /api/v1/community/posts/:id | community.post.write | 删除帖子 |
POST | /api/v1/community/posts/:id/replies | community.post.write | 发布回帖 |
DELETE | /api/v1/community/replies/:id | community.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:多租户隔离

