105 lines
3.4 KiB
C#
105 lines
3.4 KiB
C#
|
|
using CloudBuilder.Core.Authorization;
|
|
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
namespace CloudBuilder.Security.Entity
|
|
{
|
|
[TypeScript]
|
|
[Table("sys_table_pkey_view")]
|
|
public class SysTablePkeyViewEntity : ViewEntityBase
|
|
{
|
|
|
|
public SysTablePkeyViewEntity()
|
|
{
|
|
}
|
|
|
|
[Column("column_name")]
|
|
public string? ColumnName { get; set; }
|
|
[Column("pk")]
|
|
public int Pk { get; set; }
|
|
[Column("pk_name")]
|
|
public string? PkName { get; set; }
|
|
[Column("table_name")]
|
|
public string TableName { get; set; }
|
|
[Column("table_owner")]
|
|
public string TableOwner { get; set; }
|
|
[Column("table_qualifier")]
|
|
public string? TableQualifier { get; set; }
|
|
|
|
public const string COLUMN_NAME = "ColumnName";
|
|
public const string PK = "Pk";
|
|
public const string PK_NAME = "PkName";
|
|
public const string TABLE_NAME = "TableName";
|
|
public const string TABLE_OWNER = "TableOwner";
|
|
public const string TABLE_QUALIFIER = "TableQualifier";
|
|
|
|
public const string DB_NAME_SYS_TABLE_PKEY_VIEW = "sys_table_pkey_view";
|
|
public const string DB_NAME_FIELDS="column_name,pk,pk_name,table_name,table_owner,table_qualifier";
|
|
|
|
public const string DB_COLUMN_NAME = "column_name";
|
|
public const string DB_PK = "pk";
|
|
public const string DB_PK_NAME = "pk_name";
|
|
public const string DB_TABLE_NAME = "table_name";
|
|
public const string DB_TABLE_OWNER = "table_owner";
|
|
public const string DB_TABLE_QUALIFIER = "table_qualifier";
|
|
|
|
|
|
public static SysTablePkeyViewEntity GetInstance()
|
|
{
|
|
return new SysTablePkeyViewEntity();
|
|
}
|
|
|
|
public virtual void CopyFrom(SysTablePkeyViewEntity source)
|
|
{
|
|
CopyFrom(source, true);
|
|
}
|
|
|
|
public virtual void CopyFrom(SysTablePkeyViewEntity source, bool includeSystemFields)
|
|
{
|
|
if (source == null)
|
|
{
|
|
throw new NullReferenceException("Source entity is null.");
|
|
}
|
|
|
|
this.ColumnName = source.ColumnName;
|
|
this.Pk = source.Pk;
|
|
this.PkName = source.PkName;
|
|
this.TableName = source.TableName;
|
|
this.TableOwner = source.TableOwner;
|
|
this.TableQualifier = source.TableQualifier;
|
|
|
|
if (includeSystemFields)
|
|
{
|
|
}
|
|
}
|
|
|
|
public override string GetSelectFrom()
|
|
{
|
|
return $" select {DB_NAME_FIELDS} from { DB_NAME_SYS_TABLE_PKEY_VIEW} ";
|
|
}
|
|
|
|
public override string GetSelectCountFrom(string sqlWhere)
|
|
{
|
|
return $" select count(*) from { DB_NAME_SYS_TABLE_PKEY_VIEW} where 1=1 {sqlWhere}";
|
|
}
|
|
|
|
public override string GetSelectTopFrom(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_COLUMN_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_SYS_TABLE_PKEY_VIEW} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {offset},{limit} ";
|
|
}
|
|
|
|
public SysTablePkeyViewEntity Clone()
|
|
{
|
|
SysTablePkeyViewEntity result = new SysTablePkeyViewEntity();
|
|
result.CopyFrom(this);
|
|
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|