chore: add blog blog comment and blog category crud

This commit is contained in:
mahyargdz
2025-04-12 16:09:25 +03:30
parent 0bc001c66b
commit a9879732a3
23 changed files with 976 additions and 3 deletions
@@ -0,0 +1,26 @@
import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { BlogComment } from "../entities/blog-comment.entity";
import { CommentStatus } from "../enums/comment-status.enum";
@Injectable()
export class BlogCommentsRepository extends Repository<BlogComment> {
constructor(@InjectRepository(BlogComment) blogCommentsRepository: Repository<BlogComment>) {
super(blogCommentsRepository.target, blogCommentsRepository.manager, blogCommentsRepository.queryRunner);
}
async findOneById(id: string) {
return this.findOne({
where: { id },
});
}
async findAllByBlogId(blogId: string) {
return this.find({
where: { blog: { id: blogId }, status: CommentStatus.APPROVED },
order: { createdAt: "DESC" },
});
}
}