fix: align admin behavior and Kratos integrations

This commit is contained in:
2026-08-14 14:14:51 +08:00
parent 8c4c6ba661
commit e0b0e1d8c8
123 changed files with 4334 additions and 1877 deletions
+14 -3
View File
@@ -15,12 +15,12 @@ type Menu struct{ service *service.MenuService }
func NewMenu(service *service.MenuService) *Menu { return &Menu{service: service} }
func (h *Menu) List(c *gin.Context) {
items, err := h.service.List(c.Request.Context())
items, err := h.service.Tree(c.Request.Context())
if err != nil {
httpx.Fail(c, "获取失败")
return
}
httpx.Write(c, httpx.CodeSuccess, httpx.PageResult{List: items, Total: int64(len(items)), Page: 1, PageSize: 999}, "获取成功")
httpx.Write(c, httpx.CodeSuccess, items, "获取成功")
}
func (h *Menu) Tree(c *gin.Context) {
@@ -119,7 +119,18 @@ func (h *Menu) RoleIDs(c *gin.Context) {
httpx.Fail(c, "获取失败")
return
}
httpx.Write(c, httpx.CodeSuccess, ids, "获取成功")
if ids == nil {
ids = []uint{}
}
defaultIDs, err := h.service.DefaultRouterRoleIDs(c.Request.Context(), uint(id))
if err != nil {
httpx.Fail(c, "获取失败")
return
}
if defaultIDs == nil {
defaultIDs = []uint{}
}
httpx.Write(c, httpx.CodeSuccess, gin.H{"authorityIds": ids, "defaultRouterAuthorityIds": defaultIDs}, "获取成功")
}
func (h *Menu) SetRoles(c *gin.Context) {