Post.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using Domain.Entities.Forum.Boards;
  2. using Domain.Entities.Forum.Comments;
  3. using Domain.Entities.Members;
  4. using Microsoft.EntityFrameworkCore;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.ComponentModel.DataAnnotations.Schema;
  7. namespace Domain.Entities.Forum.Posts
  8. {
  9. [Table(nameof(Post))]
  10. [Index(nameof(BoardID))]
  11. [Index(nameof(BoardPrefixID))]
  12. [Index(nameof(MemberID))]
  13. [Index(nameof(ID), nameof(BoardID))]
  14. [Index(nameof(ID), nameof(BoardID), nameof(IsDeleted))]
  15. [Index(nameof(ID), nameof(BoardID), nameof(BoardPrefixID), nameof(IsDeleted), nameof(CreatedAt))]
  16. [Index(nameof(ID), nameof(BoardID), nameof(BoardPrefixID), nameof(IsDeleted), nameof(Views))]
  17. [Index(nameof(ID), nameof(BoardID), nameof(BoardPrefixID), nameof(IsDeleted), nameof(Comments))]
  18. [Index(nameof(ID), nameof(BoardID), nameof(BoardPrefixID), nameof(IsDeleted), nameof(Likes))]
  19. public class Post
  20. {
  21. [ForeignKey(nameof(BoardID))]
  22. public virtual Board Board { get; set; } = null!;
  23. [ForeignKey(nameof(BoardPrefixID))]
  24. public virtual BoardPrefix? BoardPrefix { get; set; }
  25. [ForeignKey(nameof(MemberID))]
  26. public virtual Member Member { get; set; } = null!;
  27. // 게시글 댓글
  28. public virtual List<Comment> Comment { get; set; } = [];
  29. // 게시글 이미지
  30. public virtual List<PostImage> PostImage { get; set; } = [];
  31. // 게시글 미디어
  32. public virtual List<PostMedia> PostMedia { get; set; } = [];
  33. // 게시글 파일
  34. public virtual List<PostFile> PostFile { get; set; } = [];
  35. // 게시글 링크
  36. public virtual List<PostLink> PostLink { get; set; } = [];
  37. // 게시글 태그
  38. public virtual List<PostTag> PostTag { get; set; } = [];
  39. // 게시글 반응
  40. public virtual List<PostReaction> PostReaction { get; set; } = [];
  41. // 게시글 즐겨찾기
  42. public virtual List<PostBookmark> PostBookmark { get; set; } = [];
  43. // 게시글 신고
  44. public virtual List<PostReport> PostReport { get; set; } = [];
  45. // 게시글 파일 다운로드 기록
  46. public virtual List<PostFileDownLog> PostFileDownLog { get; set; } = [];
  47. // 게시글 링크 클릭 기록
  48. public virtual List<PostLinkClickLog> PostLinkClickLog { get; set; } = [];
  49. // 게시글 변경 기록
  50. public virtual List<PostUpdateLog> PostUpdateLog { get; set; } = [];
  51. [Key]
  52. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  53. [Comment("PK")]
  54. public int ID { get; set; }
  55. [Comment("게시판 ID")]
  56. public int BoardID { get; set; }
  57. [Comment("게시글 말머리 ID")]
  58. public int? BoardPrefixID { get; set; } = null;
  59. [Comment("회원 ID")]
  60. public int MemberID { get; set; }
  61. [Comment("제목")]
  62. [StringLength(255)]
  63. public string Subject { get; set; } = default!;
  64. [Comment("내용")]
  65. [StringLength(8000)]
  66. public string Content { get; set; } = default!;
  67. [Comment("회원 SID")]
  68. [StringLength(20)]
  69. public string? SID { get; set; }
  70. [Comment("회원 이메일")]
  71. [StringLength(60)]
  72. public string? Email { get; set; }
  73. [Comment("회원 이름")]
  74. [StringLength(20)]
  75. public string? Name { get; set; }
  76. [Comment("대표 이미지")]
  77. [StringLength(255)]
  78. public string? Thumbnail { get; set; }
  79. [Comment("답변 여부")]
  80. public bool IsReply { get; set; } = false;
  81. [Comment("익명 글 여부")]
  82. public bool IsAnonymous { get; set; } = false;
  83. [Comment("비밀글 여부")]
  84. public bool IsSecret { get; set; } = false;
  85. [Comment("일반 공지 여부")]
  86. public bool IsNotice { get; set; } = false;
  87. [Comment("전체 공지 여부")]
  88. public bool IsSpeaker { get; set; } = false;
  89. [Comment("삭제 여부")]
  90. public bool IsDeleted { get; set; } = false;
  91. [Comment("조회 수")]
  92. public int Views { get; set; } = 0;
  93. [Comment("좋아요")]
  94. public int Likes { get; set; } = 0;
  95. [Comment("싫어요")]
  96. public int Dislikes { get; set; } = 0;
  97. [Comment("댓글 수")]
  98. public int Comments { get; set; } = 0;
  99. [Comment("즐겨찾기 수")]
  100. public int Bookmarks { get; set; } = 0;
  101. [Comment("신고 수")]
  102. public int Reports { get; set; } = 0;
  103. [Comment("이미지 수")]
  104. public byte Images { get; set; } = 0;
  105. [Comment("미디어 수")]
  106. public byte Medias { get; set; } = 0;
  107. [Comment("파일 수")]
  108. public byte Files { get; set; } = 0;
  109. [Comment("Tag 수")]
  110. public byte Tags { get; set; } = 0;
  111. [Comment("IP")]
  112. [StringLength(50)]
  113. public string? IpAddress { get; set; }
  114. [Comment("User-Agent")]
  115. [StringLength(255)]
  116. public string? UserAgent { get; set; }
  117. [Comment("마지막 답변 일시")]
  118. [DataType(DataType.DateTime)]
  119. public DateTime? LastReplyUpdatedAt { get; set; }
  120. [Comment("마지막 댓글 일시")]
  121. [DataType(DataType.DateTime)]
  122. public DateTime? LastCommentUpdatedAt { get; set; }
  123. [Comment("삭제 일시")]
  124. [DataType(DataType.DateTime)]
  125. public DateTime? DeletedAt { get; set; }
  126. [Comment("수정 일시")]
  127. [DataType(DataType.DateTime)]
  128. public DateTime? UpdatedAt { get; set; }
  129. [Comment("등록 일시")]
  130. [DataType(DataType.DateTime)]
  131. public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
  132. }
  133. }