This commit is contained in:
2026-08-15 02:05:43 +08:00
parent 1a5969897a
commit bd5dbf2522
15 changed files with 174 additions and 108 deletions
+1 -16
View File
@@ -1,8 +1,6 @@
package handler
import (
"strings"
"kra/internal/server/httpx"
"kra/internal/service"
"kra/internal/service/dto"
@@ -98,24 +96,11 @@ func (h *API) Find(c *gin.Context) {
httpx.Write(c, httpx.CodeSuccess, gin.H{"api": item}, "获取成功")
}
func (h *API) Groups(c *gin.Context) {
items, err := h.service.AllAPI(c.Request.Context(), false)
groups, groupAPIMap, err := h.service.Groups(c.Request.Context())
if err != nil {
httpx.Fail(c, "获取失败")
return
}
seen := map[string]bool{}
groups := []string{}
groupAPIMap := map[string]string{}
for _, item := range items {
if !seen[item.APIGroup] {
seen[item.APIGroup] = true
groups = append(groups, item.APIGroup)
}
parts := strings.Split(item.Path, "/")
if len(parts) > 1 {
groupAPIMap[parts[1]] = item.APIGroup
}
}
httpx.OKWithData(c, gin.H{"groups": groups, "apiGroupMap": groupAPIMap})
}
func (h *API) Roles(c *gin.Context) {