chore: add comment reply for review and blog comment

This commit is contained in:
mahyargdz
2025-08-31 09:55:33 +03:30
parent 9c409bef27
commit 8e9b939a0b
20 changed files with 624 additions and 222 deletions
@@ -25,6 +25,7 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
order: { createdAt: "DESC" },
relations: {
user: true,
replies: true,
},
select: {
id: true,
@@ -33,6 +34,7 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
createdAt: true,
status: true,
user: { id: true, firstName: true, lastName: true },
replies: { id: true, content: true, createdAt: true, author: { id: true, firstName: true, lastName: true } },
},
});
}
@@ -44,7 +46,11 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
.where("blog.deletedAt IS NULL")
.addSelect(["blog.id", "blog.title"])
.leftJoin("blogComment.user", "user")
.addSelect(["user.id", "user.firstName", "user.lastName"]);
.addSelect(["user.id", "user.firstName", "user.lastName"])
.leftJoin("blogComment.replies", "replies")
.addSelect(["replies.id", "replies.content", "replies.createdAt"])
.leftJoin("replies.author", "repliesAuthor")
.addSelect(["repliesAuthor.id", "repliesAuthor.firstName", "repliesAuthor.lastName"]);
if (queryDto.q) {
query.andWhere("blogComment.content ILIKE :q", { q: `%${queryDto.q}%` });
@@ -58,13 +64,14 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
return query.getManyAndCount();
}
//*********************************** */
async findBlogCommentsByBlogId(blogId: string) {
return this.find({
where: { blog: { id: blogId, deletedAt: IsNull() }, status: CommentStatus.APPROVED },
order: { createdAt: "DESC" },
relations: {
user: true,
replies: true,
},
select: {
id: true,
@@ -73,6 +80,7 @@ export class BlogCommentsRepository extends Repository<BlogComment> {
createdAt: true,
status: true,
user: { id: true, firstName: true, lastName: true, profilePic: true },
replies: { id: true, content: true, createdAt: true, author: { id: true, firstName: true, lastName: true } },
},
});
}