update:角色授权组织数据同时可以授权区域数据
This commit is contained in:
@@ -83,5 +83,9 @@ namespace Ewide.Core.Service
|
||||
public class GrantRoleDataInput : GrantRoleMenuInput
|
||||
{
|
||||
|
||||
}
|
||||
public class GrantAreaDataInput : GrantRoleMenuInput
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace Ewide.Core.Service.Role
|
||||
Task DeleteRoleAreaListByAreaCodeList(List<string> areaCodeList);
|
||||
Task DeleteRoleAreaListByRoleId(string roleId);
|
||||
Task<List<string>> GetRoleAreaCodeList(List<string> roleIdList);
|
||||
Task GrantArea(UpdateRoleInput input);
|
||||
Task GrantArea(GrantAreaDataInput input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Ewide.Core.Service.Role
|
||||
|
||||
}
|
||||
|
||||
public async Task GrantArea(UpdateRoleInput input)
|
||||
public async Task GrantArea(GrantAreaDataInput input)
|
||||
{
|
||||
var dataScopes = await _sysRoleAreaRep.Where(u => u.SysRoleId == input.Id).ToListAsync();
|
||||
dataScopes.ForEach(u =>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Furion.DatabaseAccessor;
|
||||
using Ewide.Core.Service.Role;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DatabaseAccessor.Extensions;
|
||||
using Furion.DependencyInjection;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,10 +16,11 @@ namespace Ewide.Core.Service
|
||||
public class SysRoleDataScopeService : ISysRoleDataScopeService, ITransient
|
||||
{
|
||||
private readonly IRepository<SysRoleDataScope> _sysRoleDataScopeRep; // 角色数据范围表仓储
|
||||
|
||||
public SysRoleDataScopeService(IRepository<SysRoleDataScope> sysRoleDataScopeRep)
|
||||
private readonly ISysRoleAreaService _sysRoleAreaService;
|
||||
public SysRoleDataScopeService(IRepository<SysRoleDataScope> sysRoleDataScopeRep, ISysRoleAreaService sysRoleAreaService)
|
||||
{
|
||||
_sysRoleDataScopeRep = sysRoleDataScopeRep;
|
||||
_sysRoleAreaService = sysRoleAreaService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,6 +31,11 @@ namespace Ewide.Core.Service
|
||||
[UnitOfWork]
|
||||
public async Task GrantDataScope(GrantRoleDataInput input)
|
||||
{
|
||||
if (new[] { (int)DataScopeType.AREA, (int)DataScopeType.AREA_WITH_CHILD }.Contains(input.DataScopeType))
|
||||
{
|
||||
await _sysRoleAreaService.GrantArea(input.Adapt<GrantAreaDataInput>());
|
||||
return;
|
||||
}
|
||||
var dataScopes = await _sysRoleDataScopeRep.DetachedEntities.Where(u => u.SysRoleId == input.Id).ToListAsync();
|
||||
dataScopes.ForEach(u =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user