diff --git a/backend/src/api/categories/categories.controller.ts b/backend/src/api/categories/categories.controller.ts index 7f461f632b9a4057019bd294007df834b2538c03..7f3323515bf1dafba7123afeae226044a0fcad2f 100644 --- a/backend/src/api/categories/categories.controller.ts +++ b/backend/src/api/categories/categories.controller.ts @@ -1,4 +1,12 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { + Controller, + Get, + Post, + Body, + Patch, + Param, + Delete, +} from '@nestjs/common'; import { CategoriesService } from './categories.service'; import { CreateCategoryDto } from './dto/create-category.dto'; import { UpdateCategoryDto } from './dto/update-category.dto'; @@ -8,20 +16,20 @@ export class CategoriesController { constructor(private readonly categoriesService: CategoriesService) {} @Post() - create(@Body() createCategoryDto: CreateCategoryDto) { - return this.categoriesService.create(createCategoryDto); + async create(@Body() createCategoryDto: CreateCategoryDto) { + return await this.categoriesService.create(createCategoryDto); } @Get() - findAll() { - return this.categoriesService.findAll(); + async findAll() { + return await this.categoriesService.findAll(); } @Get(':id') - findOne(@Param('id') id: string) { - return this.categoriesService.findOne(id); + async findOne(@Param('id') id: string) { + return await this.categoriesService.findOne(id); } -/* + /* @Patch(':id') update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { return this.categoriesService.update(id, updateCategoryDto); diff --git a/backend/src/api/categories/categories.service.ts b/backend/src/api/categories/categories.service.ts index 71eebc7ad625521dbee5f18fa1adf2bd61ba7503..6165fe41908aecfd4b27c75fe2032aa6284e7010 100644 --- a/backend/src/api/categories/categories.service.ts +++ b/backend/src/api/categories/categories.service.ts @@ -9,7 +9,7 @@ export class CategoriesService { create(createCategoryDto: CreateCategoryDto) { return this.prisma.category.create({ - data: createCategoryDto + data: createCategoryDto, }); } @@ -18,32 +18,32 @@ export class CategoriesService { } findOne(id: string) { - return this.prisma.category.findUnique({ + return this.prisma.category.findUnique({ where: { - id - } + id, + }, }); } update(id: string, updateCategoryDto: UpdateCategoryDto) { return this.prisma.category.update({ where: { - id + id, }, data: { - ...updateCategoryDto - } + ...updateCategoryDto, + }, }); } remove(id: string) { return this.prisma.category.update({ where: { - id + id, }, data: { - deletedAt: new Date() - } + deletedAt: new Date(), + }, }); } } diff --git a/backend/src/api/categories/entities/category.entity.ts b/backend/src/api/categories/entities/category.entity.ts index 6f4fd523af696c19290a337d30fcfc7402994cde..876ebaaf8951da2425940d314447bb294824fa4b 100644 --- a/backend/src/api/categories/entities/category.entity.ts +++ b/backend/src/api/categories/entities/category.entity.ts @@ -1 +1,9 @@ -export class Category {} +import { Category } from '@prisma/client'; + +export class CategoryEntity implements Category { + id: string; + createdAt: Date; + updatedAt: Date; + deletedAt: Date; + name: string; +}