Initial commit
This commit is contained in:
122
developer-front/database/forum_tables.sql
Normal file
122
developer-front/database/forum_tables.sql
Normal file
@@ -0,0 +1,122 @@
|
||||
-- 论坛分类表
|
||||
CREATE TABLE `forum_category` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分类ID',
|
||||
`name` varchar(50) NOT NULL COMMENT '分类名称',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
|
||||
`icon` varchar(100) DEFAULT NULL COMMENT '分类图标',
|
||||
`sort_order` int(11) DEFAULT '0' COMMENT '排序顺序',
|
||||
`status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
|
||||
`post_count` int(11) DEFAULT '0' COMMENT '帖子数量',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_sort_order` (`sort_order`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='论坛分类表';
|
||||
|
||||
-- 论坛帖子表
|
||||
CREATE TABLE `forum_post` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '帖子ID',
|
||||
`category_id` bigint(20) NOT NULL COMMENT '分类ID',
|
||||
`title` varchar(200) NOT NULL COMMENT '标题',
|
||||
`content` text NOT NULL COMMENT '内容',
|
||||
`excerpt` varchar(500) DEFAULT NULL COMMENT '摘要',
|
||||
`author_id` bigint(20) NOT NULL COMMENT '作者ID',
|
||||
`author_name` varchar(50) NOT NULL COMMENT '作者名称',
|
||||
`author_avatar` varchar(255) DEFAULT NULL COMMENT '作者头像',
|
||||
`view_count` int(11) DEFAULT '0' COMMENT '浏览量',
|
||||
`reply_count` int(11) DEFAULT '0' COMMENT '回复数',
|
||||
`like_count` int(11) DEFAULT '0' COMMENT '点赞数',
|
||||
`favorite_count` int(11) DEFAULT '0' COMMENT '收藏数',
|
||||
`is_top` char(1) DEFAULT '0' COMMENT '是否置顶(0否 1是)',
|
||||
`is_hot` char(1) DEFAULT '0' COMMENT '是否热门(0否 1是)',
|
||||
`is_solved` char(1) DEFAULT '0' COMMENT '是否已解决(0否 1是)',
|
||||
`status` char(1) DEFAULT '0' COMMENT '状态(0正常 1删除 2审核中)',
|
||||
`last_reply_id` bigint(20) DEFAULT NULL COMMENT '最后回复ID',
|
||||
`last_reply_user` varchar(50) DEFAULT NULL COMMENT '最后回复用户',
|
||||
`last_reply_time` datetime DEFAULT NULL COMMENT '最后回复时间',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_category_id` (`category_id`),
|
||||
KEY `idx_author_id` (`author_id`),
|
||||
KEY `idx_create_time` (`create_time`),
|
||||
KEY `idx_last_reply_time` (`last_reply_time`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_is_top` (`is_top`),
|
||||
KEY `idx_is_hot` (`is_hot`),
|
||||
KEY `idx_title` (`title`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='论坛帖子表';
|
||||
|
||||
-- 论坛回复表
|
||||
CREATE TABLE `forum_reply` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '回复ID',
|
||||
`post_id` bigint(20) NOT NULL COMMENT '帖子ID',
|
||||
`parent_id` bigint(20) DEFAULT '0' COMMENT '父回复ID(0表示直接回复帖子)',
|
||||
`content` text NOT NULL COMMENT '回复内容',
|
||||
`author_id` bigint(20) NOT NULL COMMENT '作者ID',
|
||||
`author_name` varchar(50) NOT NULL COMMENT '作者名称',
|
||||
`author_avatar` varchar(255) DEFAULT NULL COMMENT '作者头像',
|
||||
`like_count` int(11) DEFAULT '0' COMMENT '点赞数',
|
||||
`status` char(1) DEFAULT '0' COMMENT '状态(0正常 1删除 2审核中)',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_post_id` (`post_id`),
|
||||
KEY `idx_parent_id` (`parent_id`),
|
||||
KEY `idx_author_id` (`author_id`),
|
||||
KEY `idx_create_time` (`create_time`),
|
||||
KEY `idx_status` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='论坛回复表';
|
||||
|
||||
-- 帖子点赞表
|
||||
CREATE TABLE `forum_post_like` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`post_id` bigint(20) NOT NULL COMMENT '帖子ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_post_user` (`post_id`,`user_id`),
|
||||
KEY `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='帖子点赞表';
|
||||
|
||||
-- 帖子收藏表
|
||||
CREATE TABLE `forum_post_favorite` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`post_id` bigint(20) NOT NULL COMMENT '帖子ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_post_user` (`post_id`,`user_id`),
|
||||
KEY `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='帖子收藏表';
|
||||
|
||||
-- 回复点赞表
|
||||
CREATE TABLE `forum_reply_like` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`reply_id` bigint(20) NOT NULL COMMENT '回复ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_reply_user` (`reply_id`,`user_id`),
|
||||
KEY `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='回复点赞表';
|
||||
|
||||
-- 初始化分类数据
|
||||
INSERT INTO `forum_category` (`name`, `description`, `sort_order`, `status`, `create_time`) VALUES
|
||||
('技术讨论', '技术问题讨论和解决方案', 1, '0', NOW()),
|
||||
('SDK使用', 'SDK使用相关问题', 2, '0', NOW()),
|
||||
('API文档', 'API接口使用问题', 3, '0', NOW()),
|
||||
('问题反馈', 'Bug反馈和建议', 4, '0', NOW()),
|
||||
('经验分享', '开发经验和技术分享', 5, '0', NOW()),
|
||||
('新手求助', '新手入门问题', 6, '0', NOW());
|
||||
|
||||
Reference in New Issue
Block a user