fix: remove soft delete from the blog category

This commit is contained in:
mahyargdz
2025-04-23 14:56:24 +03:30
parent c2949ba06a
commit 0b04ba051a
6 changed files with 15 additions and 13 deletions
+6 -3
View File
@@ -55,11 +55,15 @@ export class BlogsService {
}
//*********************************** */
async deleteCategory(id: string) {
async deleteCategory(id: string, userId: string) {
console.log(userId);
const category = await this.blogCategoriesRepository.findOneBy({ id });
if (!category) throw new BadRequestException(BlogMessage.CATEGORY_NOT_FOUND);
await this.blogCategoriesRepository.delete({ id });
const blogs = await this.blogsRepository.find({ where: { category: { id } }, take: 2 });
if (blogs.length > 0) throw new BadRequestException(BlogMessage.CATEGORY_HAS_BLOGS);
await this.blogCategoriesRepository.remove(category);
return {
message: CommonMessage.DELETED,
};
@@ -106,7 +110,6 @@ export class BlogsService {
const category = await this.findCategoryById(createBlogDto.categoryId);
const slug = this.generateSlug(createBlogDto.slug);
console.log(slug);
const blog = this.blogsRepository.create({
...createBlogDto,