This commit is contained in:
@@ -54,7 +54,7 @@ namespace Dilon.Core.Service
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessageResourceName = "角色Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateRoleInput : AddRoleInput
|
||||
@@ -63,7 +63,7 @@ namespace Dilon.Core.Service
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessageResourceName = "角色Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
public class QueryRoleInput : DeleteRoleInput
|
||||
@@ -77,7 +77,7 @@ namespace Dilon.Core.Service
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessageResourceName = "角色Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
public class GrantRoleDataInput : GrantRoleMenuInput
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Dilon.Core.Service
|
||||
{
|
||||
public interface ISysRoleDataScopeService
|
||||
{
|
||||
Task DeleteRoleDataScopeListByOrgIdList(List<long> orgIdList);
|
||||
Task DeleteRoleDataScopeListByRoleId(long roleId);
|
||||
Task<List<long>> GetRoleDataScopeIdList(List<long> roleIdList);
|
||||
Task DeleteRoleDataScopeListByOrgIdList(List<string> orgIdList);
|
||||
Task DeleteRoleDataScopeListByRoleId(string roleId);
|
||||
Task<List<string>> GetRoleDataScopeIdList(List<string> roleIdList);
|
||||
Task GrantDataScope(GrantRoleDataInput input);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ namespace Dilon.Core.Service
|
||||
{
|
||||
public interface ISysRoleMenuService
|
||||
{
|
||||
Task DeleteRoleMenuListByMenuIdList(List<long> menuIdList);
|
||||
Task DeleteRoleMenuListByRoleId(long roleId);
|
||||
Task<List<long>> GetRoleMenuIdList(List<long> roleIdList);
|
||||
Task DeleteRoleMenuListByMenuIdList(List<string> menuIdList);
|
||||
Task DeleteRoleMenuListByRoleId(string roleId);
|
||||
Task<List<string>> GetRoleMenuIdList(List<string> roleIdList);
|
||||
Task GrantMenu(GrantRoleMenuInput input);
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,16 @@ namespace Dilon.Core.Service
|
||||
{
|
||||
Task AddRole(AddRoleInput input);
|
||||
Task DeleteRole(DeleteRoleInput input);
|
||||
Task<string> GetNameByRoleId(long roleId);
|
||||
Task<string> GetNameByRoleId(string roleId);
|
||||
Task<dynamic> GetRoleDropDown();
|
||||
Task<SysRole> GetRoleInfo([FromQuery] QueryRoleInput input);
|
||||
Task<dynamic> GetRoleList([FromQuery] RoleInput input);
|
||||
Task<List<long>> GetUserDataScopeIdList(List<long> roleIdList, long orgId);
|
||||
Task<List<RoleOutput>> GetUserRoleList(long userId);
|
||||
Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId);
|
||||
Task<List<RoleOutput>> GetUserRoleList(string userId);
|
||||
Task GrantData(GrantRoleDataInput input);
|
||||
Task GrantMenu(GrantRoleMenuInput input);
|
||||
Task<List<long>> OwnData([FromQuery] QueryRoleInput input);
|
||||
Task<List<long>> OwnMenu([FromQuery] QueryRoleInput input);
|
||||
Task<List<string>> OwnData([FromQuery] QueryRoleInput input);
|
||||
Task<List<string>> OwnMenu([FromQuery] QueryRoleInput input);
|
||||
Task<dynamic> QueryRolePageList([FromQuery] RoleInput input);
|
||||
Task UpdateRole(UpdateRoleInput input);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="roleIdList"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<long>> GetRoleDataScopeIdList(List<long> roleIdList)
|
||||
public async Task<List<string>> GetRoleDataScopeIdList(List<string> roleIdList)
|
||||
{
|
||||
return await _sysRoleDataScopeRep.DetachedEntities
|
||||
.Where(u => roleIdList.Contains(u.SysRoleId))
|
||||
@@ -61,7 +61,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="orgIdList"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteRoleDataScopeListByOrgIdList(List<long> orgIdList)
|
||||
public async Task DeleteRoleDataScopeListByOrgIdList(List<string> orgIdList)
|
||||
{
|
||||
var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => orgIdList.Contains(u.SysOrgId)).ToListAsync();
|
||||
dataScopes.ForEach(u =>
|
||||
@@ -75,7 +75,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteRoleDataScopeListByRoleId(long roleId)
|
||||
public async Task DeleteRoleDataScopeListByRoleId(string roleId)
|
||||
{
|
||||
var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => u.SysRoleId == roleId).ToListAsync();
|
||||
dataScopes.ForEach(u =>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="roleIdList"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<long>> GetRoleMenuIdList(List<long> roleIdList)
|
||||
public async Task<List<string>> GetRoleMenuIdList(List<string> roleIdList)
|
||||
{
|
||||
return await _sysRoleMenuRep.DetachedEntities
|
||||
.Where(u => roleIdList.Contains(u.SysRoleId))
|
||||
@@ -67,7 +67,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="menuIdList"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteRoleMenuListByMenuIdList(List<long> menuIdList)
|
||||
public async Task DeleteRoleMenuListByMenuIdList(List<string> menuIdList)
|
||||
{
|
||||
var roleMenus = await _sysRoleMenuRep.DetachedEntities.Where(u => menuIdList.Contains(u.SysMenuId)).ToListAsync();
|
||||
roleMenus.ForEach(u =>
|
||||
@@ -81,7 +81,7 @@ namespace Dilon.Core.Service
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteRoleMenuListByRoleId(long roleId)
|
||||
public async Task DeleteRoleMenuListByRoleId(string roleId)
|
||||
{
|
||||
var roleMenus = await _sysRoleMenuRep.DetachedEntities.Where(u => u.SysRoleId == roleId).ToListAsync();
|
||||
roleMenus.ForEach(u =>
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Dilon.Core.Service
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<List<RoleOutput>> GetUserRoleList(long userId)
|
||||
public async Task<List<RoleOutput>> GetUserRoleList(string userId)
|
||||
{
|
||||
return await _sysRoleRep.DetachedEntities.Join(_sysUserRoleRep.DetachedEntities, u => u.Id, e => e.SysRoleId, (u, e) => new { u, e })
|
||||
.Where(x => x.e.SysUserId == userId)
|
||||
@@ -103,7 +103,7 @@ namespace Dilon.Core.Service
|
||||
// 如果不是超级管理员,则查询自己拥有的角色集合
|
||||
var roles = _userManager.SuperAdmin
|
||||
? await _sysUserRoleRep.Where(u => u.SysUserId == _userManager.UserId).Select(u => u.SysRoleId).ToListAsync()
|
||||
: new List<long>();
|
||||
: new List<string>();
|
||||
|
||||
return await _sysRoleRep.DetachedEntities
|
||||
.Where(roles.Count > 0, u => roles.Contains(u.Id))
|
||||
@@ -239,12 +239,12 @@ namespace Dilon.Core.Service
|
||||
/// <param name="orgId"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<List<long>> GetUserDataScopeIdList(List<long> roleIdList, long orgId)
|
||||
public async Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId)
|
||||
{
|
||||
// 定义角色中最大数据范围的类型,目前按最大范围策略来,如果你同时拥有ALL和SELF的权限,最后按ALL返回
|
||||
int strongerDataScopeType = (int)DataScopeType.SELF;
|
||||
|
||||
var customDataScopeRoleIdList = new List<long>();
|
||||
var customDataScopeRoleIdList = new List<string>();
|
||||
if (roleIdList != null && roleIdList.Count > 0)
|
||||
{
|
||||
var roles = await _sysRoleRep.DetachedEntities.Where(u => roleIdList.Contains(u.Id)).ToListAsync();
|
||||
@@ -272,7 +272,7 @@ namespace Dilon.Core.Service
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<string> GetNameByRoleId(long roleId)
|
||||
public async Task<string> GetNameByRoleId(string roleId)
|
||||
{
|
||||
var role = await _sysRoleRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == roleId);
|
||||
if (role == null)
|
||||
@@ -286,9 +286,9 @@ namespace Dilon.Core.Service
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/sysRole/ownMenu")]
|
||||
public async Task<List<long>> OwnMenu([FromQuery] QueryRoleInput input)
|
||||
public async Task<List<string>> OwnMenu([FromQuery] QueryRoleInput input)
|
||||
{
|
||||
return await _sysRoleMenuService.GetRoleMenuIdList(new List<long> { input.Id });
|
||||
return await _sysRoleMenuService.GetRoleMenuIdList(new List<string> { input.Id });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -297,9 +297,9 @@ namespace Dilon.Core.Service
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/sysRole/ownData")]
|
||||
public async Task<List<long>> OwnData([FromQuery] QueryRoleInput input)
|
||||
public async Task<List<string>> OwnData([FromQuery] QueryRoleInput input)
|
||||
{
|
||||
return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List<long> { input.Id });
|
||||
return await _sysRoleDataScopeService.GetRoleDataScopeIdList(new List<string> { input.Id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user