chore: add is pinned to the blog entity and also add route for it
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user