ResourceFile.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Furion.DatabaseAccessor;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. using System;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.ComponentModel.DataAnnotations.Schema;
  7. namespace YBEE.EQM.Core;
  8. /// <summary>
  9. /// 资源文件
  10. /// </summary>
  11. [Comment("资源文件")]
  12. public class ResourceFile : DEntityBase<long>, IEntityTypeBuilder<ResourceFile>
  13. {
  14. public ResourceFile()
  15. {
  16. Id = Yitter.IdGenerator.YitIdHelper.NextId();
  17. }
  18. /// <summary>
  19. /// 主键
  20. /// </summary>
  21. [Comment("主键")]
  22. [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  23. public override long Id { get; set; }
  24. /// <summary>
  25. /// 资源文件类型
  26. /// </summary>
  27. [Comment("资源文件类型")]
  28. [Required]
  29. public ResourceFileType Type { get; set; }
  30. /// <summary>
  31. /// 来源ID
  32. /// </summary>
  33. [Comment("来源ID")]
  34. [Required]
  35. public long SourceId { get; set; }
  36. /// <summary>
  37. /// 文件名
  38. /// </summary>
  39. [Comment("文件名")]
  40. [Required, StringLength(100)]
  41. public string FileName { get; set; }
  42. /// <summary>
  43. /// 文件路径
  44. /// </summary>
  45. [Comment("文件路径")]
  46. [Required, StringLength(300)]
  47. public string FilePath { get; set; }
  48. /// <summary>
  49. /// 扩展名
  50. /// </summary>
  51. [Comment("扩展名")]
  52. [Required, StringLength(50)]
  53. public string FileExtName { get; set; }
  54. /// <summary>
  55. /// 文件大小(字节Byte)
  56. /// </summary>
  57. [Comment("文件大小(字节Byte)")]
  58. [Required]
  59. public long FileSize { get; set; } = 0;
  60. /// <summary>
  61. /// 备注
  62. /// </summary>
  63. [Comment("备注")]
  64. [StringLength(200)]
  65. public string Remark { get; set; } = "";
  66. public void Configure(EntityTypeBuilder<ResourceFile> entityBuilder, DbContext dbContext, Type dbContextLocator)
  67. {
  68. entityBuilder.HasIndex(a => new { a.Type, a.SourceId }).HasDatabaseName("idx_resource_file_type_source_id");
  69. }
  70. }