|
@@ -10,6 +10,7 @@ using System.Transactions;
|
|
|
using AutoMapper;
|
|
|
using GxPress.Request.Menu;
|
|
|
using System.Transactions;
|
|
|
+using GxPress.Result.SystemRole;
|
|
|
|
|
|
namespace GxPress.Service.Implement.Role
|
|
|
{
|
|
@@ -66,9 +67,27 @@ namespace GxPress.Service.Implement.Role
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public async Task<IEnumerable<Entity.SystemRole.SystemRole>> GetSystemRoleAllAsync()
|
|
|
+ public async Task<List<SystemRoleResult>> GetSystemRoleAllAsync()
|
|
|
{
|
|
|
- return await systemRoleRepository.GetSystemRolesAllAsync();
|
|
|
+ var result = new List<SystemRoleResult>();
|
|
|
+ var systemRoles = await systemRoleRepository.GetSystemRolesAllAsync();
|
|
|
+ foreach (var systemRole in systemRoles)
|
|
|
+ {
|
|
|
+ var models = await systemRoleMenusRepository.GetAllAsync(systemRole.Id);
|
|
|
+ var item = await menusRepository.GetAllAsync(models.Select(n => n.MenuId).ToList());
|
|
|
+ var systemRoleResult = new SystemRoleResult();
|
|
|
+ systemRoleResult.SystemRole = systemRole;
|
|
|
+ var menuInRequest = new List<MenuInResult>();
|
|
|
+ var model = item.Where(n => n.ParentId == 0).Select(n => _mapper.Map<MenuInResult>(n)).ToList();
|
|
|
+ foreach (var request in model)
|
|
|
+ {
|
|
|
+ request.Children = item.Where(n => n.ParentId == request.Id).Select(n => _mapper.Map<MenuInResult>(n)).ToList();
|
|
|
+ }
|
|
|
+ systemRoleResult.MenuInResult = model;
|
|
|
+ result.Add(systemRoleResult);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 修改权限
|
|
@@ -104,6 +123,7 @@ namespace GxPress.Service.Implement.Role
|
|
|
/// <returns></returns>
|
|
|
public async Task<bool> DeleteSystemRoleAsync(int id)
|
|
|
{
|
|
|
+ await systemRoleMenusRepository.DeleteAsync(id);
|
|
|
return await systemRoleRepository.DeleteAsync(id);
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -194,7 +214,7 @@ namespace GxPress.Service.Implement.Role
|
|
|
result = item.Where(n => n.ParentId == 0).Select(n => _mapper.Map<MenuInRequest>(n)).ToList();
|
|
|
foreach (var request in result)
|
|
|
{
|
|
|
- request.Children=item.Where(n => n.ParentId == request.Id).Select(n => _mapper.Map<MenuInRequest>(n)).ToList();
|
|
|
+ request.Children = item.Where(n => n.ParentId == request.Id).Select(n => _mapper.Map<MenuInRequest>(n)).ToList();
|
|
|
}
|
|
|
return result;
|
|
|
}
|