feat: 增加知识库新类型FAQ知识库

This commit is contained in:
2026-02-24 13:07:14 +08:00
parent e27ba8d457
commit a9060ed2b9
27 changed files with 1701 additions and 58 deletions

View File

@@ -0,0 +1,38 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- P2: FAQ知识库增强新增类型与FAQ条目表
-- 1) document_collection 增加知识库类型
ALTER TABLE tb_document_collection
ADD COLUMN collection_type varchar(16) NOT NULL DEFAULT 'DOCUMENT' COMMENT '知识库类型: DOCUMENT/FAQ' AFTER id;
-- 2) 回填历史数据
UPDATE tb_document_collection
SET collection_type = 'DOCUMENT'
WHERE collection_type IS NULL OR collection_type = '';
-- 3) 增加类型索引
ALTER TABLE tb_document_collection
ADD INDEX idx_collection_type (collection_type);
-- 4) FAQ条目表
CREATE TABLE IF NOT EXISTS tb_faq_item
(
id bigint UNSIGNED NOT NULL COMMENT '主键',
collection_id bigint UNSIGNED NOT NULL COMMENT '知识库ID',
question varchar(1024) NOT NULL COMMENT '问题',
answer_html longtext NULL COMMENT '答案HTML',
answer_text longtext NULL COMMENT '答案纯文本',
order_no int NULL DEFAULT 0 COMMENT '排序',
options text NULL COMMENT '扩展项',
created datetime NULL COMMENT '创建时间',
created_by bigint UNSIGNED NULL COMMENT '创建人',
modified datetime NULL COMMENT '更新时间',
modified_by bigint UNSIGNED NULL COMMENT '更新人',
PRIMARY KEY (id),
INDEX idx_faq_collection_id (collection_id),
INDEX idx_faq_collection_order (collection_id, order_no)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT ='FAQ条目';
SET FOREIGN_KEY_CHECKS = 1;