using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace YBEE.EQM.Core;
///
/// 资源文件
///
[Comment("资源文件")]
public class ResourceFile : DEntityBase, IEntityTypeBuilder
{
public ResourceFile()
{
Id = Yitter.IdGenerator.YitIdHelper.NextId();
}
///
/// 主键
///
[Comment("主键")]
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public override long Id { get; set; }
///
/// 资源文件类型
///
[Comment("资源文件类型")]
[Required]
public ResourceFileType Type { get; set; }
///
/// 来源ID
///
[Comment("来源ID")]
[Required]
public long SourceId { get; set; }
///
/// 文件名
///
[Comment("文件名")]
[Required, StringLength(100)]
public string FileName { get; set; }
///
/// 文件路径
///
[Comment("文件路径")]
[Required, StringLength(300)]
public string FilePath { get; set; }
///
/// 扩展名
///
[Comment("扩展名")]
[Required, StringLength(50)]
public string FileExtName { get; set; }
///
/// 文件大小(字节Byte)
///
[Comment("文件大小(字节Byte)")]
[Required]
public long FileSize { get; set; } = 0;
///
/// 备注
///
[Comment("备注")]
[StringLength(200)]
public string Remark { get; set; } = "";
public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasIndex(a => new { a.Type, a.SourceId }).HasDatabaseName("idx_resource_file_type_source_id");
}
}