SysSetting.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Abp.Domain.Entities;
  4. using Abp.Domain.Entities.Auditing;
  5. namespace IwbZero.Authorization.Base.SystemInfo
  6. {
  7. /// <summary>
  8. /// Represents a setting for a tenant or user.
  9. /// </summary>
  10. [Table("Sys_Settings")]
  11. public class SysSetting : AuditedEntity<long>, IMayHaveTenant
  12. {
  13. /// <summary>
  14. /// Maximum length of the <see cref="Name"/> property.
  15. /// </summary>
  16. public const int MaxNameLength = 256;
  17. /// <summary>
  18. /// Maximum length of the <see cref="Value"/> property.
  19. /// </summary>
  20. public const int MaxValueLength = int.MaxValue;
  21. public const int DisplayNameMaxLength = 50;
  22. public const int DescriptionMaxLength = 500;
  23. public const int RemarkMaxLength = 500;
  24. /// <summary>
  25. /// TenantId for this setting.
  26. /// TenantId is null if this setting is not Tenant level.
  27. /// </summary>
  28. [Index]
  29. public int? TenantId { get; set; }
  30. /// <summary>
  31. /// UserId for this setting.
  32. /// UserId is null if this setting is not user level.
  33. /// </summary>
  34. [Index]
  35. public long? UserId { get; set; }
  36. /// <summary>
  37. /// Unique name of the setting.
  38. /// </summary>
  39. [Required]
  40. [StringLength(MaxNameLength)]
  41. public string Name { get; set; }
  42. /// <summary>
  43. /// Value of the setting.
  44. /// </summary>
  45. [StringLength(MaxValueLength)]
  46. public string Value { get; set; }
  47. [StringLength(DisplayNameMaxLength)]
  48. public string DisplayName { get; set; }
  49. public int? Type { get; set; }
  50. [StringLength(DescriptionMaxLength)]
  51. public string Description { get; set; }
  52. [StringLength(RemarkMaxLength)]
  53. public string Remark { get; set; }
  54. /// <summary>
  55. /// Creates a new <see cref="SysSetting"/> object.
  56. /// </summary>
  57. public SysSetting()
  58. {
  59. }
  60. /// <summary>
  61. /// Creates a new <see cref="SysSetting"/> object.
  62. /// </summary>
  63. /// <param name="tenantId">TenantId for this setting</param>
  64. /// <param name="userId">UserId for this setting</param>
  65. /// <param name="name">Unique name of the setting</param>
  66. /// <param name="value">Value of the setting</param>
  67. /// <param name="displayName"></param>
  68. /// <param name="type"></param>
  69. public SysSetting(int? tenantId, long? userId, string name, string value, string displayName, int? type = null)
  70. {
  71. TenantId = tenantId;
  72. UserId = userId;
  73. Name = name;
  74. Value = value;
  75. DisplayName = displayName;
  76. Type = type;
  77. }
  78. }
  79. }