角色添加、角色编辑关联菜单功能
This commit is contained in:
@@ -230,6 +230,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetListByRoleId(System.Int64)">
|
||||
<summary>
|
||||
根据角色id获取该角色下全部菜单
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.RoleController">
|
||||
<summary>
|
||||
角色管理
|
||||
@@ -261,6 +268,12 @@
|
||||
<param name="roleDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.UpdateInfo(Yi.Framework.DTOModel.RoleInfoDto)">
|
||||
<summary>
|
||||
更新角色信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.TestController">
|
||||
<summary>
|
||||
测试控制器
|
||||
|
||||
@@ -61,5 +61,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetMenuTreeAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色下全部菜单
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetListByRoleId(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetListByRoleId(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
@@ -72,5 +73,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService.AddInfo(roleDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateInfo(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.UpdateInfo(roleDto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -10,5 +10,12 @@ namespace Yi.Framework.Interface
|
||||
{
|
||||
Task<List<MenuEntity>> GetMenuTreeAsync();
|
||||
Task<List<MenuEntity>> SelctGetList(MenuEntity menu);
|
||||
|
||||
/// <summary>
|
||||
/// 获取该角色id下的所有菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<MenuEntity>> GetListByRoleId(long roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,5 +44,13 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddInfo(RoleInfoDto roleDto);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色关联菜单
|
||||
/// </summary>
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateInfo(RoleInfoDto roleDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,11 @@ namespace Yi.Framework.Service
|
||||
//复杂查询直接使用db代理
|
||||
return await _repository._Db.Queryable<MenuEntity>().Where(u => u.IsDeleted == false).ToTreeAsync(it => it.Children, it => it.ParentId, 0);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<MenuEntity>> GetListByRoleId(long roleId)
|
||||
{
|
||||
return (await _repository._Db.Queryable<RoleEntity>().Includes(r => r.Menus).SingleAsync(r=>r.Id==roleId)).Menus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,5 +75,13 @@ namespace Yi.Framework.Service
|
||||
var res2 = await GiveRoleSetMenu(new List<long> { res1 }, roleDto.MenuIds);
|
||||
return !0.Equals(res1) && res2;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> UpdateInfo(RoleInfoDto roleDto)
|
||||
{
|
||||
var res1 = await _repository.UpdateIgnoreNullAsync(roleDto.Role);
|
||||
var res2 = await GiveRoleSetMenu(new List<long> { roleDto.Role.Id }, roleDto.MenuIds);
|
||||
return res1 && res2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user