文件上传功能添加,注意使用Path.Combine处理通用路径问题(windows||docker)
This commit is contained in:
1 parent
7817c5374c
commit
244b59a3fb
135 files changed
+16937
-75
No files matched your search
@@ -0,0 +1,249 @@
|
||||
|
||||
using CloudBuilder.Core.Authorization;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace CloudBuilder.Master.Entity
|
||||
{
|
||||
[TypeScript]
|
||||
[Table("dms_file")]
|
||||
public class DmsFileEntity : ViewEntityBase
|
||||
{
|
||||
|
||||
public DmsFileEntity()
|
||||
{
|
||||
}
|
||||
|
||||
[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; }
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[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("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("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("revision_no")]
|
||||
public int RevisionNo { get; set; }
|
||||
[Column("transcode_indc")]
|
||||
public string? TranscodeIndc { get; set; }
|
||||
[Column("updated_by")]
|
||||
public string UpdatedBy { get; set; }
|
||||
[Column("updated_datetime")]
|
||||
public DateTime UpdatedDatetime { 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 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 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 ORDER_KEY = "OrderKey";
|
||||
public const string ORG_FILE_NAME = "OrgFileName";
|
||||
public const string OWER_ID = "OwerId";
|
||||
public const string REVISION_NO = "RevisionNo";
|
||||
public const string TRANSCODE_INDC = "TranscodeIndc";
|
||||
public const string UPDATED_BY = "UpdatedBy";
|
||||
public const string UPDATED_DATETIME = "UpdatedDatetime";
|
||||
|
||||
public const string DB_NAME_DMS_FILE = "dms_file";
|
||||
public const string DB_NAME_FIELDS="allow_delete_indc,allow_rename_indc,created_by,created_datetime,file_id,file_name,file_path,file_size,file_tag,file_type,is_directory_indc,is_link_indc,landscape_indc,linked_file_id,order_key,org_file_name,ower_id,revision_no,transcode_indc,updated_by,updated_datetime";
|
||||
|
||||
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_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_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_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_REVISION_NO = "revision_no";
|
||||
public const string DB_TRANSCODE_INDC = "transcode_indc";
|
||||
public const string DB_UPDATED_BY = "updated_by";
|
||||
public const string DB_UPDATED_DATETIME = "updated_datetime";
|
||||
|
||||
private string ProviderName { get; set; }
|
||||
|
||||
public static DmsFileEntity GetInstance(string providerName)
|
||||
{
|
||||
return new DmsFileEntity() { ProviderName = providerName };
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(DmsFileEntity source)
|
||||
{
|
||||
CopyFrom(source, true);
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(DmsFileEntity 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.FileId = source.FileId;
|
||||
this.FileName = source.FileName;
|
||||
this.FilePath = source.FilePath;
|
||||
this.FileSize = source.FileSize;
|
||||
this.FileTag = source.FileTag;
|
||||
this.FileType = source.FileType;
|
||||
this.IsDirectoryIndc = source.IsDirectoryIndc;
|
||||
this.IsLinkIndc = source.IsLinkIndc;
|
||||
this.LandscapeIndc = source.LandscapeIndc;
|
||||
this.LinkedFileId = source.LinkedFileId;
|
||||
this.OrderKey = source.OrderKey;
|
||||
this.OrgFileName = source.OrgFileName;
|
||||
this.OwerId = source.OwerId;
|
||||
this.RevisionNo = source.RevisionNo;
|
||||
this.TranscodeIndc = source.TranscodeIndc;
|
||||
this.UpdatedBy = source.UpdatedBy;
|
||||
this.UpdatedDatetime = source.UpdatedDatetime;
|
||||
|
||||
if (includeSystemFields)
|
||||
{
|
||||
this.CreatedBy = source.CreatedBy;
|
||||
this.CreatedDatetime = source.CreatedDatetime;
|
||||
this.UpdatedBy = source.UpdatedBy;
|
||||
this.UpdatedDatetime = source.UpdatedDatetime;
|
||||
}
|
||||
}
|
||||
|
||||
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_DMS_FILE} with(nolock) ";
|
||||
}
|
||||
public string GetSelectFromByBySqlServer()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from { DB_NAME_DMS_FILE} ";
|
||||
}
|
||||
|
||||
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_DMS_FILE} where 1=1 {sqlWhere}";
|
||||
}
|
||||
public string GetSelectCountFromBySqlServer(string sqlWhere)
|
||||
{
|
||||
return $" select count(*) from { DB_NAME_DMS_FILE} 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_FILE_ID ;
|
||||
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_DMS_FILE} 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_FILE_ID ;
|
||||
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_DMS_FILE} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
|
||||
}
|
||||
|
||||
public DmsFileEntity Clone()
|
||||
{
|
||||
DmsFileEntity result = new DmsFileEntity();
|
||||
result.CopyFrom(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user