feat: 调整博客页以支持slug
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user