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