feat: 规范化PocketBase数据库文档与原生API访问

- 将数据库文档拆分为按collection命名的标准文件,统一格式
- 补充tbl_company、tbl_system_dict等表的原生访问规则
- 新增users_tag、document_create等字段
- 优化用户资料更新接口,支持非必填字段
- 添加公司原生API测试脚本
- 归档本次变更至OpenSpec
This commit is contained in:
2026-03-29 16:21:34 +08:00
parent 51a90260e4
commit e9fe1165e3
46 changed files with 3790 additions and 1108 deletions

View File

@@ -0,0 +1,39 @@
# pb_tbl_attachments
> 来源:线上 PocketBase collection 回读、`script/pocketbase.documents.js`
> 类型:`base`
> 读写规则:公开可读;原生写权限与 hooks 管理权限仅管理员 / 管理角色允许
## 表用途
统一存储项目中的真实上传文件。业务表只保存 `attachments_id`,文件本体仅保存在本表 `attachments_link` 中。
## 字段清单
| 字段名 | 类型 | 必填 | 说明 |
| :--- | :--- | :---: | :--- |
| `id` | `text` | 是 | PocketBase 记录主键 |
| `attachments_id` | `text` | 是 | 附件业务 ID |
| `attachments_link` | `file` | 否 | 文件本体,数据库限制已放宽到约 4GB |
| `attachments_filename` | `text` | 否 | 原始文件名 |
| `attachments_filetype` | `text` | 否 | 文件类型 / MIME |
| `attachments_size` | `number` | 否 | 文件大小 |
| `attachments_owner` | `text` | 否 | 上传者业务标识 |
| `attachments_md5` | `text` | 否 | 文件 MD5 |
| `attachments_ocr` | `text` | 否 | OCR 识别结果 |
| `attachments_status` | `text` | 否 | 附件状态 |
| `attachments_remark` | `text` | 否 | 备注 |
## 索引
| 索引名 | 类型 | 说明 |
| :--- | :--- | :--- |
| `idx_tbl_attachments_attachments_id` | `UNIQUE INDEX` | 保证 `attachments_id` 唯一 |
| `idx_tbl_attachments_attachments_owner` | `INDEX` | 加速按上传者查询 |
| `idx_tbl_attachments_attachments_status` | `INDEX` | 加速按附件状态查询 |
## 补充约定
- 图片、视频、普通文件都统一走本表。
- 业务访问控制不放在本表,而由引用它的业务表与 hooks 接口控制。
- PocketBase 系统字段 `created``updated` 仍然存在,只是不在 collection 字段清单里单独声明。