🐛 Fix post modeling data infiniting loop

This commit is contained in:
LittleSheep 2025-06-27 01:11:19 +08:00
parent 1d50f225c1
commit 35a9dcffbc

View File

@ -64,7 +64,7 @@ public class Post : ModelBase, IIdentifiedResource, IActivity
public ICollection<PostReaction> Reactions { get; set; } = new List<PostReaction>(); public ICollection<PostReaction> Reactions { get; set; } = new List<PostReaction>();
public ICollection<PostTag> Tags { get; set; } = new List<PostTag>(); public ICollection<PostTag> Tags { get; set; } = new List<PostTag>();
public ICollection<PostCategory> Categories { get; set; } = new List<PostCategory>(); public ICollection<PostCategory> Categories { get; set; } = new List<PostCategory>();
public ICollection<PostCollection> Collections { get; set; } = new List<PostCollection>(); [JsonIgnore] public ICollection<PostCollection> Collections { get; set; } = new List<PostCollection>();
[JsonIgnore] public bool Empty => Content == null && Attachments.Count == 0 && ForwardedPostId == null; [JsonIgnore] public bool Empty => Content == null && Attachments.Count == 0 && ForwardedPostId == null;
[NotMapped] public bool IsTruncated { get; set; } = false; [NotMapped] public bool IsTruncated { get; set; } = false;
@ -91,7 +91,7 @@ public class PostTag : ModelBase
public Guid Id { get; set; } public Guid Id { get; set; }
[MaxLength(128)] public string Slug { get; set; } = null!; [MaxLength(128)] public string Slug { get; set; } = null!;
[MaxLength(256)] public string? Name { get; set; } [MaxLength(256)] public string? Name { get; set; }
public ICollection<Post> Posts { get; set; } = new List<Post>(); [JsonIgnore] public ICollection<Post> Posts { get; set; } = new List<Post>();
} }
public class PostCategory : ModelBase public class PostCategory : ModelBase
@ -99,7 +99,7 @@ public class PostCategory : ModelBase
public Guid Id { get; set; } public Guid Id { get; set; }
[MaxLength(128)] public string Slug { get; set; } = null!; [MaxLength(128)] public string Slug { get; set; } = null!;
[MaxLength(256)] public string? Name { get; set; } [MaxLength(256)] public string? Name { get; set; }
public ICollection<Post> Posts { get; set; } = new List<Post>(); [JsonIgnore] public ICollection<Post> Posts { get; set; } = new List<Post>();
} }
public class PostCollection : ModelBase public class PostCollection : ModelBase