Files
easygoadmin-wiki/EasyGoAdmin_Gin_AntdVue/zh/api-spec/dict-api.md
T
2026-10-25 17:24:27 +08:00

45 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 8.6 字典数据接口
:::tip 概述
字典数据分两套入口:**别名接口**(/api/dictionary/*,登录即可)供业务侧读字典定义与项;**字典项快捷接口**(getDictItemList)供前端下拉取选项。管理类接口需管理权限码。
:::
## 业务读取(登录即可)
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/dictionary/list | 字典列表(含字典项) |
| GET | /api/dictionary/info | 字典详情 |
未声明 Permission ——登录即可访问,供页面初始化取字典数据。
## 字典项快捷查询(登录即可)
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/dict/item/getDictItemList/{code} | 按字典编码取全部字典项 |
前端下拉数据源标准入口:传字典编码(如 `example_status`),返回该项集合(value/label/排序)。
## 管理接口(需权限码)
| 路径 | 权限码前缀 |
|---|---|
| /api/dict/*(字典 CRUD、refreshCache) | sys:dict:* |
| /api/dict/item/*(字典项 CRUD) | sys:dictitem:* |
## 缓存行为
字典项集合按编码缓存(变更主动失效)。业务读接口命中缓存毫秒级返回;`GET /api/dict/refreshCache` 为运维手动兜底(需 sys:dict:cache)。
## 前后端同源约定
- 后端 SerializeMaps 回填 `{field}Text` 用的编码 = 前端下拉取选项的编码
- 枚举存储整型、字典值字符串——基座负责转换
- 显示名改动只需改字典项,两端同步生效
## 相关
- [5.11 字典模块](/zh/core/dict.html)
- [6.12 字典管理](/zh/modules/dict.html)