新增微信登录/注册合一接口、资料完善接口和token刷新接口 重构用户服务层,支持自动维护用户类型和资料完整度 引入JWT认证中间件和请求验证中间件 更新文档与测试用例,支持dist构建部署
3.4 KiB
3.4 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 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(加速这三个高频业务外键的匹配查询)