|
|
@@ -186,7 +186,7 @@ func generatePermName(code string) string {
|
|
|
return code
|
|
|
}
|
|
|
|
|
|
- nameMap := map[string]string{
|
|
|
+ actionMap := map[string]string{
|
|
|
"read": "读取",
|
|
|
"write": "写入",
|
|
|
"create": "创建",
|
|
|
@@ -196,14 +196,31 @@ func generatePermName(code string) string {
|
|
|
"detail": "详情",
|
|
|
}
|
|
|
|
|
|
+ capitalize := func(s string) string {
|
|
|
+ if len(s) == 0 {
|
|
|
+ return s
|
|
|
+ }
|
|
|
+ return strings.ToUpper(s[:1]) + s[1:]
|
|
|
+ }
|
|
|
+
|
|
|
+ // 字段权限:data:model:field:read|write → "{Model} {field} 字段 [读取|写入]"
|
|
|
+ if parts[0] == "data" && len(parts) == 4 {
|
|
|
+ action := actionMap[parts[3]]
|
|
|
+ if action == "" {
|
|
|
+ action = parts[3]
|
|
|
+ }
|
|
|
+ return capitalize(parts[1]) + " " + parts[2] + " 字段" + action
|
|
|
+ }
|
|
|
+
|
|
|
+ // 接口/数据权限:api:model:action 或 data:model:action
|
|
|
var result []string
|
|
|
for i := 1; i < len(parts); i++ {
|
|
|
p := parts[i]
|
|
|
- if mapped, ok := nameMap[p]; ok {
|
|
|
+ if mapped, ok := actionMap[p]; ok {
|
|
|
result = append(result, mapped)
|
|
|
} else {
|
|
|
- result = append(result, p)
|
|
|
+ result = append(result, capitalize(p))
|
|
|
}
|
|
|
}
|
|
|
- return strings.Join(result, "-")
|
|
|
+ return strings.Join(result, " ")
|
|
|
}
|