Skip to content

Commit

Permalink
feat: 유저 정보 가져오는 api 구현 #158
Browse files Browse the repository at this point in the history
  • Loading branch information
koomchang committed Nov 20, 2024
1 parent 5b45f01 commit 9793638
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
6 changes: 6 additions & 0 deletions backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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);
}
}

0 comments on commit 9793638

Please sign in to comment.