dto对象
This commit is contained in:
parent
aea8856148
commit
34ea934195
|
@ -0,0 +1,3 @@
|
||||||
|
export class CreatePostDto {
|
||||||
|
readonly title: string
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import { Controller, Get, Post, Req, Query, Headers, Param, Body } from '@nestjs/common';
|
import { Controller, Get, Post, Req, Query, Headers, Param, Body } from '@nestjs/common';
|
||||||
|
import { CreatePostDto } from './post.dto';
|
||||||
|
|
||||||
@Controller('posts')
|
@Controller('posts')
|
||||||
export class PostsController {
|
export class PostsController {
|
||||||
|
@ -21,8 +22,8 @@ export class PostsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
store(@Body() body) {
|
store(@Body() post: CreatePostDto) {
|
||||||
console.log(body)
|
console.log(post)
|
||||||
return body
|
return post
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue