05 — 字典服务
来源:
api/personal.ts/api/work.ts
涉及页面:Personal / Work / Guarantor
共 4 个接口(行政区划 / 就业类型 / 行业 / 亲属关系)
业务上下文
字典服务承担三类职责:
- 后端 SoT — 后端调整选项不需要前端发版(如新增行业、行政区划调整)
- 多端一致 — SA App / Client App / 运营后台共用同一份枚举
- 多国扩展 — 字典随国家切换,支持后续扩展到 KE / GH 等
通用约定
所有字典接口出参统一结构:
| 字段 | 类型 | 说明 |
|---|---|---|
| code | string | 业务码(snake_case 或 kebab-case;用于持久化) |
| label | string | 显示文案(按 locale 返回 i18n 文案;UI 直接展示) |
字典接口请求方式:
- 鉴权 token 必填
- 出参带
etag/version字段支持客户端缓存 - 支持
?locale=en参数(接口预留多语言扩展)
1. 行政区划字典(States + LGAs)
1.1 States 列表
业务描述:拉取 NG 全部 36 州 + FCT。
触发场景:Personal 页 mount。
入参:无
出参:array<{ code, name }>
| 字段 | 类型 | 说明 |
|---|---|---|
| code | string | 州代码(如 lagos / fct / kano) |
| name | string | 州名(如 Lagos / Abuja FCT) |
1.2 LGAs 列表(按 State 级联)
业务描述:按州 code 拉取该州的 LGA(Local Government Area)列表。
触发场景:Personal 页用户选完州后;切换州时重新拉。
入参
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| state_code | string | ✓ | 州代码(从 1.1 接口出参取) |
出参:array<{ code, name, state_code }>
| 字段 | 类型 | 说明 |
|---|---|---|
| code | string | LGA 代码 |
| name | string | LGA 名 |
| state_code | string | 所属州 code(回显,便于前端校验) |
关键异常
| 异常码 | 含义 | 前端处理 |
|---|---|---|
| STATE_NOT_FOUND | 入参 state_code 不存在 | toast + 清空当前州选择 |
2. 就业类型字典
业务描述:拉取就业类型枚举。
触发场景:Work 页 mount。
入参:无
出参:array<{ code, label }>
选项:
| code | label |
|---|---|
| salaried | Salaried |
| self-employed | Self-employed |
| business-owner | Business Owner |
| civil-servant | Civil Servant |
| student | Student |
| unemployed | Unemployed |
| others | Others |
3. 行业字典
业务描述:拉取行业枚举。
触发场景:Work 页 mount。
入参:无
出参:array<{ code, label }>
选项(按字母顺序):
| code | label |
|---|---|
| agriculture | Agriculture |
| banking-finance | Banking & Finance |
| construction | Construction |
| education | Education |
| healthcare | Healthcare |
| hospitality | Hospitality & Tourism |
| it-technology | IT & Technology |
| manufacturing | Manufacturing |
| oil-gas | Oil & Gas |
| public-sector | Public Sector / Government |
| real-estate | Real Estate |
| retail-trade | Retail / Trade |
| telecommunications | Telecommunications |
| transport-logistics | Transport / Logistics |
| others | Others |
4. 亲属关系字典
业务描述:拉取紧急联系人关系枚举。
触发场景:Guarantor 页 mount。
入参:无
出参:array<{ code, label }>
选项:
| code | label |
|---|---|
| parent | Parent |
| spouse | Spouse |
| sibling | Sibling |
| friend | Friend |
| colleague | Colleague |
| other | Other |
范围边界
以下枚举由前端 hard code,不在本字典服务范围(选项稳定、跨国差异小):
- 性别 / 婚姻 / 子女数 / 宗教 / 教育 / 居住类型 / 还款频率