feat:完成后端数据权限过滤

This commit is contained in:
陈淳
2023-05-22 12:57:27 +08:00
parent ad6bd8f39b
commit 327a7b2a48
14 changed files with 167 additions and 15 deletions

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Yi.Furion.Core.Rbac.Entities;
namespace Yi.Furion.Sqlsugar.Core.Repositories
{
public interface IDeptRepository
{
Task<List<long>> GetChildListAsync(long deptId);
Task<List<DeptEntity>> GetListRoleIdAsync([FromRoute] long roleId);
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.DependencyInjection;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Yi.Framework.Infrastructure.Sqlsugar.Repositories;
using Yi.Furion.Core.Bbs.Entities;
using Yi.Furion.Core.Rbac.Dtos.Dept;
using Yi.Furion.Core.Rbac.Entities;
namespace Yi.Furion.Sqlsugar.Core.Repositories.Impl
{
public class DeptRepository : SqlsugarRepository<DeptEntity>, IDeptRepository, ITransient
{
public DeptRepository(ISqlSugarClient context) : base(context)
{
}
public async Task<List<long>> GetChildListAsync(long deptId)
{
var entities = await _DbQueryable.ToChildListAsync(x => x.ParentId, deptId);
return entities.Select(x => x.Id).ToList();
}
public async Task<List<DeptEntity>> GetListRoleIdAsync([FromRoute] long roleId)
{
return await _DbQueryable.Where(d => SqlFunc.Subqueryable<RoleDeptEntity>().Where(rd => rd.RoleId == roleId && d.Id == rd.DeptId).Any()).ToListAsync();
}
}
}