2026-03-27 10:27:44 +08:00
|
|
|
|
# PocketBase 文档相关表结构
|
|
|
|
|
|
|
|
|
|
|
|
本方案新增 3 张 PocketBase `base collection`,统一采用业务 id 字段进行关联,不直接依赖 PocketBase 自动生成的 `id` 作为业务主键。
|
|
|
|
|
|
|
|
|
|
|
|
补充约定:
|
|
|
|
|
|
|
2026-03-27 13:55:06 +08:00
|
|
|
|
- `document_image`、`document_video` 只保存关联的 `attachments_id`,不直接存文件;当存在多个附件时,统一使用 `|` 分隔,例如:`ATT-001|ATT-002|ATT-003`。
|
2026-03-27 19:26:25 +08:00
|
|
|
|
- `document_type` 使用多选字符串持久化,但格式特殊:`system_dict_id@dict_word_enum|system_dict_id@dict_word_enum`;前端显示时用枚举值描述,存库时保留该组合值。
|
2026-03-27 10:27:44 +08:00
|
|
|
|
- `document_keywords`、`document_product_categories`、`document_application_scenarios`、`document_hotel_type` 统一使用竖线分隔字符串,例如:`分类A|分类B|分类C`。
|
2026-03-27 19:26:25 +08:00
|
|
|
|
- `document_status` 仅允许 `有效`、`过期` 两种值,并由系统根据生效日期与到期日期自动计算;当两者都为空时默认 `有效`。
|
2026-03-27 10:27:44 +08:00
|
|
|
|
- `document_owner` 的业务含义为“上传者openid”。
|
|
|
|
|
|
- `attachments_link` 是 PocketBase `file` 字段,保存附件本体;访问链接由 PocketBase 根据记录和文件名生成。
|
2026-03-27 13:55:06 +08:00
|
|
|
|
- 文档字段中,面向用户填写的字段里只有 `document_title`、`document_type` 设为必填,其余字段均允许为空。
|
2026-03-27 10:27:44 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 1. `tbl_attachments` 附件表
|
|
|
|
|
|
|
|
|
|
|
|
**类型:** Base Collection
|
|
|
|
|
|
|
|
|
|
|
|
| 字段名 | 类型 | 备注 |
|
|
|
|
|
|
| :--- | :--- | :--- |
|
|
|
|
|
|
| attachments_id | text | 附件业务 id,唯一标识符 |
|
2026-03-27 19:26:25 +08:00
|
|
|
|
| attachments_link | file | 附件本体,单文件,不限制文件类型,数据库字段上限已放宽到约 4GB |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| attachments_filename | text | 原始文件名 |
|
|
|
|
|
|
| attachments_filetype | text | 文件类型/MIME |
|
|
|
|
|
|
| attachments_size | number | 附件大小 |
|
|
|
|
|
|
| attachments_owner | text | 上传者业务 id |
|
|
|
|
|
|
| attachments_md5 | text | 附件 MD5 码 |
|
|
|
|
|
|
| attachments_ocr | text | OCR 识别结果 |
|
|
|
|
|
|
| attachments_status | text | 附件状态 |
|
|
|
|
|
|
| attachments_remark | text | 备注 |
|
|
|
|
|
|
|
|
|
|
|
|
**索引规划:**
|
|
|
|
|
|
|
|
|
|
|
|
- `attachments_id` 唯一索引
|
|
|
|
|
|
- `attachments_owner` 普通索引
|
|
|
|
|
|
- `attachments_status` 普通索引
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 2. `tbl_document` 文档表
|
|
|
|
|
|
|
|
|
|
|
|
**类型:** Base Collection
|
|
|
|
|
|
|
|
|
|
|
|
| 字段名 | 类型 | 备注 |
|
|
|
|
|
|
| :--- | :--- | :--- |
|
|
|
|
|
|
| document_id | text | 文档业务 id,唯一标识符 |
|
|
|
|
|
|
| document_effect_date | date | 文档生效日期 |
|
|
|
|
|
|
| document_expiry_date | date | 文档到期日期 |
|
2026-03-27 19:26:25 +08:00
|
|
|
|
| document_type | text | 文档类型,必填;多选时按 `system_dict_id@dict_word_enum|...` 保存 |
|
2026-03-27 13:55:06 +08:00
|
|
|
|
| document_title | text | 文档标题,必填 |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| document_subtitle | text | 文档副标题 |
|
|
|
|
|
|
| document_summary | text | 文档摘要 |
|
|
|
|
|
|
| document_content | text | 正文内容,保存 Markdown 原文 |
|
2026-03-27 13:55:06 +08:00
|
|
|
|
| document_image | text | 关联多个 `attachments_id`,使用 `|` 分隔 |
|
|
|
|
|
|
| document_video | text | 关联多个 `attachments_id`,使用 `|` 分隔 |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| document_owner | text | 上传者openid |
|
|
|
|
|
|
| document_relation_model | text | 关联机型/模型标识 |
|
2026-03-27 19:26:25 +08:00
|
|
|
|
| document_keywords | text | 关键词,多选后用 `|` 分隔保存 |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| document_share_count | number | 分享次数 |
|
|
|
|
|
|
| document_download_count | number | 下载次数 |
|
|
|
|
|
|
| document_favorite_count | number | 收藏次数 |
|
2026-03-27 19:26:25 +08:00
|
|
|
|
| document_status | text | 文档状态,仅允许 `有效` 或 `过期`,由系统依据生效日期和到期日期自动更新 |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| document_embedding_status | text | 文档嵌入状态 |
|
|
|
|
|
|
| document_embedding_error | text | 文档错误原因 |
|
|
|
|
|
|
| document_embedding_lasttime | date | 最后更新日期 |
|
|
|
|
|
|
| document_vector_version | text | 向量版本号或模型名称 |
|
2026-03-27 19:26:25 +08:00
|
|
|
|
| document_product_categories | text | 产品关联文档,多选后从 `文档-产品关联文档` 字典保存为 `|` 分隔字符串 |
|
|
|
|
|
|
| document_application_scenarios | text | 筛选依据,多选后从 `文档-筛选依据` 字典保存为 `|` 分隔字符串 |
|
|
|
|
|
|
| document_hotel_type | text | 适用场景,多选后从 `文档-适用场景` 字典保存为 `|` 分隔字符串 |
|
2026-03-27 10:27:44 +08:00
|
|
|
|
| document_remark | text | 备注 |
|
|
|
|
|
|
|
|
|
|
|
|
**索引规划:**
|
|
|
|
|
|
|
|
|
|
|
|
- `document_id` 唯一索引
|
|
|
|
|
|
- `document_owner` 普通索引
|
|
|
|
|
|
- `document_type` 普通索引
|
|
|
|
|
|
- `document_status` 普通索引
|
|
|
|
|
|
- `document_embedding_status` 普通索引
|
|
|
|
|
|
- `document_effect_date` 普通索引
|
|
|
|
|
|
- `document_expiry_date` 普通索引
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 3. `tbl_document_operation_history` 文档操作历史表
|
|
|
|
|
|
|
|
|
|
|
|
**类型:** Base Collection
|
|
|
|
|
|
|
|
|
|
|
|
| 字段名 | 类型 | 备注 |
|
|
|
|
|
|
| :--- | :--- | :--- |
|
|
|
|
|
|
| doh_id | text | 文档操作历史业务 id,唯一标识符 |
|
|
|
|
|
|
| doh_document_id | text | 关联 `document_id` |
|
|
|
|
|
|
| doh_operation_type | text | 操作类型 |
|
|
|
|
|
|
| doh_user_id | text | 操作人业务 id |
|
|
|
|
|
|
| doh_current_count | number | 本次操作对应次数 |
|
|
|
|
|
|
| doh_remark | text | 备注 |
|
|
|
|
|
|
|
|
|
|
|
|
**索引规划:**
|
|
|
|
|
|
|
|
|
|
|
|
- `doh_id` 唯一索引
|
|
|
|
|
|
- `doh_document_id` 普通索引
|
|
|
|
|
|
- `doh_user_id` 普通索引
|
|
|
|
|
|
- `doh_operation_type` 普通索引
|