package handler

import (
	"kra/internal/modules/system/service"
	"kra/internal/modules/system/transport/httpx"
	"kra/internal/modules/system/transport/middleware"

	"github.com/gin-gonic/gin"
)

type Navigation struct{ service *service.UserService }

func NewNavigation(service *service.UserService) *Navigation { return &Navigation{service: service} }
func (h *Navigation) Menu(c *gin.Context) {
	claims := middleware.Claims(c)
	if claims == nil {
		httpx.NoAuth(c, "未登录或非法访问")
		return
	}
	menus, err := h.service.Menus(c.Request.Context(), claims.AuthorityID)
	if err != nil {
		httpx.Fail(c, "获取失败")
		return
	}
	httpx.Write(c, httpx.CodeSuccess, gin.H{"menus": menus}, "获取成功")
}
