Files
2026-10-20 21:19:44 +08:00

37 lines
1.5 KiB
Markdown
Raw Permalink 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.
# 6.12 参数管理
:::tip 概述
参数模块(goframe_param,平台级表)管理系统级扁平键值参数:code 全局唯一(uk_code),标准七件套 CRUD。机制说明见 [5.13 系统参数管理](../core/param),本节给出模块视角。
:::
## 接口清单
```text
七件套:sys:param:{page|list|detail|add|update|delete|batchDelete}
```
## 模块要点
| 要点 | 实现 |
|------|------|
| 唯一性 | UniqueFields{Field:"code"}(与全局 uk_code 一致,无偏差)——Add 前预检 |
| 平台级 | 无租户隔离(全局参数) |
| 消费方式 | 业务按 code 查询取值(低频直接查库) |
| 选择判据 | 简单键值对 → param;结构化表单配置 → config;需重启 → config.yaml |
## 与 config 模块的对照
| 维度 | param | config + config_item |
|------|-------|---------------------|
| 形态 | 扁平 code→value | 分组 + 键值明细(type/options 结构化) |
| 适用 | 运行参数快速读写 | 网站配置等表单化场景 |
| 接口 | 七件套 | 七件套 + web/index + web/save |
| 唯一预检 | 有(spec UniqueFields) | Add 走 CheckUnique(Update 1062 兜底) |
## 管理建议
+ code 命名 snake_case 语义化(default_password / page_size / user_code_prefix)
+ 删除是软删(可恢复),但删除前确认无业务引用(param 无引用守卫)
+ 高频消费场景(每请求读)建议调用方自建缓存(param 模块无缓存层)
+ 新增参数后在代码中以常量引用 code 字符串,避免拼写漂移