SqlServer and MySql
This commit is contained in:
1 parent
42405492b6
commit
011e60afa9
53 files changed
+3419
-1238
No files matched your search
@@ -16,38 +16,39 @@ namespace CloudBuilder.Security.Entity
|
||||
|
||||
[Column("orderby")]
|
||||
public int Orderby { get; set; }
|
||||
[Column("parent_function_local_name")]
|
||||
public string? ParentFunctionLocalName { get; set; }
|
||||
[Column("parent_function_name")]
|
||||
public string ParentFunctionName { get; set; }
|
||||
[Column("son_function_local_name")]
|
||||
public string? SonFunctionLocalName { get; set; }
|
||||
[Column("parent_function_local_name")]
|
||||
public string? ParentFunctionLocalName { get; set; }
|
||||
[Column("son_function_name")]
|
||||
public string SonFunctionName { get; set; }
|
||||
[Column("son_function_local_name")]
|
||||
public string? SonFunctionLocalName { get; set; }
|
||||
[Column("son_page_name")]
|
||||
public string? SonPageName { get; set; }
|
||||
|
||||
public const string ORDERBY = "Orderby";
|
||||
public const string PARENT_FUNCTION_LOCAL_NAME = "ParentFunctionLocalName";
|
||||
public const string PARENT_FUNCTION_NAME = "ParentFunctionName";
|
||||
public const string SON_FUNCTION_LOCAL_NAME = "SonFunctionLocalName";
|
||||
public const string PARENT_FUNCTION_LOCAL_NAME = "ParentFunctionLocalName";
|
||||
public const string SON_FUNCTION_NAME = "SonFunctionName";
|
||||
public const string SON_FUNCTION_LOCAL_NAME = "SonFunctionLocalName";
|
||||
public const string SON_PAGE_NAME = "SonPageName";
|
||||
|
||||
public const string DB_NAME_SECURITY_FUNCTION_MAP_VIEW = "security_function_map_view";
|
||||
public const string DB_NAME_FIELDS="orderby,parent_function_local_name,parent_function_name,son_function_local_name,son_function_name,son_page_name";
|
||||
public const string DB_NAME_FIELDS="orderby,parent_function_name,parent_function_local_name,son_function_name,son_function_local_name,son_page_name";
|
||||
|
||||
public const string DB_ORDERBY = "orderby";
|
||||
public const string DB_PARENT_FUNCTION_LOCAL_NAME = "parent_function_local_name";
|
||||
public const string DB_PARENT_FUNCTION_NAME = "parent_function_name";
|
||||
public const string DB_SON_FUNCTION_LOCAL_NAME = "son_function_local_name";
|
||||
public const string DB_PARENT_FUNCTION_LOCAL_NAME = "parent_function_local_name";
|
||||
public const string DB_SON_FUNCTION_NAME = "son_function_name";
|
||||
public const string DB_SON_FUNCTION_LOCAL_NAME = "son_function_local_name";
|
||||
public const string DB_SON_PAGE_NAME = "son_page_name";
|
||||
|
||||
public string ProviderName { get; set; }
|
||||
|
||||
public static SecurityFunctionMapViewEntity GetInstance()
|
||||
public static SecurityFunctionMapViewEntity GetInstance(string providerName)
|
||||
{
|
||||
return new SecurityFunctionMapViewEntity();
|
||||
return new SecurityFunctionMapViewEntity() { ProviderName = providerName };
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SecurityFunctionMapViewEntity source)
|
||||
@@ -63,10 +64,10 @@ namespace CloudBuilder.Security.Entity
|
||||
}
|
||||
|
||||
this.Orderby = source.Orderby;
|
||||
this.ParentFunctionLocalName = source.ParentFunctionLocalName;
|
||||
this.ParentFunctionName = source.ParentFunctionName;
|
||||
this.SonFunctionLocalName = source.SonFunctionLocalName;
|
||||
this.ParentFunctionLocalName = source.ParentFunctionLocalName;
|
||||
this.SonFunctionName = source.SonFunctionName;
|
||||
this.SonFunctionLocalName = source.SonFunctionLocalName;
|
||||
this.SonPageName = source.SonPageName;
|
||||
|
||||
if (includeSystemFields)
|
||||
@@ -75,16 +76,71 @@ namespace CloudBuilder.Security.Entity
|
||||
}
|
||||
|
||||
public override string GetSelectFrom()
|
||||
{
|
||||
if (ProviderName.Contains("MySql"))
|
||||
{
|
||||
return GetSelectFromByMySql();
|
||||
}
|
||||
else if (ProviderName.Contains("SqlServer"))
|
||||
{
|
||||
return GetSelectFromByBySqlServer();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
|
||||
}
|
||||
}
|
||||
public string GetSelectFromByMySql()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} with(nolock) ";
|
||||
}
|
||||
public string GetSelectFromByBySqlServer()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} ";
|
||||
}
|
||||
|
||||
|
||||
public override string GetSelectCountFrom(string sqlWhere)
|
||||
{
|
||||
if (ProviderName.Contains("MySql"))
|
||||
{
|
||||
return GetSelectCountFromByMySql(sqlWhere);
|
||||
}
|
||||
else if (ProviderName.Contains("SqlServer"))
|
||||
{
|
||||
return GetSelectCountFromBySqlServer(sqlWhere);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSelectCountFromByMySql(string sqlWhere)
|
||||
{
|
||||
return $" select count(*) from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} where 1=1 {sqlWhere}";
|
||||
}
|
||||
|
||||
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
|
||||
public string GetSelectCountFromBySqlServer(string sqlWhere)
|
||||
{
|
||||
return $" select count(*) from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} with(nolock) where 1=1 {sqlWhere}";
|
||||
}
|
||||
|
||||
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
|
||||
{
|
||||
if (ProviderName.Contains("MySql"))
|
||||
{
|
||||
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
|
||||
}
|
||||
else if (ProviderName.Contains("SqlServer"))
|
||||
{
|
||||
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
|
||||
{
|
||||
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
|
||||
|
||||
@@ -92,6 +148,14 @@ namespace CloudBuilder.Security.Entity
|
||||
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {offset},{limit} ";
|
||||
}
|
||||
|
||||
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
|
||||
{
|
||||
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
|
||||
|
||||
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_ORDERBY ; string top = limit > 0 ? $"top {limit}" : "";
|
||||
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_SECURITY_FUNCTION_MAP_VIEW} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
|
||||
}
|
||||
|
||||
public SecurityFunctionMapViewEntity Clone()
|
||||
{
|
||||
SecurityFunctionMapViewEntity result = new SecurityFunctionMapViewEntity();
|
||||
|
||||
Reference in new issue
Block a user