feat:完成后端数据权限过滤
This commit is contained in:
@@ -76,6 +76,10 @@ namespace Yi.Furion.Application.Rbac.Domain
|
||||
var claims = new Dictionary<string, object>();
|
||||
claims.Add(TokenTypeConst.Id, dto.User.Id);
|
||||
claims.Add(TokenTypeConst.UserName, dto.User.UserName);
|
||||
if (dto.User.DeptId is not null)
|
||||
{
|
||||
claims.Add(TokenTypeConst.DeptId, dto.User.DeptId);
|
||||
}
|
||||
if (dto.User.Email is not null)
|
||||
{
|
||||
claims.Add(TokenTypeConst.Email, dto.User.Email);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Furion.Core.Rbac.Dtos;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services
|
||||
{
|
||||
public interface IAccountService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,6 @@ namespace Yi.Furion.Application.Rbac.Services
|
||||
public interface IDeptService : ICrudAppService<DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>
|
||||
{
|
||||
Task<List<long>> GetChildListAsync(long deptId);
|
||||
Task<List<DeptGetListOutputDto>> GetListRoleIdAsync([FromRoute] long roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using Yi.Furion.Sqlsugar.Core.Repositories;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
public class AccountService : ApplicationService, ITransient, IDynamicApiController
|
||||
public class AccountService : ApplicationService, IAccountService, ITransient, IDynamicApiController
|
||||
{
|
||||
|
||||
public AccountService(IUserRepository userRepository, ICurrentUser currentUser, AccountManager accountManager, IRepository<MenuEntity> menuRepository, SmsAliyunManager smsAliyunManager, IOptions<SmsAliyunOptions> smsAliyunManagerOptions, SecurityCodeHelper securityCode, IMemoryCache memoryCache, IEventPublisher eventPublisher, IHttpContextAccessor httpContextAccessor) =>
|
||||
|
||||
@@ -3,6 +3,7 @@ using Yi.Framework.Infrastructure.Ddd.Dtos;
|
||||
using Yi.Framework.Infrastructure.Ddd.Services;
|
||||
using Yi.Furion.Core.Rbac.Dtos.Dept;
|
||||
using Yi.Furion.Core.Rbac.Entities;
|
||||
using Yi.Furion.Sqlsugar.Core.Repositories;
|
||||
|
||||
namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
{
|
||||
@@ -12,11 +13,12 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
public class DeptService : CrudAppService<DeptEntity, DeptGetOutputDto, DeptGetListOutputDto, long, DeptGetListInputVo, DeptCreateInputVo, DeptUpdateInputVo>,
|
||||
IDeptService, ITransient, IDynamicApiController
|
||||
{
|
||||
private IDeptRepository _deptRepository;
|
||||
public DeptService(IDeptRepository deptRepository) { _deptRepository = deptRepository; }
|
||||
[NonAction]
|
||||
public async Task<List<long>> GetChildListAsync(long deptId)
|
||||
{
|
||||
var entities= await _DbQueryable.ToChildListAsync(x=>x.ParentId,deptId);
|
||||
return entities.Select(x => x.Id).ToList();
|
||||
return await _deptRepository.GetChildListAsync(deptId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +28,7 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
//[Route("{roleId}")]
|
||||
public async Task<List<DeptGetListOutputDto>> GetListRoleIdAsync([FromRoute] long roleId)
|
||||
{
|
||||
var entities = await _DbQueryable.Where(d => SqlFunc.Subqueryable<RoleDeptEntity>().Where(rd => rd.RoleId == roleId && d.Id == rd.DeptId).Any()).ToListAsync();
|
||||
var entities = await _deptRepository.GetListRoleIdAsync(roleId);
|
||||
return await MapToGetListOutputDtosAsync(entities);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,6 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
|
||||
private IRepository<RoleDeptEntity> _roleDeptRepository;
|
||||
|
||||
|
||||
public async Task<List<long>> GetDeptIdsAsync(long roleId)
|
||||
{
|
||||
var entities = await _roleDeptRepository.GetListAsync(x => x.RoleId == roleId);
|
||||
return entities.Select(x => x.DeptId).ToList();
|
||||
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public async Task UpdateDataScpoceAsync(UpdateDataScpoceInput input)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user