From 979363865dbcba0180a31e22e2ec814896dcadb6 Mon Sep 17 00:00:00 2001 From: koomchang Date: Wed, 20 Nov 2024 21:05:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20api=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20#158?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/user/user.controller.ts | 7 ++++++- backend/src/user/user.service.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/user/user.controller.ts b/backend/src/user/user.controller.ts index 4bbfcb37..01c9638e 100644 --- a/backend/src/user/user.controller.ts +++ b/backend/src/user/user.controller.ts @@ -1,7 +1,12 @@ -import { Controller } from '@nestjs/common'; +import { Controller, Get, Param } from '@nestjs/common'; import { UserService } from './user.service'; @Controller('users') export class UserController { constructor(private readonly userService: UserService) {} + + @Get('/:id') + async getUserInfo(@Param('id') id: number) { + return await this.userService.getUserInfo(id); + } } diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 4278da27..14505301 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@nestjs/common'; import { UserRepository } from './user.repository'; import { CreateUserRequest } from './dto/CreateUserRequest'; +import { UserIconResponse } from '@src/user/dto/UserIconResponse'; @Injectable() export class UserService { @@ -22,4 +23,9 @@ export class UserService { const newUser = await this.userRepository.save(user); return { userId: newUser.id, role: newUser.role }; } + + async getUserInfo(userId: number) { + const user = await this.userRepository.findById(userId); + return UserIconResponse.from(user); + } }