From c9ad8b32e17f392e916d1ec951adb8e8a9ba422d Mon Sep 17 00:00:00 2001 From: kim jong hwa Date: Wed, 18 Oct 2023 17:35:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[=EC=9E=91=EC=97=85=EC=A4=91]:=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/data.controller.ts | 2 +- src/data/interface/verify.ts | 2 +- src/events/events.controller.ts | 6 +++--- src/events/events.service.ts | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/data/data.controller.ts b/src/data/data.controller.ts index c669712..9a376cb 100644 --- a/src/data/data.controller.ts +++ b/src/data/data.controller.ts @@ -50,7 +50,7 @@ export class DataController { return this.dataService.filteredEventByCategory(query); } - @Get('filter/verifiy') + @Get('filter/verify') @ApiOperation({ summary: '이벤트 필터링(위치인증)' }) @ApiQuery({ name: 'verify', type: String, required: true }) filteredEventByVerify(@Query() query: Verify) { diff --git a/src/data/interface/verify.ts b/src/data/interface/verify.ts index 3e10eb5..df8c1fd 100644 --- a/src/data/interface/verify.ts +++ b/src/data/interface/verify.ts @@ -2,7 +2,7 @@ export interface Verify { verify: string; } -const verifies: Verify[] = [{ verify: 'yes' }, { verify: 'no' }]; +const verifies: Verify[] = [{ verify: '🙋‍♀️아무나' }, { verify: '🏡동네만' }]; export const toss = { category: ['☕맛집/커피', '🏃‍♂️운동/건강', '🐾애완동물', '📕공부/교육'], diff --git a/src/events/events.controller.ts b/src/events/events.controller.ts index b120949..0da615e 100644 --- a/src/events/events.controller.ts +++ b/src/events/events.controller.ts @@ -13,6 +13,7 @@ import { ParseIntPipe, UploadedFile, UseInterceptors, + Query, } from '@nestjs/common'; import { EventsService } from './events.service'; import { CreateEventDto } from './dto/create-event.dto'; @@ -91,9 +92,8 @@ export class EventsController { @Get() @ApiOperation({ summary: 'Event 전체 조회' }) @ApiOkResponse({ type: EventEntity, isArray: true }) - async findAll() { - const events = await this.eventsService.findAll(); - console.log(events) + async findAll(@Query('lastPage', ParseIntPipe) lastPage:number) { + const events = await this.eventsService.findAll(lastPage); const event = events.map((item) => { const { GuestEvents, HostEvents, ...rest } = item; const hostUser = item.HostEvents[0].User.UserDetail; diff --git a/src/events/events.service.ts b/src/events/events.service.ts index e4937a9..58244d0 100644 --- a/src/events/events.service.ts +++ b/src/events/events.service.ts @@ -36,8 +36,11 @@ export class EventsService { return file.path } - findAll() { + findAll(lastPage: number) { return this.prisma.event.findMany({ + take: 10, + skip: lastPage ? 1 : 0, + ...(lastPage && {cursor: {eventId: lastPage}}), where: { isDeleted: false, }, From a7fe936a4a688cd9da0eb28880c25bc9df8c964f Mon Sep 17 00:00:00 2001 From: kim jong hwa Date: Thu, 19 Oct 2023 11:13:35 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[=EC=9E=91=EC=97=85=EC=99=84=EB=A3=8C]:=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=B0=B8=EC=84=9D=20response=20?= =?UTF-8?q?=EA=B0=92=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/events.controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/events/events.controller.ts b/src/events/events.controller.ts index 0da615e..e8850bf 100644 --- a/src/events/events.controller.ts +++ b/src/events/events.controller.ts @@ -143,14 +143,14 @@ export class EventsController { const { userId } = req.user; const isJoin = await this.eventsService.isJoin(eventId, userId); if (!isJoin) { - this.eventsService.join(+eventId, userId); + this.eventsService.join(eventId, userId); this.eventsService.createRsvpLog(eventId, userId, 'applied'); // 로그 생성 - return `${eventId}번 모임 참석 신청!`; + return {userId, eventId}; } if (isJoin) { this.eventsService.cancelJoin(isJoin.guestEventId); this.eventsService.createRsvpLog(eventId, userId, 'canceled'); // 로그 생성 - return `${eventId}번 모임 신청 취소!`; + return {userId, eventId}; } }