实现添加博客

This commit is contained in:
2025-05-16 21:58:33 +08:00
parent 65303ac988
commit 59a68b372b
13 changed files with 260 additions and 39 deletions

View File

@@ -1,6 +1,45 @@
import { Controller } from "@nestjs/common";
import { Body, Controller, Delete, Get, Param, ParseUUIDPipe, Post, Put } from "@nestjs/common";
import { CreateBlogDto } from "src/admin/dto/admin-web/create-blog.dto";
import { BlogService } from "src/blog/blog.service";
@Controller('/admin/web/blog')
export class AdminWebBlogController {
constructor(
private readonly adminWebBlogService: BlogService,
) { }
@Get()
async list() {
return this.adminWebBlogService.list();
}
@Post()
async create(
@Body() dto: CreateBlogDto,
) {
return this.adminWebBlogService.create(dto);
}
@Put(':id')
async update(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() dto: CreateBlogDto,
) {
return this.adminWebBlogService.update(id, dto);
}
@Get(':id')
async get(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
) {
return this.adminWebBlogService.findById(id);
}
@Delete(':id')
async remove(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
) {
return this.adminWebBlogService.remove(id);
}
}

View File

@@ -26,14 +26,16 @@ export class AdminWebResourceController {
@Put(':id')
async update(
@Param('id') id: string,
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() data: CreateResourceDto
) {
return this.resourceService.update(id, data);
}
@Delete(':id')
async delete(@Param('id') id: string) {
async delete(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
) {
return this.resourceService.delete(id);
}
}