package handler

import (
	"kra/internal/service"

	"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 := Claims(c)
	if claims == nil {
		NoAuth(c, "未登录或非法访问")
		return
	}
	menus, err := h.service.Menus(c.Request.Context(), claims.AuthorityID)
	if err != nil {
		Fail(c, "获取失败")
		return
	}
	Write(c, CodeSuccess, gin.H{"menus": menus}, "获取成功")
}
