From f54195bb8a012ace955138a91aeebeb4f457ab45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sat, 10 Sep 2022 22:00:32 +0900 Subject: [PATCH] nestjs_auth... --- src/auth/auth.service.ts | 2 +- src/user/user.controller.ts | 22 +++++++++++----------- src/user/user.service.ts | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 9176b60..20e6306 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -40,6 +40,6 @@ export class AuthService { async register(data: UserDTO): Promise { const user = await this.userService.add(data) if (!user) return null - return await this.getTokens(user) + return this.getTokens(user) } } diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index 8d182f3..5450f09 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() - async fetchAll(@Query() query): Promise { + fetchAll(@Query() query) { console.log(query) //Field별 filter AND Sql용 @@ -114,8 +114,8 @@ export class UserController { console.log(fetchSQL) //전체 갯수 및 fetched Data - const total = await this.userService.count(fetchSQL) - const rows = await this.userService.fetchAll(fetchSQL) + const total = this.userService.count(fetchSQL) + const rows = 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') - async fetchOne(@Param('id') id: string): Promise { - return await this.userService.fetchOne({ id: Number(id) }) + fetchOne(@Param('id') id: string): Promise { + return this.userService.fetchOne({ id: Number(id) }) } @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Post('add') - async add(@Body() data: UserDTO): Promise { - return await this.userService.add(data) + add(@Body() data: UserDTO): Promise { + return this.userService.add(data) } @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Put(':id') - async update(@Param('id') id: string, @Body() data: UserDTO): Promise { + update(@Param('id') id: string, @Body() data: UserDTO): Promise { data.updatedAt = new Date() - return await this.userService.update({ + return this.userService.update({ where: { id: Number(id) }, data: data }) @@ -157,7 +157,7 @@ export class UserController { @Roles(ROLE.ADMIN) @UseGuards(JwtAuthGuard, RolesGuard) @Delete(':id') - async delete(@Param('id') id: string): Promise { - return await this.userService.remove({ id: Number(id) }) + delete(@Param('id') id: string): Promise { + return this.userService.remove({ id: Number(id) }) } } diff --git a/src/user/user.service.ts b/src/user/user.service.ts index c695715..037f381 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -18,7 +18,7 @@ export class UserService { where?: Prisma.UserWhereInput }): Promise { const { cursor, where } = params - return await this.prisma.user.count({ + return this.prisma.user.count({ cursor, where }) @@ -33,7 +33,7 @@ export class UserService { orderBy?: Prisma.UserOrderByWithRelationInput }): Promise { const { skip, take, cursor, where, orderBy } = params - return await this.prisma.user.findMany({ + return this.prisma.user.findMany({ skip, take, cursor, @@ -44,12 +44,12 @@ export class UserService { //단일 조회 async fetchOne(where: Prisma.UserWhereInput): Promise { - return await this.prisma.user.findFirstOrThrow({ where: where }) + return this.prisma.user.findFirstOrThrow({ where: where }) } //단일 추가 async add(data: Prisma.UserCreateInput): Promise { - return await this.prisma.user.create({ data }) + return this.prisma.user.create({ data }) } //단일 수정 @@ -58,7 +58,7 @@ export class UserService { data: Prisma.UserUpdateInput }): Promise { const { where, data } = params - return await this.prisma.user.update({ + return this.prisma.user.update({ data, where }) @@ -66,6 +66,6 @@ export class UserService { //단일 삭제 async remove(where: Prisma.UserWhereUniqueInput): Promise { - return await this.prisma.user.delete({ where }) + return this.prisma.user.delete({ where }) } }