This commit is contained in:
2026-08-16 09:02:39 +08:00
parent c554152f4f
commit f7f6db8695
105 changed files with 2535 additions and 948 deletions
+23 -8
View File
@@ -1,8 +1,14 @@
package biz
import "context"
import (
"context"
"time"
)
type MenuButton struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uint
Name string
Description string
@@ -11,15 +17,22 @@ type MenuButton struct {
}
type MenuParameter struct {
ID uint
MenuID uint
Type string
Key string
Value string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uint
MenuID uint
Type string
Key string
Value string
}
type Menu struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uint
MenuID uint
ParentID uint
Path string
Name string
@@ -73,7 +86,7 @@ func (uc *MenuUsecase) Tree(ctx context.Context) ([]*Menu, error) {
for _, item := range items {
if parent := byID[item.ParentID]; parent != nil {
parent.Children = append(parent.Children, item)
} else {
} else if item.ParentID == 0 {
roots = append(roots, item)
}
}
@@ -118,8 +131,10 @@ func (uc *MenuUsecase) AuthorityMenus(ctx context.Context, authorityID uint) ([]
if _, ok := selected[item.ID]; ok {
// The authority-menu endpoint returns menu relations only. Keep its
// existing contract: button details are loaded by the dedicated
// authority-button endpoints.
// authority-button endpoints. The compatible query does not preload either
// relation here, so parameters must remain absent as well.
item.Buttons = nil
item.Parameters = nil
result = append(result, item)
}
}