|
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Transactions;
|
|
|
using AutoMapper;
|
|
|
+using GxPress.Request.Menu;
|
|
|
|
|
|
namespace GxPress.Service.Implement.Role
|
|
|
{
|
|
@@ -18,13 +19,13 @@ namespace GxPress.Service.Implement.Role
|
|
|
|
|
|
private readonly ISystemRoleRepository systemRoleRepository;
|
|
|
|
|
|
- private readonly IMapper _mapper;
|
|
|
- public RoleService(ISystemRoleMenusRepository systemRoleMenusRepository, IMenusRepository menusRepository, ISystemRoleRepository systemRoleRepository,IMapper _mapper)
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ public RoleService(ISystemRoleMenusRepository systemRoleMenusRepository, IMenusRepository menusRepository, ISystemRoleRepository systemRoleRepository, IMapper _mapper)
|
|
|
{
|
|
|
this.systemRoleRepository = systemRoleRepository;
|
|
|
this.systemRoleMenusRepository = systemRoleMenusRepository;
|
|
|
this.menusRepository = menusRepository;
|
|
|
- this._mapper=_mapper;
|
|
|
+ this._mapper = _mapper;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加权限菜单关联
|
|
@@ -78,7 +79,7 @@ namespace GxPress.Service.Implement.Role
|
|
|
/// </summary>
|
|
|
/// <param name="models"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<bool> InsertMenusAsync(List<Entity.Menus.Menus> models)
|
|
|
+ public async Task<bool> InsertMenusAsync(List<MenuInRequest> models)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -86,12 +87,28 @@ namespace GxPress.Service.Implement.Role
|
|
|
{
|
|
|
foreach (var item in models)
|
|
|
{
|
|
|
- var id = await menusRepository.InsertAsync(item);
|
|
|
+ var menuEntity = new Entity.Menus.Menus()
|
|
|
+ {
|
|
|
+ Icon = item.Icon,
|
|
|
+ Name = item.Name,
|
|
|
+ ParentId = item.ParentId,
|
|
|
+ Path = item.Path,
|
|
|
+ Title = item.Title
|
|
|
+ };
|
|
|
+ var id = await menusRepository.InsertAsync(menuEntity);
|
|
|
if (item.Children == null)
|
|
|
continue;
|
|
|
foreach (var menu in item.Children)
|
|
|
{
|
|
|
- await menusRepository.InsertAsync(_mapper.Map<Entity.Menus.Menus>(menu));
|
|
|
+ menuEntity = new Entity.Menus.Menus()
|
|
|
+ {
|
|
|
+ Icon = item.Icon,
|
|
|
+ Name = item.Name,
|
|
|
+ ParentId = id,
|
|
|
+ Path = item.Path,
|
|
|
+ Title = item.Title
|
|
|
+ };
|
|
|
+ await menusRepository.InsertAsync(menuEntity);
|
|
|
}
|
|
|
}
|
|
|
transactionScope.Complete();
|