This commit is contained in:
mahyargdz
2025-04-23 15:04:03 +03:30
parent 0b04ba051a
commit d69755a690
4 changed files with 12 additions and 5 deletions
+8 -3
View File
@@ -1,7 +1,7 @@
import { BadRequestException, Injectable } from "@nestjs/common";
import { Not } from "typeorm";
import { BlogMessage, CommonMessage } from "../../../common/enums/message.enum";
import { AdminMessage, BlogMessage, CommonMessage } from "../../../common/enums/message.enum";
import { CategoryListSearchQueryDto } from "../../danak-services/DTO/category-search-query.dto";
import { UsersService } from "../../users/providers/users.service";
import { BlogCommentQueryDto } from "../DTO/blog-comment-query.dto";
@@ -56,7 +56,9 @@ export class BlogsService {
//*********************************** */
async deleteCategory(id: string, userId: string) {
console.log(userId);
const isSuperAdmin = await this.usersService.isSuperAdmin(userId);
if (!isSuperAdmin) throw new BadRequestException(AdminMessage.NOT_ALLOWED);
const category = await this.blogCategoriesRepository.findOneBy({ id });
if (!category) throw new BadRequestException(BlogMessage.CATEGORY_NOT_FOUND);
@@ -159,7 +161,10 @@ export class BlogsService {
}
//*********************************** */
async deleteBlog(id: string) {
async deleteBlog(id: string, userId: string) {
const isSuperAdmin = await this.usersService.isSuperAdmin(userId);
if (!isSuperAdmin) throw new BadRequestException(AdminMessage.NOT_ALLOWED);
const blog = await this.blogsRepository.findOneBy({ id });
if (!blog) throw new BadRequestException(BlogMessage.BLOG_NOT_FOUND);