Files
yunzerwebsiteallinone/go/docs/sql/create_platform_website_notice.sql
T
2026-11-16 17:22:50 +08:00

60 lines
3.4 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.
CREATE TABLE IF NOT EXISTS `yz_platform_website_notice` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '公告标题',
`summary` varchar(500) NOT NULL DEFAULT '' COMMENT '公告摘要(前台卡片展示,留空则前台截取正文)',
`content` mediumtext COMMENT '公告正文(富文本 HTML)',
`type` tinyint NOT NULL DEFAULT 1 COMMENT '公告类型:1 通知公告 2 活动公告 3 系统维护',
`link_url` varchar(500) NOT NULL DEFAULT '' COMMENT '点击跳转地址,站内相对路径或完整 URL;留空表示不可点击',
`is_popup` tinyint NOT NULL DEFAULT 0 COMMENT '是否作为弹窗/侧栏公告:0 否 1 是',
`top` tinyint NOT NULL DEFAULT 0 COMMENT '是否置顶:0 否 1 是',
`sort` int NOT NULL DEFAULT 0 COMMENT '排序,数字越小越靠前',
`status` tinyint NOT NULL DEFAULT 0 COMMENT '状态:0 草稿 1 已发布 2 已下线',
`start_time` datetime DEFAULT NULL COMMENT '生效开始时间,NULL 表示立即生效',
`end_time` datetime DEFAULT NULL COMMENT '生效结束时间,NULL 表示永久有效',
`views` int NOT NULL DEFAULT 0 COMMENT '浏览量',
`publisher_id` bigint UNSIGNED DEFAULT NULL COMMENT '发布人(平台用户ID)',
`publish_time` datetime DEFAULT NULL COMMENT '发布时间',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`delete_time` datetime DEFAULT NULL COMMENT '删除时间(软删除)',
PRIMARY KEY (`id`),
KEY `idx_status_sort` (`status`, `sort`, `id`),
KEY `idx_popup` (`is_popup`, `status`),
KEY `idx_publish_time` (`publish_time`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '平台官网-站点公告';
SET @notice_pid := (
SELECT `pid` FROM `yz_system_menu`
WHERE `delete_time` IS NULL AND `component_path` LIKE '/website/content/%'
ORDER BY `id` ASC LIMIT 1
);
SET @notice_pid := IFNULL(@notice_pid, (
SELECT `id` FROM `yz_system_menu`
WHERE `delete_time` IS NULL
AND (`path` = '/website/content' OR `title` = '内容管理')
ORDER BY `id` ASC LIMIT 1
));
INSERT INTO `yz_system_menu`
(`pid`, `title`, `path`, `component_path`, `icon`, `sort`, `status`, `is_visible`, `views`, `type`, `creater`, `remark`, `create_time`)
SELECT
@notice_pid, '站点公告', '/website/content/notice', '/website/content/notice/index.vue',
'Bell', 50, 1, 1, '[1]', 2, 'sql', '官网管理 - 站点公告', NOW()
FROM (SELECT 1) AS `t`
WHERE @notice_pid IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM (
SELECT `id` FROM `yz_system_menu`
WHERE `delete_time` IS NULL AND `path` = '/website/content/notice'
LIMIT 1
) AS `exist`
);
INSERT INTO `yz_platform_website_notice`
(`title`, `summary`, `content`, `type`, `is_popup`, `top`, `sort`, `status`, `publish_time`)
VALUES
('温新云科技官网全新改版上线', '本次改版聚焦信息架构与访问体验,欢迎反馈建议。',
'<p>温新云科技官网全新改版上线,本次改版聚焦信息架构与访问体验。</p>', 1, 1, 1, 0, 1, NOW());