前端修改
This commit is contained in:
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
@@ -135,9 +136,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
var userId = HttpContext.GetUserIdInfo();
|
||||
var data = await _iUserService.GetUserAllInfo(userId);
|
||||
var menus = data.Menus.ToList();
|
||||
|
||||
//为超级管理员直接给全部路由
|
||||
if (SystemConst.Admin.Equals(data.User.UserName))
|
||||
{
|
||||
menus = await _iUserService._repository.ChangeRepository<Repository<MenuEntity>>().GetListAsync();
|
||||
}
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
List<VueRouterModel> routers = MenuEntity.RouterBuild(data.Menus.ToList());
|
||||
List<VueRouterModel> routers = MenuEntity.RouterBuild(menus);
|
||||
return Result.Success().SetData(routers);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
15
Yi.Framework.Net6/Yi.Framework.Common/Const/SystemConst.cs
Normal file
15
Yi.Framework.Net6/Yi.Framework.Common/Const/SystemConst.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class SystemConst
|
||||
{
|
||||
public const string Admin = "cc";
|
||||
public const string AdminRolesCode = "admin";
|
||||
public const string AdminPermissionCode = "*:*:*";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
@@ -53,7 +54,7 @@ namespace Yi.Framework.Service
|
||||
if (await Exist(userName, o => user = o))
|
||||
{
|
||||
userAction.Invoke(user);
|
||||
if (user.Password == Common.Helper.MD5Helper.SHA2Encode(password, user.Salt))
|
||||
if (user.Password ==MD5Helper.SHA2Encode(password, user.Salt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -149,6 +150,7 @@ namespace Yi.Framework.Service
|
||||
public async Task<UserRoleMenuDto> GetUserAllInfo(long userId)
|
||||
{
|
||||
|
||||
|
||||
var userRoleMenu = new UserRoleMenuDto();
|
||||
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)
|
||||
|
||||
@@ -160,6 +162,18 @@ namespace Yi.Framework.Service
|
||||
}
|
||||
user.Password = null;
|
||||
user.Salt = null;
|
||||
|
||||
//超级管理员特殊处理
|
||||
if (SystemConst.Admin.Equals(user.UserName))
|
||||
{
|
||||
userRoleMenu.User = user;
|
||||
userRoleMenu.RoleCodes.Add(SystemConst.AdminRolesCode);
|
||||
userRoleMenu.PermissionCodes.Add(SystemConst.AdminPermissionCode);
|
||||
return userRoleMenu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//得到角色集合
|
||||
var roleList = user.Roles;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user