-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Comment, Like, Post, and User entities
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
backend/services/PostService/src/PostService.Domain/Entities/Comment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace PostService.Domain.Entities; | ||
|
||
public class Comment | ||
{ | ||
public Guid CommentId { get; private set; } | ||
public Guid PostId { get; private set; } | ||
public Guid UserId { get; private set; } | ||
public string Content { get; private set; } | ||
public DateTime CreatedAt { get; private set; } | ||
|
||
public Comment(Guid commentId, Guid postId, Guid userId, string content) | ||
{ | ||
CommentId = commentId; | ||
PostId = postId; | ||
UserId = userId; | ||
Content = content; | ||
CreatedAt = DateTime.UtcNow; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/services/PostService/src/PostService.Domain/Entities/Like.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace PostService.Domain.Entities; | ||
|
||
public class Like | ||
{ | ||
public Guid LikeId { get; private set; } | ||
public Guid PostId { get; private set; } | ||
public Guid UserId { get; private set; } | ||
public DateTime CreatedAt { get; private set; } | ||
|
||
public Like(Guid likeId, Guid postId, Guid userId) | ||
{ | ||
LikeId = likeId; | ||
PostId = postId; | ||
UserId = userId; | ||
CreatedAt = DateTime.UtcNow; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/services/PostService/src/PostService.Domain/Entities/Post.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace PostService.Domain.Entities; | ||
|
||
public class Post | ||
{ | ||
public Guid PostId { get; private set; } | ||
public Guid UserId { get; private set; } | ||
public string Title { get; private set; } | ||
public string Content { get; private set; } | ||
public string ImageUrl { get; private set; } | ||
public int LikeCount { get; private set; } | ||
public int CommentCount { get; private set; } | ||
public DateTime CreatedAt { get; private set; } | ||
|
||
public Post(Guid postId, Guid userId, string title, string content, string imageUrl) | ||
{ | ||
PostId = postId; | ||
UserId = userId; | ||
Title = title; | ||
Content = content; | ||
ImageUrl = imageUrl; | ||
LikeCount = 0; | ||
CommentCount = 0; | ||
CreatedAt = DateTime.UtcNow; | ||
} | ||
|
||
public void IncrementCommentCount() => CommentCount++; | ||
|
||
public void IncrementLikeCount() => LikeCount++; | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/services/PostService/src/PostService.Domain/Entities/User.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace PostService.Domain.Entities; | ||
|
||
public class User | ||
{ | ||
public Guid UserId { get; private set; } | ||
public string FirstName { get; private set; } | ||
public string LastName { get; private set; } | ||
public string Username { get; private set; } | ||
public string ImageUrl { get; private set; } | ||
public DateTime CreatedAt { get; private set; } | ||
|
||
public User(Guid userId, string firstName, string lastName, string username, string imageUrl) | ||
{ | ||
UserId = userId; | ||
FirstName = firstName; | ||
LastName = lastName; | ||
Username = username; | ||
ImageUrl = imageUrl; | ||
CreatedAt = DateTime.UtcNow; | ||
} | ||
} |