This commit is contained in:
john 2025-05-27 00:28:10 +02:00
parent def7767b94
commit 8ad4302ec8
13 changed files with 3902 additions and 4 deletions

View file

@ -1,5 +1,6 @@
using Femto.Common.Domain;
using Femto.Modules.Blog.Domain.Posts.Events;
using Femto.Modules.Blog.Emoji;
namespace Femto.Modules.Blog.Domain.Posts;
@ -9,6 +10,8 @@ internal class Post : Entity
public Guid AuthorId { get; private set; }
public string Content { get; private set; } = null!;
public IList<PostMedia> Media { get; private set; }
public IList<PostReaction> Reactions { get; private set; } = [];
public bool IsPublic { get; set; }
private Post() { }
@ -19,7 +22,13 @@ internal class Post : Entity
this.AuthorId = authorId;
this.Content = content;
this.Media = media;
this.Reactions = AllEmoji
.GetRandomEmoji(5)
.Select(emoji => new PostReaction(emoji, 0))
.ToList();
this.AddDomainEvent(new PostCreated(this));
}
}

View file

@ -0,0 +1,17 @@
namespace Femto.Modules.Blog.Domain.Posts;
public class PostReaction
{
public Guid Id { get; private set; }
public string Emoji { get; private set; } = null!;
public int Count { get; private set; }
public PostReaction(string emoji, int count)
{
this.Id = Guid.CreateVersion7();
this.Emoji = emoji;
this.Count = count;
}
private PostReaction() { }
}