58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import {
|
|
CreateWebsiteBlogCategoryDto,
|
|
CreateWebsiteBlogPostDto,
|
|
} from './dto/website-blog.dto';
|
|
import { WebsiteBlogService } from './website-blog.service';
|
|
|
|
@Controller('website/blog')
|
|
export class WebsiteBlogController {
|
|
constructor(private readonly blog: WebsiteBlogService) {}
|
|
|
|
@Get('categories')
|
|
listCategories() {
|
|
return this.blog.listCategories();
|
|
}
|
|
|
|
@Post('categories')
|
|
createCategory(@Body() body: CreateWebsiteBlogCategoryDto) {
|
|
return this.blog.createCategory(body);
|
|
}
|
|
|
|
@Patch('categories/:id')
|
|
updateCategory(
|
|
@Param('id') id: string,
|
|
@Body() body: CreateWebsiteBlogCategoryDto,
|
|
) {
|
|
return this.blog.updateCategory(id, body);
|
|
}
|
|
|
|
@Delete('categories/:id')
|
|
deleteCategory(@Param('id') id: string) {
|
|
return this.blog.deleteCategory(id);
|
|
}
|
|
|
|
@Get('posts')
|
|
listPosts() {
|
|
return this.blog.listPosts();
|
|
}
|
|
|
|
@Post('posts')
|
|
createPost(@Body() body: CreateWebsiteBlogPostDto) {
|
|
return this.blog.createPost(body);
|
|
}
|
|
|
|
@Delete('posts/:id')
|
|
deletePost(@Param('id') id: string) {
|
|
return this.blog.deletePost(id);
|
|
}
|
|
}
|