- 修改登录路由为 `/pb/api/wechat/login`,新增局部 try/catch 以保留业务状态码并返回统一结构 `{ code, msg, data }`。
- 更新所有相关 API 路由前缀为 `/pb`,包括系统、平台、字典、附件和文档接口。
- 新增文档接口支持多个附件 ID,更新 OpenAPI 文档以反映这些变化。
- 在数据库模式中添加对字典名称的唯一索引,确保全局唯一性。
- 更新文档字段,设置 `document_title` 和 `document_type` 为必填项,并在验证过程中检查字段的必填属性。
3.5 KiB
3.5 KiB
平台后台数据库表结构 (PocketBase)
本方案采用纯业务 ID 关联模式。PocketBase 底层的 id 字段由系统自动维护,业务逻辑中完全使用自定义的 _id 字段进行读写和关联。
1. tbl_system_dict (系统词典)
类型: Base Collection
| 字段名 | 类型 | 备注 |
|---|---|---|
| system_dict_id | text | 自定义词id |
| dict_name | text | 词典名称 |
| dict_word_enum | text | 词典枚举 |
| dict_word_description | text | 词典描述 |
| dict_word_is_enabled | bool | 是否有效 |
| dict_word_sort_order | number | 显示顺序 |
| dict_word_parent_id | text | 实现父级字段 (存储其他 dict 的 system_dict_id) |
| dict_word_remark | text | 备注 |
索引规划 (Indexes):
CREATE UNIQUE INDEX针对system_dict_id(确保业务主键唯一)CREATE UNIQUE INDEX针对dict_name(确保词典名称全局唯一,并支持按名称唯一索引查询)CREATE INDEX针对dict_word_parent_id(加速父子级联查询)
2. tbl_company (公司)
类型: Base Collection
| 字段名 | 类型 | 备注 |
|---|---|---|
| company_id | text | 自定义公司id |
| company_name | text | 公司名称 |
| company_type | text | 公司类型 |
| company_entity | text | 公司法人 |
| company_usci | text | 统一社会信用代码 |
| company_nationality | text | 国家 |
| company_province | text | 省份 |
| company_city | text | 城市 |
| company_postalcode | text | 邮编 |
| company_add | text | 地址 |
| company_status | text | 公司状态 |
| company_level | text | 公司等级 |
| company_remark | text | 备注 |
索引规划 (Indexes):
CREATE UNIQUE INDEX针对company_id(确保业务主键唯一)CREATE INDEX针对company_usci(加速信用代码检索)
3. tbl_user_groups (用户组)
类型: Base Collection
| 字段名 | 类型 | 备注 |
|---|---|---|
| usergroups_id | text | 自定义用户组id |
| usergroups_name | text | 用户组名 |
| usergroups_level | number | 权限等级 |
| usergroups_remark | text | 备注 |
索引规划 (Indexes):
CREATE UNIQUE INDEX针对usergroups_id(确保业务主键唯一)
4. tbl_users (用户)
类型: Base Collection (采用纯业务记录,不使用系统 Auth,以便完美适配图示字段)
| 字段名 | 类型 | 备注 |
|---|---|---|
| users_id | text | 自定义用户id |
| users_name | text | 用户名 |
| users_idtype | text | 证件类别 |
| users_id_number | text | 证件号 |
| users_phone | text | 用户电话号码 |
| users_wx_openid | text | 微信号 |
| users_level | text | 用户等级 |
| users_type | text | 用户类型 |
| users_status | text | 用户状态 |
| company_id | text | 公司id (存储 tbl_company.company_id) |
| users_parent_id | text | 用户父级id (存储 tbl_users.users_id) |
| users_promo_code | text | 用户推广码 |
| users_id_pic_a | file | 用户证件照片(正) |
| users_id_pic_b | file | 用户证件照片(反) |
| users_title_picture | file | 用户资质照片 |
| users_picture | file | 用户头像 |
| usergroups_id | text | 用户组id (存储 tbl_user_groups.usergroups_id) |
索引规划 (Indexes):
CREATE UNIQUE INDEX针对users_id(确保业务主键唯一)CREATE UNIQUE INDEX针对users_phone(确保手机号唯一,加速登录查询)CREATE UNIQUE INDEX针对users_wx_openid(确保微信开放ID唯一)CREATE INDEX针对company_id,usergroups_id,users_parent_id(加速这三个高频业务外键的匹配查询)