| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "github.com/gin-gonic/gin" |
| | | "webserver/extend/code" |
| | | "basic.com/valib/logger.git" |
| | | "webserver/extend/util" |
| | | "webserver/middlewares/auth" |
| | | ) |
| | | |
| | | type SysMenuController struct { |
| | | |
| | | } |
| | | |
| | | // @Security ApiKeyAuth |
| | | // @Summary 当前用户的系统菜单 |
| | | // @Description 当前用户的系统菜单 |
| | | // @Produce json |
| | | // @Tags 系统菜单 |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}" |
| | | // @Router /data/api-v/sysmenus/me [get] |
| | | func (controller SysMenuController) Me(c *gin.Context) { |
| | | module := c.Param("module") |
| | | logger.Debug("me.module:",module) |
| | | authDriver := auth.GenerateAuthDriver() |
| | | userM := (*authDriver).User(c) |
| | | if userM !=nil { |
| | | menus := userM["permissions"] |
| | | util.ResponseFormat(c,code.Success,menus) |
| | | } else { |
| | | util.ResponseFormat(c,code.NotLogin,"") |
| | | } |
| | | } |
| | | |
| | | // @Security ApiKeyAuth |
| | | // @Summary 查找当前用户可见的系统菜单 |
| | | // @Description 查找当前用户可见的系统菜单 |
| | | // @Produce json |
| | | // @Tags 系统菜单 |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"", data:""}" |
| | | // @Router /data/api-v/sysmenus/tree [get] |
| | | func (smc SysMenuController) MenuTree(c *gin.Context) { |
| | | authDriver := auth.GenerateAuthDriver() |
| | | userM := (*authDriver).User(c) |
| | | logger.Debug("current:",userM) |
| | | if userM != nil { |
| | | userId := userM["id"].(string) |
| | | var api dbapi.SysMenuApi |
| | | b,d := api.MenuTree(userId) |
| | | if b { |
| | | util.ResponseFormat(c,code.Success,d) |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"") |
| | | } |
| | | } else { |
| | | util.ResponseFormat(c,code.NotLogin,"请登录") |
| | | } |
| | | } |