mirror of
https://github.com/tiger1103/gfast.git
synced 2026-09-21 18:20:47 +00:00
用户在线状态处理
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user