实现访问博客计数

This commit is contained in:
2025-05-18 16:01:12 +08:00
parent a561d729e2
commit 3f8e9c27be
2 changed files with 5 additions and 0 deletions

View File

@@ -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,

View File

@@ -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);
}
}