update: add slug field to the danak service entity

This commit is contained in:
mahyargdz
2025-05-04 11:31:53 +03:30
parent 721968ed2e
commit 8fe1d398a6
9 changed files with 55 additions and 24 deletions
+4 -1
View File
@@ -111,6 +111,9 @@ export class BlogsService {
const category = await this.findCategoryById(createBlogDto.categoryId);
const existSlug = await this.blogsRepository.findOne({ where: { slug: createBlogDto.slug } });
if (existSlug) throw new BadRequestException(BlogMessage.BLOG_ALREADY_EXISTS_WITH_THIS_SLUG);
const slug = this.generateSlug(createBlogDto.slug);
const blog = this.blogsRepository.create({
@@ -145,7 +148,7 @@ export class BlogsService {
if (updateBlogDto.slug) {
const existBlog = await this.blogsRepository.findOne({ where: { slug: updateBlogDto.slug, id: Not(id) } });
if (existBlog) throw new BadRequestException(BlogMessage.BLOG_ALREADY_EXISTS);
if (existBlog) throw new BadRequestException(BlogMessage.BLOG_ALREADY_EXISTS_WITH_THIS_SLUG);
}
await this.blogsRepository.save({