fix: remove soft delete from the blog category
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user