42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using SqlSugar;
|
||
using System.Collections.Generic;
|
||
using VolPro.Core.ManageUser;
|
||
using VolPro.Entity.DomainModels;
|
||
|
||
namespace VolPro.Core.Tenancy
|
||
{
|
||
public static class TenancySqlManager
|
||
{
|
||
|
||
/// <summary>
|
||
/// 自定义主表查询
|
||
/// </summary>
|
||
/// <param name="tableName">查询的表名</param>
|
||
/// <param name="selectSql">查询的sql(框架生成的,可以直接用也可以单独写)</param>
|
||
/// <param name="filters">查询条件</param>
|
||
/// <returns></returns>
|
||
public static string GetSearchSqlQuery(this string tableName, string selectSql, List<SearchParameters> filters, List<SugarParameter> parameters)
|
||
{
|
||
//超级管理员不限制(这里可以根据tableName表名自己判断要不要限制超级管理员)
|
||
if (UserContext.Current.IsSuperAdmin)
|
||
{
|
||
return null;
|
||
}
|
||
switch (tableName.ToLower())
|
||
{
|
||
//根据不同的表名设置不同的查询,查询条件在filters中
|
||
case "sys_user":
|
||
/* 重新生杨sql
|
||
* selectSql = $"select * from {tableName} where xx=@xx";
|
||
* 添加自定义参数
|
||
* parameters.Add("@xx", "value");
|
||
*/
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return selectSql;
|
||
}
|
||
}
|
||
}
|