From 7ce649bb74008c21778d8fa3e20fecfe5f62711c 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:40 +0900 Subject: [PATCH] nestjs_auth init.. --- src/todo/todo.controller.ts | 22 +++++++++++----------- src/todo/todo.service.ts | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/todo/todo.controller.ts b/src/todo/todo.controller.ts index 834fc84..aa40ba4 100644 --- a/src/todo/todo.controller.ts +++ b/src/todo/todo.controller.ts @@ -17,7 +17,7 @@ export class TodoController { constructor(private readonly todoService: TodoService) {} @Get() - async fetchAll(@Query() query): Promise { + fetchAll(@Query() query) { console.log(query) //Field별 filter AND Sql용 @@ -106,8 +106,8 @@ export class TodoController { console.log(fetchSQL) //전체 갯수 및 fetched Data - const total = await this.todoService.count(fetchSQL) - const rows = await this.todoService.fetchAll(fetchSQL) + const total = this.todoService.count(fetchSQL) + const rows = this.todoService.fetchAll(fetchSQL) const result = { total: total, perPage: perPage, @@ -122,26 +122,26 @@ export class TodoController { } @Get(':id') - async fetchOne(@Param('id') id: string): Promise { - return await this.todoService.fetchOne({ id: Number(id) }) + fetchOne(@Param('id') id: string): Promise { + return this.todoService.fetchOne({ id: Number(id) }) } @Post() - async add(@Body() data: TodoDTO): Promise { - return await this.todoService.add(data) + add(@Body() data: TodoDTO): Promise { + return this.todoService.add(data) } @Put(':id') - async update(@Param('id') id: string, @Body() data: TodoDTO): Promise { + update(@Param('id') id: string, @Body() data: TodoDTO): Promise { data.updatedAt = new Date() - return await this.todoService.update({ + return this.todoService.update({ where: { id: Number(id) }, data: data }) } @Delete(':id') - async delete(@Param('id') id: string): Promise { - return await this.todoService.remove({ id: Number(id) }) + delete(@Param('id') id: string): Promise { + return this.todoService.remove({ id: Number(id) }) } } diff --git a/src/todo/todo.service.ts b/src/todo/todo.service.ts index 105090d..3e4ca3a 100644 --- a/src/todo/todo.service.ts +++ b/src/todo/todo.service.ts @@ -18,7 +18,7 @@ export class TodoService { where?: Prisma.TodoWhereInput }): Promise { const { cursor, where } = params - return await this.prisma.todo.count({ + return this.prisma.todo.count({ cursor, where }) @@ -33,7 +33,7 @@ export class TodoService { orderBy?: Prisma.TodoOrderByWithRelationInput }): Promise { const { skip, take, cursor, where, orderBy } = params - return await this.prisma.todo.findMany({ + return this.prisma.todo.findMany({ skip, take, cursor, @@ -44,12 +44,12 @@ export class TodoService { //단일 조회 async fetchOne(where: Prisma.TodoWhereInput): Promise { - return await this.prisma.todo.findFirstOrThrow({ where: where }) + return this.prisma.todo.findFirstOrThrow({ where: where }) } //단일 추가 async add(data: Prisma.TodoCreateInput): Promise { - return await this.prisma.todo.create({ data }) + return this.prisma.todo.create({ data }) } //단일 수정 @@ -58,7 +58,7 @@ export class TodoService { data: Prisma.TodoUpdateInput }): Promise { const { where, data } = params - return await this.prisma.todo.update({ + return this.prisma.todo.update({ data, where }) @@ -66,6 +66,6 @@ export class TodoService { //단일 삭제 async remove(where: Prisma.TodoWhereUniqueInput): Promise { - return await this.prisma.todo.delete({ where }) + return this.prisma.todo.delete({ where }) } }