fix: 设计原则审查修复 — DIP/ISP, LoD, DRY, OCP, URL, 301缓存
- P0 DIP+ISP: 全链路注入接口,消除零接口紧耦合 - P0 URL: auth 301→302,修复登出后浏览器缓存陷阱 - P1 DRY: JWT 认证逻辑收敛至 TokenService+中间件 - P2 DRY: 前后端角色/状态映射统一为 model 常量 - P2 LoD: 新增 SettingsController,router 不再跨层调 repo - P2 URL: settings ?tab= → /settings/:tab 伪静态 - P3 OCP: 角色权限 map 化,告别硬编码 switch
This commit is contained in:
@ -15,6 +15,7 @@ type Config struct {
|
||||
Database DatabaseConfig `mapstructure:"database"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
Bcrypt BcryptConfig `mapstructure:"bcrypt"`
|
||||
Roles RolesConfig `mapstructure:"roles"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@ -42,6 +43,18 @@ type BcryptConfig struct {
|
||||
Cost int `mapstructure:"cost"`
|
||||
}
|
||||
|
||||
// RolesConfig 角色配置(可扩展,新增角色只需改 config.yaml)
|
||||
type RolesConfig struct {
|
||||
Levels map[string]int `mapstructure:"levels"`
|
||||
Names map[string]string `mapstructure:"names"`
|
||||
Permissions RolesPermissions `mapstructure:"permissions"`
|
||||
}
|
||||
|
||||
// RolesPermissions 角色间操作权限
|
||||
type RolesPermissions struct {
|
||||
OperableRoles map[string][]string `mapstructure:"operable_roles"`
|
||||
}
|
||||
|
||||
// 全局配置实例(初始化后只读)
|
||||
var App *Config
|
||||
|
||||
|
||||
Reference in New Issue
Block a user