28 lines
513 B
Go
28 lines
513 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"myschools.me/heritage/heritage-api/service"
|
|
)
|
|
|
|
func MenuList(c *gin.Context) {
|
|
usr := currentUser(c)
|
|
if usr == nil {
|
|
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
|
|
"data": "无效TOKEN, 请重新登录!",
|
|
})
|
|
return
|
|
}
|
|
|
|
menus, err := service.MenuList(usr)
|
|
if err != nil {
|
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"data": "查询失败"})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"items": menus,
|
|
})
|
|
}
|