SqlServer and MySql
This commit is contained in:
1 parent
42405492b6
commit
011e60afa9
53 files changed
+3419
-1238
No files matched your search
+96
-32
@@ -14,48 +14,49 @@ namespace CloudBuilder.Security.Entity
|
||||
{
|
||||
}
|
||||
|
||||
[Column("amend_indc")]
|
||||
public string AmendIndc { get; set; }
|
||||
[Column("create_indc")]
|
||||
public string CreateIndc { get; set; }
|
||||
[Column("delete_indc")]
|
||||
public string DeleteIndc { get; set; }
|
||||
[Column("dependent")]
|
||||
public string? Dependent { get; set; }
|
||||
[Column("group_name")]
|
||||
public string GroupName { get; set; }
|
||||
[Column("permission_description")]
|
||||
public string? PermissionDescription { get; set; }
|
||||
[Column("permission_name")]
|
||||
public string PermissionName { get; set; }
|
||||
[Column("view_indc")]
|
||||
public string ViewIndc { get; set; }
|
||||
[Column("create_indc")]
|
||||
public string CreateIndc { get; set; }
|
||||
[Column("amend_indc")]
|
||||
public string AmendIndc { get; set; }
|
||||
[Column("delete_indc")]
|
||||
public string DeleteIndc { get; set; }
|
||||
[Column("dependent")]
|
||||
public string? Dependent { get; set; }
|
||||
[Column("permission_description")]
|
||||
public string? PermissionDescription { get; set; }
|
||||
|
||||
public const string AMEND_INDC = "AmendIndc";
|
||||
public const string CREATE_INDC = "CreateIndc";
|
||||
public const string DELETE_INDC = "DeleteIndc";
|
||||
public const string DEPENDENT = "Dependent";
|
||||
public const string GROUP_NAME = "GroupName";
|
||||
public const string PERMISSION_DESCRIPTION = "PermissionDescription";
|
||||
public const string PERMISSION_NAME = "PermissionName";
|
||||
public const string VIEW_INDC = "ViewIndc";
|
||||
public const string CREATE_INDC = "CreateIndc";
|
||||
public const string AMEND_INDC = "AmendIndc";
|
||||
public const string DELETE_INDC = "DeleteIndc";
|
||||
public const string DEPENDENT = "Dependent";
|
||||
public const string PERMISSION_DESCRIPTION = "PermissionDescription";
|
||||
|
||||
public const string DB_NAME_SECURITY_GROUP_PERMISSION_VIEW = "security_group_permission_view";
|
||||
public const string DB_NAME_FIELDS="amend_indc,create_indc,delete_indc,dependent,group_name,permission_description,permission_name,view_indc";
|
||||
public const string DB_NAME_FIELDS="group_name,permission_name,view_indc,create_indc,amend_indc,delete_indc,dependent,permission_description";
|
||||
|
||||
public const string DB_AMEND_INDC = "amend_indc";
|
||||
public const string DB_CREATE_INDC = "create_indc";
|
||||
public const string DB_DELETE_INDC = "delete_indc";
|
||||
public const string DB_DEPENDENT = "dependent";
|
||||
public const string DB_GROUP_NAME = "group_name";
|
||||
public const string DB_PERMISSION_DESCRIPTION = "permission_description";
|
||||
public const string DB_PERMISSION_NAME = "permission_name";
|
||||
public const string DB_VIEW_INDC = "view_indc";
|
||||
public const string DB_CREATE_INDC = "create_indc";
|
||||
public const string DB_AMEND_INDC = "amend_indc";
|
||||
public const string DB_DELETE_INDC = "delete_indc";
|
||||
public const string DB_DEPENDENT = "dependent";
|
||||
public const string DB_PERMISSION_DESCRIPTION = "permission_description";
|
||||
|
||||
public string ProviderName { get; set; }
|
||||
|
||||
public static SecurityGroupPermissionViewEntity GetInstance()
|
||||
public static SecurityGroupPermissionViewEntity GetInstance(string providerName)
|
||||
{
|
||||
return new SecurityGroupPermissionViewEntity();
|
||||
return new SecurityGroupPermissionViewEntity() { ProviderName = providerName };
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SecurityGroupPermissionViewEntity source)
|
||||
@@ -70,14 +71,14 @@ namespace CloudBuilder.Security.Entity
|
||||
throw new NullReferenceException("Source entity is null.");
|
||||
}
|
||||
|
||||
this.AmendIndc = source.AmendIndc;
|
||||
this.CreateIndc = source.CreateIndc;
|
||||
this.DeleteIndc = source.DeleteIndc;
|
||||
this.Dependent = source.Dependent;
|
||||
this.GroupName = source.GroupName;
|
||||
this.PermissionDescription = source.PermissionDescription;
|
||||
this.PermissionName = source.PermissionName;
|
||||
this.ViewIndc = source.ViewIndc;
|
||||
this.CreateIndc = source.CreateIndc;
|
||||
this.AmendIndc = source.AmendIndc;
|
||||
this.DeleteIndc = source.DeleteIndc;
|
||||
this.Dependent = source.Dependent;
|
||||
this.PermissionDescription = source.PermissionDescription;
|
||||
|
||||
if (includeSystemFields)
|
||||
{
|
||||
@@ -85,23 +86,86 @@ 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_GROUP_PERMISSION_VIEW} with(nolock) ";
|
||||
}
|
||||
public string GetSelectFromByBySqlServer()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from { DB_NAME_SECURITY_GROUP_PERMISSION_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_GROUP_PERMISSION_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_GROUP_PERMISSION_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";
|
||||
|
||||
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_AMEND_INDC ; int offset = limit * (start - 1);
|
||||
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GROUP_NAME ; int offset = limit * (start - 1);
|
||||
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_SECURITY_GROUP_PERMISSION_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_GROUP_NAME ; 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_GROUP_PERMISSION_VIEW} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
|
||||
}
|
||||
|
||||
public SecurityGroupPermissionViewEntity Clone()
|
||||
{
|
||||
SecurityGroupPermissionViewEntity result = new SecurityGroupPermissionViewEntity();
|
||||
|
||||
Reference in new issue
Block a user