Przeglądaj źródła

✨ feat(policy-news): 创建政策资讯相关数据表

- 创建policy_news表存储政策资讯基本信息,包含标题、内容、发布时间等字段
- 创建policy_news_files表实现政策资讯与文件的多对多关联
- 优化PolicyNews实体中newsContent字段类型为longtext以匹配数据库定义
yourname 8 miesięcy temu
rodzic
commit
4989614b27

+ 31 - 0
src/server/migrations/2025081301-create-policy-news-table.sql

@@ -0,0 +1,31 @@
+-- 政策资讯表创建
+CREATE TABLE IF NOT EXISTS `policy_news` (
+  `id` int unsigned NOT NULL AUTO_INCREMENT,
+  `news_title` varchar(255) NOT NULL COMMENT '资讯标题',
+  `news_content` longtext NOT NULL COMMENT '资讯内容',
+  `publish_time` timestamp NOT NULL COMMENT '发布时间',
+  `view_count` int unsigned DEFAULT 0 COMMENT '阅读量',
+  `summary` text COMMENT '资讯摘要',
+  `source` varchar(255) DEFAULT NULL COMMENT '资讯来源',
+  `category` varchar(100) DEFAULT NULL COMMENT '资讯分类',
+  `is_featured` tinyint DEFAULT 0 COMMENT '是否精选 0:否 1:是',
+  `is_deleted` tinyint DEFAULT 0 COMMENT '删除状态 0:未删除 1:已删除',
+  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
+  `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `created_by` int DEFAULT NULL COMMENT '创建用户ID',
+  `updated_by` int DEFAULT NULL COMMENT '更新用户ID',
+  PRIMARY KEY (`id`),
+  KEY `idx_category` (`category`),
+  KEY `idx_publish_time` (`publish_time`),
+  KEY `idx_created_by` (`created_by`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+-- 政策资讯文件关联表(多对多关系)
+CREATE TABLE IF NOT EXISTS `policy_news_files` (
+  `policy_news_id` int unsigned NOT NULL,
+  `file_id` int unsigned NOT NULL,
+  PRIMARY KEY (`policy_news_id`, `file_id`),
+  KEY `idx_file_id` (`file_id`),
+  CONSTRAINT `fk_policy_news_files_news` FOREIGN KEY (`policy_news_id`) REFERENCES `policy_news` (`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_policy_news_files_file` FOREIGN KEY (`file_id`) REFERENCES `files` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

+ 1 - 1
src/server/modules/silver-users/policy-news.entity.ts

@@ -10,7 +10,7 @@ export class PolicyNews {
   @Column({ name: 'news_title', type: 'varchar', length: 255, comment: '资讯标题' })
   newsTitle!: string;
 
-  @Column({ name: 'news_content', type: 'text', comment: '资讯内容' })
+  @Column({ name: 'news_content', type: 'longtext', comment: '资讯内容' })
   newsContent!: string;
 
   @Column({ name: 'publish_time', type: 'timestamp', comment: '发布时间' })