From 651542fa9f68f4020cbde940cef1ef5986a2dced Mon Sep 17 00:00:00 2001 From: Seungil Kim Date: Thu, 10 Aug 2023 23:08:52 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feat:=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=EC=9D=98=20=ED=83=9C=EA=B7=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # --- src/tag/tag.controller.ts | 8 +++++++- src/tag/tag.service.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/tag/tag.controller.ts b/src/tag/tag.controller.ts index 94bbf34..8569702 100644 --- a/src/tag/tag.controller.ts +++ b/src/tag/tag.controller.ts @@ -1,11 +1,17 @@ -import { Controller, UseGuards } from '@nestjs/common'; +import { Controller, Get, UseGuards } from '@nestjs/common'; import { TagService } from './tag.service'; import { AuthGuard } from '@nestjs/passport'; import { ApiBearerAuth } from '@nestjs/swagger'; +import { GetUid } from '../decorators/get-uid.decorator'; @Controller('tag') @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() export class TagController { constructor(private readonly tagService: TagService) {} + + @Get() + async getTags(@GetUid() uid: string): Promise { + return await this.tagService.getTags(uid); + } } diff --git a/src/tag/tag.service.ts b/src/tag/tag.service.ts index 5832ee0..9e4d8a4 100644 --- a/src/tag/tag.service.ts +++ b/src/tag/tag.service.ts @@ -4,4 +4,12 @@ import { PrismaService } from '../prisma/prisma.service'; @Injectable() export class TagService { constructor(private readonly prisma: PrismaService) {} + + async getTags(uid: string): Promise { + const tags = await this.prisma.tag.findMany({ + where: { user: { uid } }, + }); + + return tags.map((tag) => tag.name); + } }