diff --git a/src/modules/content/controllers/post.controller.ts b/src/modules/content/controllers/post.controller.ts index bfcd769..b5bb8da 100644 --- a/src/modules/content/controllers/post.controller.ts +++ b/src/modules/content/controllers/post.controller.ts @@ -4,7 +4,6 @@ import { Delete, Get, Param, - ParseIntPipe, ParseUUIDPipe, Patch, Post, @@ -24,7 +23,7 @@ export class PostController { } @Get(':id') - async show(@Param('id', new ParseIntPipe()) id: string) { + async show(@Param('id') id: string) { return this.postService.detail(id); } diff --git a/src/modules/content/entities/post.entity.ts b/src/modules/content/entities/post.entity.ts index d68faa0..3861783 100644 --- a/src/modules/content/entities/post.entity.ts +++ b/src/modules/content/entities/post.entity.ts @@ -1,5 +1,5 @@ import { Expose } from 'class-transformer'; -import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; +import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn } from 'typeorm'; import { PostBodyType } from '@/modules/content/constants'; @@ -30,9 +30,9 @@ export class PostEntity extends BaseEntity { @Column({ comment: '自定义文章排序', default: 0 }) customOrder: number; - @Column({ comment: '创建时间' }) + @CreateDateColumn({ comment: '创建时间' }) createdAt?: Date; - @Column({ comment: '更新时间' }) + @Column({ comment: '更新时间', nullable: true }) updatedAt?: Date; } diff --git a/src/modules/content/services/post.service.ts b/src/modules/content/services/post.service.ts index 33d8825..d720f7b 100644 --- a/src/modules/content/services/post.service.ts +++ b/src/modules/content/services/post.service.ts @@ -36,8 +36,9 @@ export class PostService { } async update(data: RecordAny) { + data.updatedAt = new Date(); await this.repository.update(data.id, omit(data, ['id'])); - return this.delete(data.id); + return this.detail(data.id); } async delete(id: string) {