用户在线状态处理

This commit is contained in:
yxh
2020-03-06 18:11:05 +08:00
parent 12ef9cb691
commit f90e2a79b4
13 changed files with 734 additions and 28 deletions
+19 -4
View File
@@ -4,6 +4,7 @@ import (
"gfast/app/service/admin/auth_service"
"gfast/app/service/admin/user_service"
"gfast/library/response"
"gfast/library/utils"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/util/gconv"
@@ -15,12 +16,22 @@ type Index struct{}
//后台首页接口数据
func (c *Index) Index(r *ghttp.Request) {
//获取用户信息
userInfo := user_service.GetLoginAdminInfo(r)
userEntity := user_service.GetLoginAdminInfo(r)
userInfo := gconv.Map(userEntity)
//菜单列表
var menuList g.List
isSuperAdmin := false
if userInfo != nil {
userId := gconv.Int(userInfo["id"])
userId := userEntity.Id
delete(userInfo, "user_password")
//获取无需验证权限的用户id
for _, v := range utils.NotCheckAuthAdminIds {
if v == userId {
isSuperAdmin = true
break
}
}
//获取用户角色信息
allRoles, err := auth_service.GetRoleList()
if err == nil {
@@ -34,7 +45,12 @@ func (c *Index) Index(r *ghttp.Request) {
}
userInfo["roles"] = strings.Join(name, "")
//获取菜单信息
menuList, err = user_service.GetAdminMenusByRoleIds(roleIds)
if isSuperAdmin {
//超管获取所有菜单
menuList, err = user_service.GetAllMenus()
} else {
menuList, err = user_service.GetAdminMenusByRoleIds(roleIds)
}
if err != nil {
g.Log().Error(err)
}
@@ -46,7 +62,6 @@ func (c *Index) Index(r *ghttp.Request) {
g.Log().Error(err)
userInfo["roles"] = ""
}
}
result := g.Map{