chore: add is pinned to the blog entity and also add route for it

This commit is contained in:
mahyargdz
2025-04-12 16:28:02 +03:30
parent 39cce1c380
commit d76b9326e6
6 changed files with 53 additions and 2 deletions
@@ -262,4 +262,16 @@ export class BlogsService {
const blogs = await this.blogsRepository.getMostVisitedBlogs();
return { blogs };
}
async getPinnedBlogs() {
const blogs = await this.blogsRepository.getPinnedBlogs();
return { blogs };
}
async togglePinnedStatus(id: string) {
const blog = await this.findBlogById(id);
blog.isPinned = !blog.isPinned;
await this.blogsRepository.save(blog);
return { message: CommonMessage.UPDATE_SUCCESS, blog };
}
}