feat: Реализована функциональность списка желаний с бэкенд API, базой данных и пользовательским интерфейсом.
This commit is contained in:
41
backend/src/wishlist/categories.controller.ts
Normal file
41
backend/src/wishlist/categories.controller.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Controller, Get, Post, Patch, Delete, Body, Param, UsePipes } from '@nestjs/common';
|
||||
import { WishlistCategoriesService } from './categories.service';
|
||||
import { CreateWishlistCategoryDto, UpdateWishlistCategoryDto } from './dto/category.dto';
|
||||
import { ZodValidationPipe } from '../pipes/zod-validation.pipe';
|
||||
import { CreateWishlistCategorySchema, UpdateWishlistCategorySchema } from './dto/category.dto';
|
||||
|
||||
@Controller('api/wishlist/categories')
|
||||
export class WishlistCategoriesController {
|
||||
constructor(private readonly categoriesService: WishlistCategoriesService) { }
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
return this.categoriesService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async findOne(@Param('id') id: string) {
|
||||
return this.categoriesService.findOne(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UsePipes(new ZodValidationPipe(CreateWishlistCategorySchema))
|
||||
async create(@Body() dto: CreateWishlistCategoryDto) {
|
||||
return this.categoriesService.create(dto);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@UsePipes(new ZodValidationPipe(UpdateWishlistCategorySchema))
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateWishlistCategoryDto
|
||||
) {
|
||||
return this.categoriesService.update(id, dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') id: string) {
|
||||
await this.categoriesService.delete(id);
|
||||
return { message: 'Category deleted successfully' };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user