From 2ed6e8ed21c5c228960370bd5ef5a2e4ca91a578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 12 Sep 2022 12:43:51 +0900 Subject: [PATCH] nestjs_auth... --- src/user/user.controller.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index 5450f09..a9dccaf 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -25,7 +25,7 @@ export class UserController { @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Get() - fetchAll(@Query() query) { + async fetchAll(@Query() query) { console.log(query) //Field별 filter AND Sql용 @@ -114,8 +114,8 @@ export class UserController { console.log(fetchSQL) //전체 갯수 및 fetched Data - const total = this.userService.count(fetchSQL) - const rows = this.userService.fetchAll(fetchSQL) + const total = await this.userService.count(fetchSQL) + const rows = await this.userService.fetchAll(fetchSQL) const result = { total: total, perPage: perPage, @@ -132,23 +132,23 @@ export class UserController { @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Get(':id') - fetchOne(@Param('id') id: string): Promise { - return this.userService.fetchOne({ id: Number(id) }) + async fetchOne(@Param('id') id: string) { + return await this.userService.fetchOne({ id: Number(id) }) } @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Post('add') - add(@Body() data: UserDTO): Promise { - return this.userService.add(data) + async add(@Body() data: UserDTO) { + return await this.userService.add(data) } @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Put(':id') - update(@Param('id') id: string, @Body() data: UserDTO): Promise { + async update(@Param('id') id: string, @Body() data: UserDTO) { data.updatedAt = new Date() - return this.userService.update({ + return await this.userService.update({ where: { id: Number(id) }, data: data }) @@ -157,7 +157,7 @@ export class UserController { @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Delete(':id') - delete(@Param('id') id: string): Promise { - return this.userService.remove({ id: Number(id) }) + async delete(@Param('id') id: string): Promise { + return await this.userService.remove({ id: Number(id) }) } }