Files
Docker/CloudBuilder/CloudBuilder.Master/Entity/FamilyDmsFileViewEntity.auto.cs
T

281 lines
11 KiB
C#

using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_dms_file_view")]
public class FamilyDmsFileViewEntity : ViewEntityBase
{
public FamilyDmsFileViewEntity()
{
}
[Column("allow_delete_indc")]
public string AllowDeleteIndc { get; set; }
[Column("allow_rename_indc")]
public string AllowRenameIndc { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("family_name")]
public string FamilyName { get; set; }
[Column("favorite_indc")]
public string FavoriteIndc { get; set; }
[Column("file_category")]
public string FileCategory { get; set; }
[Column("file_id")]
public long FileId { get; set; }
[Column("file_name")]
public string FileName { get; set; }
[Column("file_path")]
public string? FilePath { get; set; }
[Column("file_size")]
public int FileSize { get; set; }
[Column("file_tag")]
public string? FileTag { get; set; }
[Column("file_type")]
public string? FileType { get; set; }
[Column("folder_local_name")]
public string? FolderLocalName { get; set; }
[Column("folder_name")]
public string FolderName { get; set; }
[Column("is_directory_indc")]
public string IsDirectoryIndc { get; set; }
[Column("is_link_indc")]
public string IsLinkIndc { get; set; }
[Column("landscape_indc")]
public string? LandscapeIndc { get; set; }
[Column("linked_file_id")]
public int LinkedFileId { get; set; }
[Column("notice")]
public string? Notice { get; set; }
[Column("order_key")]
public string? OrderKey { get; set; }
[Column("org_file_name")]
public string? OrgFileName { get; set; }
[Column("ower_id")]
public string OwerId { get; set; }
[Column("permission_indc")]
public string PermissionIndc { get; set; }
[Column("revision_no")]
public int RevisionNo { get; set; }
[Column("top_folder_name")]
public string TopFolderName { get; set; }
[Column("transcode_indc")]
public string? TranscodeIndc { get; set; }
[Column("url")]
public string Url { get; set; }
public const string ALLOW_DELETE_INDC = "AllowDeleteIndc";
public const string ALLOW_RENAME_INDC = "AllowRenameIndc";
public const string CREATED_BY = "CreatedBy";
public const string CREATED_DATETIME = "CreatedDatetime";
public const string FAMILY_NAME = "FamilyName";
public const string FAVORITE_INDC = "FavoriteIndc";
public const string FILE_CATEGORY = "FileCategory";
public const string FILE_ID = "FileId";
public const string FILE_NAME = "FileName";
public const string FILE_PATH = "FilePath";
public const string FILE_SIZE = "FileSize";
public const string FILE_TAG = "FileTag";
public const string FILE_TYPE = "FileType";
public const string FOLDER_LOCAL_NAME = "FolderLocalName";
public const string FOLDER_NAME = "FolderName";
public const string IS_DIRECTORY_INDC = "IsDirectoryIndc";
public const string IS_LINK_INDC = "IsLinkIndc";
public const string LANDSCAPE_INDC = "LandscapeIndc";
public const string LINKED_FILE_ID = "LinkedFileId";
public const string NOTICE = "Notice";
public const string ORDER_KEY = "OrderKey";
public const string ORG_FILE_NAME = "OrgFileName";
public const string OWER_ID = "OwerId";
public const string PERMISSION_INDC = "PermissionIndc";
public const string REVISION_NO = "RevisionNo";
public const string TOP_FOLDER_NAME = "TopFolderName";
public const string TRANSCODE_INDC = "TranscodeIndc";
public const string URL = "Url";
public const string DB_NAME_FAMILY_DMS_FILE_VIEW = "family_dms_file_view";
public const string DB_NAME_FIELDS="allow_delete_indc,allow_rename_indc,created_by,created_datetime,family_name,favorite_indc,file_category,file_id,file_name,file_path,file_size,file_tag,file_type,folder_local_name,folder_name,is_directory_indc,is_link_indc,landscape_indc,linked_file_id,notice,order_key,org_file_name,ower_id,permission_indc,revision_no,top_folder_name,transcode_indc,url";
public const string DB_ALLOW_DELETE_INDC = "allow_delete_indc";
public const string DB_ALLOW_RENAME_INDC = "allow_rename_indc";
public const string DB_CREATED_BY = "created_by";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_FAMILY_NAME = "family_name";
public const string DB_FAVORITE_INDC = "favorite_indc";
public const string DB_FILE_CATEGORY = "file_category";
public const string DB_FILE_ID = "file_id";
public const string DB_FILE_NAME = "file_name";
public const string DB_FILE_PATH = "file_path";
public const string DB_FILE_SIZE = "file_size";
public const string DB_FILE_TAG = "file_tag";
public const string DB_FILE_TYPE = "file_type";
public const string DB_FOLDER_LOCAL_NAME = "folder_local_name";
public const string DB_FOLDER_NAME = "folder_name";
public const string DB_IS_DIRECTORY_INDC = "is_directory_indc";
public const string DB_IS_LINK_INDC = "is_link_indc";
public const string DB_LANDSCAPE_INDC = "landscape_indc";
public const string DB_LINKED_FILE_ID = "linked_file_id";
public const string DB_NOTICE = "notice";
public const string DB_ORDER_KEY = "order_key";
public const string DB_ORG_FILE_NAME = "org_file_name";
public const string DB_OWER_ID = "ower_id";
public const string DB_PERMISSION_INDC = "permission_indc";
public const string DB_REVISION_NO = "revision_no";
public const string DB_TOP_FOLDER_NAME = "top_folder_name";
public const string DB_TRANSCODE_INDC = "transcode_indc";
public const string DB_URL = "url";
private string ProviderName { get; set; }
public static FamilyDmsFileViewEntity GetInstance(string providerName)
{
return new FamilyDmsFileViewEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyDmsFileViewEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyDmsFileViewEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.AllowDeleteIndc = source.AllowDeleteIndc;
this.AllowRenameIndc = source.AllowRenameIndc;
this.CreatedBy = source.CreatedBy;
this.CreatedDatetime = source.CreatedDatetime;
this.FamilyName = source.FamilyName;
this.FavoriteIndc = source.FavoriteIndc;
this.FileCategory = source.FileCategory;
this.FileId = source.FileId;
this.FileName = source.FileName;
this.FilePath = source.FilePath;
this.FileSize = source.FileSize;
this.FileTag = source.FileTag;
this.FileType = source.FileType;
this.FolderLocalName = source.FolderLocalName;
this.FolderName = source.FolderName;
this.IsDirectoryIndc = source.IsDirectoryIndc;
this.IsLinkIndc = source.IsLinkIndc;
this.LandscapeIndc = source.LandscapeIndc;
this.LinkedFileId = source.LinkedFileId;
this.Notice = source.Notice;
this.OrderKey = source.OrderKey;
this.OrgFileName = source.OrgFileName;
this.OwerId = source.OwerId;
this.PermissionIndc = source.PermissionIndc;
this.RevisionNo = source.RevisionNo;
this.TopFolderName = source.TopFolderName;
this.TranscodeIndc = source.TranscodeIndc;
this.Url = source.Url;
if (includeSystemFields)
{
this.CreatedBy = source.CreatedBy;
this.CreatedDatetime = source.CreatedDatetime;
}
}
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_FAMILY_DMS_FILE_VIEW} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_DMS_FILE_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_FAMILY_DMS_FILE_VIEW} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_DMS_FILE_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_ALLOW_DELETE_INDC ; 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_FAMILY_DMS_FILE_VIEW} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {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_ALLOW_DELETE_INDC ; 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_FAMILY_DMS_FILE_VIEW} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyDmsFileViewEntity Clone()
{
FamilyDmsFileViewEntity result = new FamilyDmsFileViewEntity();
result.CopyFrom(this);
return result;
}
}
}