⚡ 优化功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Infrastructure;
|
||||
using SqlSugar.IOC;
|
||||
using ZR.Model.Business;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.ServiceCore.SqlSugar
|
||||
@@ -85,35 +86,5 @@ namespace ZR.ServiceCore.SqlSugar
|
||||
db.QueryFilter.AddTableFilter(expRole.ToExpression());
|
||||
db.QueryFilter.AddTableFilter(expLoginlog.ToExpression());
|
||||
}
|
||||
|
||||
public static void FilterData1(int configId)
|
||||
{
|
||||
//获取当前用户的信息
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
if (user == null) return;
|
||||
var db = DbScoped.SugarScope.GetConnectionScope(configId);
|
||||
|
||||
foreach (var role in user.Roles.OrderBy(f => f.DataScope))
|
||||
{
|
||||
var dataScope = (DataPermiEnum)role.DataScope;
|
||||
if (DataPermiEnum.All.Equals(dataScope))//所有权限
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (DataPermiEnum.CUSTOM.Equals(dataScope))//自定数据权限
|
||||
{
|
||||
}
|
||||
else if (DataPermiEnum.DEPT.Equals(dataScope))//本部门数据
|
||||
{
|
||||
}
|
||||
else if (DataPermiEnum.DEPT_CHILD.Equals(dataScope))//本部门及以下数据
|
||||
{
|
||||
|
||||
}
|
||||
else if (DataPermiEnum.SELF.Equals(dataScope))//仅本人数据
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Infrastructure;
|
||||
using SqlSugar.IOC;
|
||||
using ZR.ServiceCore.SqlSugar;
|
||||
|
||||
namespace ZR.ServiceCore
|
||||
{
|
||||
public class DataPermiSevice
|
||||
{
|
||||
/// <summary>
|
||||
/// 你的业务库数据权限过滤方法
|
||||
/// </summary>
|
||||
/// <param name="configId"></param>
|
||||
public static void FilterData(int configId)
|
||||
{
|
||||
//获取当前用户的信息
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
if (user == null) return;
|
||||
var db = DbScoped.SugarScope.GetConnectionScope(configId);
|
||||
|
||||
foreach (var role in user.Roles.OrderBy(f => f.DataScope))
|
||||
{
|
||||
var dataScope = (DataPermiEnum)role.DataScope;
|
||||
if (DataPermiEnum.All.Equals(dataScope))//所有权限
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (DataPermiEnum.CUSTOM.Equals(dataScope))//自定数据权限
|
||||
{
|
||||
}
|
||||
else if (DataPermiEnum.DEPT.Equals(dataScope))//本部门数据
|
||||
{
|
||||
}
|
||||
else if (DataPermiEnum.DEPT_CHILD.Equals(dataScope))//本部门及以下数据
|
||||
{
|
||||
|
||||
}
|
||||
else if (DataPermiEnum.SELF.Equals(dataScope))//仅本人数据
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace ZR.ServiceCore.SqlSugar
|
||||
{
|
||||
DataPermi.FilterData(0);
|
||||
//ConfigId = 1的数据权限过滤
|
||||
//DataPermi.FilterData1(1);
|
||||
//DataPermiSevice.FilterData(1);
|
||||
}
|
||||
|
||||
iocList.ForEach(iocConfig =>
|
||||
|
||||
Reference in New Issue
Block a user