feat: 调整博客页以支持slug

This commit is contained in:
2025-12-27 13:48:48 +08:00
parent b9d09a16ec
commit b48ed4d903
5 changed files with 29 additions and 30 deletions

View File

@@ -35,13 +35,14 @@ export class BlogService {
return i;
}
const { createdAt, updatedAt, deletedAt, id, title, viewCount, description } = i;
const { createdAt, updatedAt, deletedAt, id, title, viewCount, description, slug } = i;
return {
createdAt,
updatedAt,
deletedAt,
id,
title,
slug,
viewCount,
description,
};
@@ -96,6 +97,12 @@ export class BlogService {
return await this.blogRepository.findOneBy({ id });
}
async findBySlug(slug: string) {
return this.blogRepository.findOne({
where: { slug }
})
}
async incrementViewCount(id: string) {
await this.blogRepository.increment({ id }, 'viewCount', 1);
}