update: add slug field to the danak service entity
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user