-- ============================================ -- 缘池与许愿树数据库表 -- 版本: V2.0 -- 日期: 2025-12-30 -- ============================================ -- ============================================ -- 一、缘池相关表 -- ============================================ -- 1. 板块表 CREATE TABLE IF NOT EXISTS `eb_community_category` ( `id` int NOT NULL AUTO_INCREMENT COMMENT '板块ID', `name` varchar(50) NOT NULL COMMENT '板块名称', `icon` varchar(255) DEFAULT '' COMMENT '图标', `type` varchar(20) DEFAULT 'card' COMMENT '类型 quick=快捷入口 card=功能卡片', `jump_page` varchar(100) DEFAULT '' COMMENT '跳转页面', `sort` int DEFAULT 0 COMMENT '排序(越大越靠前)', `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池板块表'; -- 2. 消息表 CREATE TABLE IF NOT EXISTS `eb_community_message` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息ID', `uid` int NOT NULL COMMENT '用户ID', `category_id` int NOT NULL COMMENT '板块ID', `content` text COMMENT '消息内容', `images` varchar(1000) DEFAULT '' COMMENT '图片(逗号分隔)', `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', `audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工', `audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注', `is_delete` tinyint DEFAULT 0 COMMENT '是否删除 0否 1是', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), KEY `idx_uid` (`uid`), KEY `idx_category` (`category_id`), KEY `idx_status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池消息表'; -- 3. 匹配配置表 CREATE TABLE IF NOT EXISTS `eb_community_match_config` ( `id` int NOT NULL AUTO_INCREMENT, `match_radius` int DEFAULT 5 COMMENT '匹配半径(公里)', `recommend_count` int DEFAULT 6 COMMENT '推荐用户数', `priority_online` tinyint DEFAULT 1 COMMENT '优先在线用户 0否 1是', `priority_same_city` tinyint DEFAULT 1 COMMENT '优先同城用户 0否 1是', `priority_opposite_sex` tinyint DEFAULT 1 COMMENT '优先异性用户 0否 1是', `auto_audit` tinyint DEFAULT 1 COMMENT '自动审核开关 0关 1开', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池匹配配置表'; -- ============================================ -- 二、许愿树相关表 -- ============================================ -- 1. 节日表 CREATE TABLE IF NOT EXISTS `eb_wishtree_festival` ( `id` int NOT NULL AUTO_INCREMENT COMMENT '节日ID', `name` varchar(50) NOT NULL COMMENT '节日名称', `icon` varchar(255) DEFAULT '' COMMENT '节日图标', `start_date` varchar(20) DEFAULT '' COMMENT '开始日期(MM-DD或农历)', `end_date` varchar(20) DEFAULT '' COMMENT '结束日期', `is_lunar` tinyint DEFAULT 0 COMMENT '是否农历 0否 1是', `theme_color` varchar(20) DEFAULT '#FF6B6B' COMMENT '主题色', `sort` int DEFAULT 0 COMMENT '排序(越大越靠前)', `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树节日表'; -- 2. 心愿表 CREATE TABLE IF NOT EXISTS `eb_wishtree_wish` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '心愿ID', `uid` int NOT NULL COMMENT '用户ID', `festival_id` int DEFAULT 0 COMMENT '节日ID', `content` varchar(500) NOT NULL COMMENT '心愿内容', `background_id` int DEFAULT 0 COMMENT '背景ID', `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', `audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工', `audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注', `like_count` int DEFAULT 0 COMMENT '点赞数', `comment_count` int DEFAULT 0 COMMENT '评论数', `is_delete` tinyint DEFAULT 0 COMMENT '是否删除 0否 1是', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), KEY `idx_uid` (`uid`), KEY `idx_festival` (`festival_id`), KEY `idx_status` (`status`), KEY `idx_create_time` (`create_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树心愿表'; -- 3. 心愿点赞表 CREATE TABLE IF NOT EXISTS `eb_wishtree_like` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '点赞ID', `uid` int NOT NULL COMMENT '用户ID', `wish_id` bigint NOT NULL COMMENT '心愿ID', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), UNIQUE KEY `uk_uid_wish` (`uid`, `wish_id`), KEY `idx_wish` (`wish_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树点赞表'; -- 4. 心愿评论表 CREATE TABLE IF NOT EXISTS `eb_wishtree_comment` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论ID', `wish_id` bigint NOT NULL COMMENT '心愿ID', `uid` int NOT NULL COMMENT '用户ID', `content` varchar(255) NOT NULL COMMENT '评论内容', `parent_id` bigint DEFAULT 0 COMMENT '父评论ID(回复)', `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', `is_delete` tinyint DEFAULT 0 COMMENT '是否删除 0否 1是', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), KEY `idx_wish` (`wish_id`), KEY `idx_uid` (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树评论表'; -- 5. 背景素材表 CREATE TABLE IF NOT EXISTS `eb_wishtree_background` ( `id` int NOT NULL AUTO_INCREMENT COMMENT '背景ID', `name` varchar(50) NOT NULL COMMENT '背景名称', `image` varchar(255) NOT NULL COMMENT '背景图片URL', `festival_id` int DEFAULT 0 COMMENT '关联节日ID(0=通用)', `sort` int DEFAULT 0 COMMENT '排序(越大越靠前)', `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), KEY `idx_festival` (`festival_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树背景素材表'; -- ============================================ -- 三、初始化数据 -- ============================================ -- 初始化匹配配置 INSERT INTO `eb_community_match_config` (`id`, `match_radius`, `recommend_count`, `priority_online`, `priority_same_city`, `priority_opposite_sex`, `auto_audit`) VALUES (1, 5, 6, 1, 1, 1, 1) ON DUPLICATE KEY UPDATE `id` = `id`; -- 初始化缘池板块 INSERT INTO `eb_community_category` (`name`, `icon`, `type`, `jump_page`, `sort`, `status`) VALUES ('语音匹配', 'el-icon-microphone', 'quick', 'VoiceMatchActivity', 100, 1), ('心动信号', 'el-icon-star-on', 'quick', 'HeartbeatSignalActivity', 99, 1), ('在线处对象', 'el-icon-user', 'card', 'OnlineDatingActivity', 90, 1), ('找人玩游戏', 'el-icon-video-play', 'card', 'FindGameActivity', 89, 1), ('一起KTV', 'el-icon-headset', 'card', 'KTVTogetherActivity', 88, 1), ('你画我猜', 'el-icon-edit', 'card', 'DrawGuessActivity', 87, 1), ('和平精英', 'el-icon-aim', 'card', 'PeaceEliteActivity', 86, 1), ('桌游', 'el-icon-s-grid', 'card', 'TableGamesActivity', 85, 1); -- 初始化节日数据 INSERT INTO `eb_wishtree_festival` (`name`, `icon`, `start_date`, `end_date`, `is_lunar`, `theme_color`, `sort`, `status`) VALUES ('元旦', '🎉', '12-31', '01-03', 0, '#FF6B6B', 100, 1), ('春节', '🧧', '除夕', '正月十五', 1, '#E74C3C', 99, 1), ('情人节', '💕', '02-13', '02-15', 0, '#FF69B4', 98, 1), ('妇女节', '🌸', '03-07', '03-09', 0, '#FFB6C1', 97, 1), ('清明节', '🌿', '清明', '清明后2天', 1, '#90EE90', 96, 1), ('劳动节', '💪', '04-30', '05-03', 0, '#FFA500', 95, 1), ('母亲节', '🌹', '5月第2周日', '5月第2周日', 0, '#FF1493', 94, 1), ('儿童节', '🎈', '05-31', '06-02', 0, '#87CEEB', 93, 1), ('端午节', '🐲', '五月初五', '五月初七', 1, '#228B22', 92, 1), ('七夕', '🌙', '七月初七', '七月初七', 1, '#9370DB', 91, 1), ('中秋节', '🥮', '八月十五', '八月十七', 1, '#FFD700', 90, 1), ('国庆节', '🇨🇳', '09-30', '10-07', 0, '#FF0000', 89, 1), ('圣诞节', '🎄', '12-24', '12-26', 0, '#228B22', 88, 1), ('生日祝福', '🎂', '全年', '全年', 0, '#FF69B4', 50, 1), ('日常祝福', '✨', '全年', '全年', 0, '#9B59B6', 49, 1); -- ============================================ -- 四、菜单配置 -- ============================================ -- 缘池管理菜单 INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delte`, `create_time`, `update_time`) VALUES (0, '缘池管理', 'el-icon-s-opportunity', '', '/community', 'M', 140, 1, 0, NOW(), NOW()); SET @community_id = LAST_INSERT_ID(); INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delte`, `create_time`, `update_time`) VALUES (@community_id, '板块管理', '', 'admin:community:category', '/community/category', 'C', 3, 1, 0, NOW(), NOW()), (@community_id, '消息管理', '', 'admin:community:message', '/community/message', 'C', 2, 1, 0, NOW(), NOW()), (@community_id, '匹配配置', '', 'admin:community:match', '/community/match-config', 'C', 1, 1, 0, NOW(), NOW()); -- 许愿树管理菜单 INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delte`, `create_time`, `update_time`) VALUES (0, '许愿树管理', 'el-icon-present', '', '/wishtree', 'M', 139, 1, 0, NOW(), NOW()); SET @wishtree_id = LAST_INSERT_ID(); INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`, `is_delte`, `create_time`, `update_time`) VALUES (@wishtree_id, '节日管理', '', 'admin:wishtree:festival', '/wishtree/festival', 'C', 4, 1, 0, NOW(), NOW()), (@wishtree_id, '心愿管理', '', 'admin:wishtree:wish', '/wishtree/wish', 'C', 3, 1, 0, NOW(), NOW()), (@wishtree_id, '背景素材', '', 'admin:wishtree:background', '/wishtree/background', 'C', 2, 1, 0, NOW(), NOW()), (@wishtree_id, '数据统计', '', 'admin:wishtree:statistics', '/wishtree/statistics', 'C', 1, 1, 0, NOW(), NOW());