From 86f95efe1bc2502bc9f488364d5c2d845db1e7c3 Mon Sep 17 00:00:00 2001 From: Andres Date: Mon, 24 Jul 2023 11:41:21 +0200 Subject: [PATCH] fix schema --- src/modules/decks/decks.controller.ts | 8 ++++---- src/modules/decks/entities/deck.entity.ts | 5 ++++- src/modules/decks/infrastructure/decks.repository.ts | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/decks/decks.controller.ts b/src/modules/decks/decks.controller.ts index ba40bad..ace7907 100644 --- a/src/modules/decks/decks.controller.ts +++ b/src/modules/decks/decks.controller.ts @@ -35,7 +35,7 @@ import { Card, PaginatedCards } from '../cards/entities/cards.entity' import { DecksService } from './decks.service' import { UpdateDeckDto, CreateDeckDto, GetAllDecksDto } from './dto' -import { Deck, PaginatedDecks } from './entities/deck.entity' +import { Deck, DeckWithAuthor, PaginatedDecks } from './entities/deck.entity' import { CreateDeckCommand, DeleteDeckByIdCommand, @@ -77,7 +77,7 @@ export class DecksController { cover: Express.Multer.File[] }, @Body() createDeckDto: CreateDeckDto - ): Promise { + ): Promise { const userId = req.user.id return this.commandBus.execute( @@ -89,7 +89,7 @@ export class DecksController { @ApiUnauthorizedResponse({ description: 'Unauthorized' }) @UseGuards(JwtAuthGuard) @Get(':id') - findOne(@Param('id') id: string): Promise { + findOne(@Param('id') id: string): Promise { return this.commandBus.execute(new GetDeckByIdCommand(id)) } @@ -108,7 +108,7 @@ export class DecksController { }, @Body() updateDeckDto: UpdateDeckDto, @Req() req - ): Promise { + ): Promise { return this.commandBus.execute( new UpdateDeckCommand(id, updateDeckDto, req.user.id, files?.cover?.[0]) ) diff --git a/src/modules/decks/entities/deck.entity.ts b/src/modules/decks/entities/deck.entity.ts index b40feb3..e1cb334 100644 --- a/src/modules/decks/entities/deck.entity.ts +++ b/src/modules/decks/entities/deck.entity.ts @@ -11,6 +11,9 @@ export class Deck { created: Date updated: Date cardsCount: number +} + +export class DeckWithAuthor extends Deck { author: DeckAuthor } @@ -20,7 +23,7 @@ export class DeckAuthor { } export class PaginatedDecks { - items: Deck[] + items: DeckWithAuthor[] pagination: Pagination maxCardsCount: number } diff --git a/src/modules/decks/infrastructure/decks.repository.ts b/src/modules/decks/infrastructure/decks.repository.ts index 9b14dcf..0fc1a28 100644 --- a/src/modules/decks/infrastructure/decks.repository.ts +++ b/src/modules/decks/infrastructure/decks.repository.ts @@ -122,7 +122,7 @@ export class DecksRepository { } } - public async findDeckById(id: string) { + public async findDeckById(id: string): Promise { try { return await this.prisma.deck.findUnique({ where: { @@ -135,7 +135,7 @@ export class DecksRepository { } } - public async findDeckByCardId(cardId: string) { + public async findDeckByCardId(cardId: string): Promise { try { const card = await this.prisma.card.findUnique({ where: {