Files
vf_react/community_channel_admins.sql
2026-01-06 12:44:35 +08:00

50 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 频道管理员表
-- 在 MySQL 中执行
-- 1. 创建频道管理员表
CREATE TABLE IF NOT EXISTS community_channel_admins (
id INT AUTO_INCREMENT PRIMARY KEY,
channel_id VARCHAR(50) NOT NULL,
user_id INT NOT NULL,
role ENUM('owner', 'admin', 'moderator') NOT NULL DEFAULT 'moderator',
-- owner: 频道创建者,拥有最高权限
-- admin: 频道管理员,可以管理消息和成员
-- moderator: 版主,可以删除消息
permissions JSON,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uk_channel_user (channel_id, user_id),
INDEX idx_channel_id (channel_id),
INDEX idx_user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 2. 权限说明
-- owner 权限(频道创建者):
-- - delete_channel: 删除频道
-- - edit_channel: 编辑频道信息
-- - manage_admins: 管理频道管理员
-- - pin_messages: 置顶消息
-- - delete_messages: 删除任何消息
-- - slow_mode: 设置慢速模式
-- - lock_channel: 锁定频道
-- admin 权限:
-- - edit_channel: 编辑频道信息(部分)
-- - pin_messages: 置顶消息
-- - delete_messages: 删除消息
-- - slow_mode: 设置慢速模式
-- moderator 权限:
-- - pin_messages: 置顶消息
-- - delete_messages: 删除消息
-- 3. 超级管理员说明
-- community_admins 表中 role='admin' 的用户(如 user_id=65
-- 自动拥有所有频道的最高权限,不需要在此表中添加记录
-- 查看频道管理员
-- SELECT cca.*, u.username, c.name as channel_name
-- FROM community_channel_admins cca
-- LEFT JOIN users u ON cca.user_id = u.id
-- LEFT JOIN community_channels c ON cca.channel_id = c.id;