fix: bug
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user