更新控制器
This commit is contained in:
@@ -26,9 +26,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpGet]
|
||||
public async Task<Result> GetMenu()
|
||||
{
|
||||
//var top =await _menuService.GetTopMenu();
|
||||
//var children=await _menuService.get
|
||||
return Result.Success().SetData(await _menuService.GetTopMenu());
|
||||
|
||||
return Result.Success().SetData(await _menuService.GetMenuMould());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -74,5 +74,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
await _roleService.SetMenusByRolesId(idsListDto.ids2, idsListDto.ids1);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,5 +97,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
await _userService.SetRolesByUser(idsListDto.ids2, idsListDto.ids1);
|
||||
return Result.Success();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据http上下文的用户得到该用户有哪些角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetRolesByUser()
|
||||
{
|
||||
var _user = HttpContext.GetCurrentUserInfo();
|
||||
var roleList = await _userService.GetRolesByUser(_user);
|
||||
return Result.Success().SetData(roleList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
14
Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs
Normal file
14
Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum ShowFlagEnum
|
||||
{
|
||||
NoShow=0,
|
||||
Show=1
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,6 @@ namespace Yi.Framework.Interface
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetChildrenMenu(menu _menu);
|
||||
|
||||
Task<List<menu>> GetMenuMould();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,6 @@ namespace Yi.Framework.Interface
|
||||
/// <returns></returns>
|
||||
Task<bool> SetMenusByRolesId(List<int> menuIds, List<int> roleIds);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ namespace Yi.Framework.Interface
|
||||
Task<bool> Register(user _user);
|
||||
|
||||
/// <summary>
|
||||
/// 得到该用户拥有哪些角色
|
||||
/// 根据http上下文的用户得到该用户有哪些角色
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<role>> GetRolesByUser(user _user);
|
||||
|
||||
@@ -64,7 +63,7 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="_user"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<List<menu>>> GetMenuByUser(user _user);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@ namespace Yi.Framework.Service
|
||||
return childrenList;
|
||||
}
|
||||
|
||||
public async Task<List<menu>> GetMenuMould()
|
||||
{
|
||||
var menuList= await _Db.Set<menu>().Include(u => u.children).Include(u => u.mould)
|
||||
.Where(u => u.is_delete == (short)Common.Enum.DelFlagEnum.Normal )
|
||||
.ToListAsync();
|
||||
return menuList;
|
||||
}
|
||||
|
||||
public async Task<menu> GetMenuMouldByMenu(menu _menu)
|
||||
{
|
||||
var menu_data = await _Db.Set<menu>().Include(u => u.children).Include(u=>u.mould).Where(u=>u.id==_menu.id).FirstOrDefaultAsync();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Yi.Framework.Service
|
||||
var role_data =await _Db.Set<role>().Include(u => u.menus)
|
||||
.Where(u => u.id == _role.id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
||||
var menuList =role_data.menus.Where(u => u.is_top == (short)Common.Enum.TopFlagEnum.Top && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal)
|
||||
.ToList();
|
||||
.ToList();
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ namespace Yi.Framework.Service
|
||||
foreach (var role in roleList)
|
||||
{
|
||||
var menu= await _roleService.GetMenusByRole(role);
|
||||
menu.ForEach(u => u.roles = null);
|
||||
menuList.Add(menu);
|
||||
}
|
||||
return menuList;
|
||||
|
||||
Reference in New Issue
Block a user