You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
790 B

  1. package api
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. "main/controller/servers"
  6. "main/middleware"
  7. "main/model/dbModel"
  8. )
  9. // @Tags Menu
  10. // @Summary 获取用户动态路由
  11. // @Security ApiKeyAuth
  12. // @Produce application/json
  13. // @Param data body api.RegistAndLoginStuct true "可以什么都不填"
  14. // @Success 200 {string} json "{"success":true,"data":{},"msg":"返回成功"}"
  15. // @Router /menu/getMenu [post]
  16. func GetMenu(c *gin.Context) {
  17. claims, _ := c.Get("claims")
  18. waitUse := claims.(*middleware.CustomClaims)
  19. err, menus := new(dbModel.Menu).GetMenuTree(waitUse.AuthorityId)
  20. if err != nil {
  21. servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{"menus": menus})
  22. } else {
  23. servers.ReportFormat(c, true, "获取成功", gin.H{"menus": menus})
  24. }
  25. }