实现访问博客计数
This commit is contained in:
@@ -23,6 +23,7 @@ export class BlogController {
|
||||
const blogDataRes = await fetch(`${blog.contentUrl}`);
|
||||
const blogContent = await blogDataRes.text();
|
||||
|
||||
await this.blogService.incrementViewCount(id);
|
||||
return {
|
||||
id: blog.id,
|
||||
title: blog.title,
|
||||
|
||||
@@ -39,4 +39,8 @@ export class BlogService {
|
||||
async findById(id: string) {
|
||||
return this.blogRepository.findOneBy({ id });
|
||||
}
|
||||
|
||||
async incrementViewCount(id: string) {
|
||||
await this.blogRepository.increment({ id }, 'viewCount', 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user