using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Atomx.Common.Entities
{
    /// <summary>
    /// 上传的文件
    /// </summary>
    [Table("UploadFiles")]
    public class UploadFile
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 归属站点应用ID
        /// </summary>
        public long SiteId { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public int Type { get; set; }

        /// <summary>
        /// 文件名
        /// </summary>
        [Column(TypeName = "varchar(64)")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 存放路径
        /// </summary>
        [Column(TypeName = "varchar(128)")]
        public string Path { get; set; } = string.Empty;

        /// <summary>
        /// 文件扩展
        /// </summary>
        [Column(TypeName = "varchar(12)")]
        public string Extension { get; set; } = string.Empty;

        /// <summary>
        /// 文件扩展
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        public string ContentType { get; set; } = string.Empty;

        /// <summary>
        /// 文件hash
        /// </summary>
        [Column(TypeName = "varchar(128)")]
        public string SHA256Hash { get; set; } = string.Empty;

        /// <summary>
        /// 文件大小，单位：字节
        /// </summary>
        public int Size { get; set; }

        /// <summary>
        /// 创建用户ID
        /// </summary>
        public long CreateUid { get; set; }

        /// <summary>
        /// 创建用户名
        /// </summary>
        [Column(TypeName = "varchar(32)")]
        public string CreateBy { get; set; } = string.Empty;

        /// <summary>
        /// 数据创建时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime CreateTime { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 数据最后更新时间
        /// </summary>
        [Column(TypeName = "timestamptz")]
        public DateTime? UpdateTime { get; set; }
    }
}
