From 710f50cf993fd45ac68162a7184a8fa8667fff25 Mon Sep 17 00:00:00 2001 From: Lee-won-hyeok Date: Mon, 19 Feb 2024 12:33:45 +0000 Subject: [PATCH] docs: submission bruno docs & rename API --- .../admin/src/announcement/announcement.resolver.ts | 12 ++++++------ .../admin/src/announcement/announcement.service.ts | 6 ++---- .../Error: Invalid Problem ID.bru | 1 + .../Announcement/Create Announcement/Succeed.bru | 1 + .../admin/Announcement/Get Announcement/Succeed.bru | 1 + .../admin/Announcement/Get Announcements/Succeed.bru | 5 ++++- .../Error: Invalid Announcement ID.bru | 5 +---- .../Announcement/Update Announcement/Succeed.bru | 5 +---- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/backend/apps/admin/src/announcement/announcement.resolver.ts b/backend/apps/admin/src/announcement/announcement.resolver.ts index d23a665f6c..390ca650e0 100644 --- a/backend/apps/admin/src/announcement/announcement.resolver.ts +++ b/backend/apps/admin/src/announcement/announcement.resolver.ts @@ -31,13 +31,13 @@ export class AnnouncementResolver { } } - @Query(() => [Announcement], { name: 'getAnnouncementsByProblemId' }) - async getAnnouncementsByProblemId( + @Query(() => [Announcement], { name: 'getAnnouncements' }) + async getAnnouncements( @Args('contestId', { type: () => Int }) contestId: number, @Args('problemId', { type: () => Int, nullable: true }) problemId?: number ) { try { - return await this.announcementService.getAnnouncementsByProblemId( + return await this.announcementService.getAnnouncements( contestId, problemId ) @@ -47,10 +47,10 @@ export class AnnouncementResolver { } } - @Query(() => Announcement, { name: 'getAnnouncement' }) - async getAnnouncement(@Args('id', { type: () => Int }) id: number) { + @Query(() => Announcement, { name: 'getAnnouncementById' }) + async getAnnouncementById(@Args('id', { type: () => Int }) id: number) { try { - return await this.announcementService.getAnnouncement(id) + return await this.announcementService.getAnnouncementById(id) } catch (error) { if (error instanceof EntityNotExistException) { throw error.convert2HTTPException() diff --git a/backend/apps/admin/src/announcement/announcement.service.ts b/backend/apps/admin/src/announcement/announcement.service.ts index a025b47731..a473509c96 100644 --- a/backend/apps/admin/src/announcement/announcement.service.ts +++ b/backend/apps/admin/src/announcement/announcement.service.ts @@ -51,8 +51,7 @@ export class AnnouncementService { }) } - //getAnnouncements - async getAnnouncementsByProblemId(contestId: number, problemId?: number) { + async getAnnouncements(contestId: number, problemId?: number) { return await this.prisma.announcement.findMany({ where: { ...(problemId && { problemId }), @@ -61,8 +60,7 @@ export class AnnouncementService { }) } - //getAnnouncementById - async getAnnouncement(id: number) { + async getAnnouncementById(id: number) { const announcement = await this.prisma.announcement .findFirstOrThrow({ where: { diff --git a/collection/admin/Announcement/Create Announcement/Error: Invalid Problem ID.bru b/collection/admin/Announcement/Create Announcement/Error: Invalid Problem ID.bru index 6e33c96803..940c743d1d 100644 --- a/collection/admin/Announcement/Create Announcement/Error: Invalid Problem ID.bru +++ b/collection/admin/Announcement/Create Announcement/Error: Invalid Problem ID.bru @@ -15,6 +15,7 @@ body:graphql { createAnnouncement( createAnnouncementInput: { problemId: -9999999 + contestId: -9999999 content: "this is new announcment!" } ) { diff --git a/collection/admin/Announcement/Create Announcement/Succeed.bru b/collection/admin/Announcement/Create Announcement/Succeed.bru index b6936ed4ba..52de5f4f64 100644 --- a/collection/admin/Announcement/Create Announcement/Succeed.bru +++ b/collection/admin/Announcement/Create Announcement/Succeed.bru @@ -15,6 +15,7 @@ body:graphql { createAnnouncement( createAnnouncementInput: { problemId: 1 + contestId: 1 content: "this is new announcement" } ) { diff --git a/collection/admin/Announcement/Get Announcement/Succeed.bru b/collection/admin/Announcement/Get Announcement/Succeed.bru index ef1f00c2f6..46a97f8b6a 100644 --- a/collection/admin/Announcement/Get Announcement/Succeed.bru +++ b/collection/admin/Announcement/Get Announcement/Succeed.bru @@ -17,6 +17,7 @@ body:graphql { ) { id problemId + contestId content } } diff --git a/collection/admin/Announcement/Get Announcements/Succeed.bru b/collection/admin/Announcement/Get Announcements/Succeed.bru index 09e4a51285..bcf89eacb8 100644 --- a/collection/admin/Announcement/Get Announcements/Succeed.bru +++ b/collection/admin/Announcement/Get Announcements/Succeed.bru @@ -13,10 +13,12 @@ post { body:graphql { query { getAnnouncementsByProblemId( + contestId: 1 problemId: 1 ) { id problemId + contestId content } } @@ -31,5 +33,6 @@ docs { ### Args | 이름 | 타입 | 설명| |--|--|--| - |problemId|int|Announment를 조회할 문제의 id| + |contestId|int|Announment를 조회할 contest의 id| + |problemId|int|Announment를 조회할 문제의 id (optional)| } diff --git a/collection/admin/Announcement/Update Announcement/Error: Invalid Announcement ID.bru b/collection/admin/Announcement/Update Announcement/Error: Invalid Announcement ID.bru index 7528d2a55b..0bf9f6a19e 100644 --- a/collection/admin/Announcement/Update Announcement/Error: Invalid Announcement ID.bru +++ b/collection/admin/Announcement/Update Announcement/Error: Invalid Announcement ID.bru @@ -14,10 +14,7 @@ body:graphql { mutation { updateAnnouncement( id: -99999 - announcementInput: { - problemId: 2 - content: "updated announcement" - } + content: "updated announcement" ) { id problemId diff --git a/collection/admin/Announcement/Update Announcement/Succeed.bru b/collection/admin/Announcement/Update Announcement/Succeed.bru index 4b67c73af4..0d1c89eb24 100644 --- a/collection/admin/Announcement/Update Announcement/Succeed.bru +++ b/collection/admin/Announcement/Update Announcement/Succeed.bru @@ -14,10 +14,7 @@ body:graphql { mutation { updateAnnouncement( id: 1 - announcementInput: { - problemId: 2 - content: "updated announcement" - } + content: "updated announcement" ) { id problemId