From 1c28a128c2cd62740d721bf393a065375d9a8852 Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Sun, 4 Feb 2024 04:44:46 +0000 Subject: [PATCH 1/7] docs(be): re-write admin problem module api docs --- .../apps/admin/src/group/group.resolver.ts | 8 +- .../admin/Problem/Create Problem/Succeed.bru | 84 +++++++++++++++++++ .../Create Problem/UNPROCESSABLE (1).bru | 68 +++++++++++++++ .../Create Problem/UNPROCESSABLE (2).bru | 68 +++++++++++++++ .../Problem/Delete a Problem/NOT_FOUND.bru | 38 +++++++++ .../Problem/Delete a Problem/Succeed.bru | 43 +++++++++- .../NOT_FOUND.bru} | 8 +- .../Problem/Get Contest Problems/Succeed.bru | 51 +++++++++++ .../Get ContestProblems by ID/Succeed.bru | 48 ----------- .../admin/Problem/Get Problems/Succeed.bru | 57 +++++++++++++ .../Get WorkbookProblems by ID/Succeed.bru | 46 ---------- .../Succeed.bru} | 20 +++-- .../admin/Problem/Get a Problem/NOT_FOUND.bru | 38 +++++++++ .../admin/Problem/Get a Problem/Succeed.bru | 52 ++++++++++++ ...or: No Contest found.bru => NOT_FOUND.bru} | 10 +-- .../Update ContestProblems Order/Succeed.bru | 35 ++++---- ...Length not equal.bru => UNPROCESSABLE.bru} | 10 +-- ...r: No Workbook found.bru => NOT_FOUND.bru} | 6 +- .../Update WorkbookProblems Order/Succeed.bru | 37 ++++---- ...Length not equal.bru => UNPROCESSABLE.bru} | 10 +-- .../Problem/Update a Problem/Succeed.bru | 61 ++++++++++++++ .../Update a Problem/UNPROCESSABLE (1).bru | 56 +++++++++++++ .../Update a Problem/UNPROCESSABLE (2).bru | 56 +++++++++++++ 23 files changed, 740 insertions(+), 170 deletions(-) create mode 100644 collection/admin/Problem/Create Problem/Succeed.bru create mode 100644 collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru create mode 100644 collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru create mode 100644 collection/admin/Problem/Delete a Problem/NOT_FOUND.bru rename collection/admin/Problem/{Get ContestProblems by ID/Error: No Contest found.bru => Get Contest Problems/NOT_FOUND.bru} (73%) create mode 100644 collection/admin/Problem/Get Contest Problems/Succeed.bru delete mode 100644 collection/admin/Problem/Get ContestProblems by ID/Succeed.bru create mode 100644 collection/admin/Problem/Get Problems/Succeed.bru delete mode 100644 collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru rename collection/admin/Problem/{Get WorkbookProblems by ID/Error: No Workbook found.bru => Get WorkbookProblems/Succeed.bru} (53%) create mode 100644 collection/admin/Problem/Get a Problem/NOT_FOUND.bru create mode 100644 collection/admin/Problem/Get a Problem/Succeed.bru rename collection/admin/Problem/Update ContestProblems Order/{Error: No Contest found.bru => NOT_FOUND.bru} (76%) rename collection/admin/Problem/Update ContestProblems Order/{Error: Length not equal.bru => UNPROCESSABLE.bru} (72%) rename collection/admin/Problem/Update WorkbookProblems Order/{Error: No Workbook found.bru => NOT_FOUND.bru} (95%) rename collection/admin/Problem/Update WorkbookProblems Order/{Error: Length not equal.bru => UNPROCESSABLE.bru} (71%) create mode 100644 collection/admin/Problem/Update a Problem/Succeed.bru create mode 100644 collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru create mode 100644 collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru diff --git a/backend/apps/admin/src/group/group.resolver.ts b/backend/apps/admin/src/group/group.resolver.ts index 3cf4b1d35e..b1eadf30be 100644 --- a/backend/apps/admin/src/group/group.resolver.ts +++ b/backend/apps/admin/src/group/group.resolver.ts @@ -89,7 +89,9 @@ export class GroupResolver { } @Mutation(() => String) - async issueInvitation(@Args('groupId', GroupIDPipe) id: number) { + async issueInvitation( + @Args('groupId', { type: () => Int }, GroupIDPipe) id: number + ) { try { return await this.groupService.issueInvitation(id) } catch (error) { @@ -102,7 +104,9 @@ export class GroupResolver { } @Mutation(() => String) - async revokeInvitation(@Args('groupId', GroupIDPipe) id: number) { + async revokeInvitation( + @Args('groupId', { type: () => Int }, GroupIDPipe) id: number + ) { try { return await this.groupService.revokeInvitation(id) } catch (error) { diff --git a/collection/admin/Problem/Create Problem/Succeed.bru b/collection/admin/Problem/Create Problem/Succeed.bru new file mode 100644 index 0000000000..00f19a0b7a --- /dev/null +++ b/collection/admin/Problem/Create Problem/Succeed.bru @@ -0,0 +1,84 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Cpp"], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Create Problem + Problem을 생성합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | 생성된 Problem이 속할 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | input | CreateProblemInput | Problem 생성에 필요한 데이터 | + + ### Error Cases + #### UNPROCESSABLE(1) + Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. + #### UNPROCESSABLE(2) + Problem은 Template에 존재하는 프로그래밍 언어를 지원해야 합니다. +} diff --git a/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru b/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru new file mode 100644 index 0000000000..875fb7c5f8 --- /dev/null +++ b/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru @@ -0,0 +1,68 @@ +meta { + name: UNPROCESSABLE (1) + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": [], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq A problem should support at least one language +} diff --git a/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru b/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru new file mode 100644 index 0000000000..e089b78765 --- /dev/null +++ b/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru @@ -0,0 +1,68 @@ +meta { + name: UNPROCESSABLE (2) + type: graphql + seq: 3 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Python3"], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq This problem does not support Cpp +} diff --git a/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru b/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru new file mode 100644 index 0000000000..ddba780171 --- /dev/null +++ b/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru @@ -0,0 +1,38 @@ +meta { + name: NOT_FOUND + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation DeleteProblem($groupId: Int!, $id: Int!) { + deleteProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 99999, + "id": 5 + } +} + +assert { + res.body.errors[0].extensions.code: eq NOT_FOUND + res.body.errors[0].message: eq No Problem found +} diff --git a/collection/admin/Problem/Delete a Problem/Succeed.bru b/collection/admin/Problem/Delete a Problem/Succeed.bru index 523228f76e..09ebf7c3ab 100644 --- a/collection/admin/Problem/Delete a Problem/Succeed.bru +++ b/collection/admin/Problem/Delete a Problem/Succeed.bru @@ -6,6 +6,47 @@ meta { post { url: {{gqlUrl}} - body: none + body: graphql auth: none } + +body:graphql { + mutation DeleteProblem($groupId: Int!, $id: Int!) { + deleteProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "id": 5 + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Delete Problem + Problem을 삭제합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | 삭제할 Problem이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | id | Int | 삭제할 Problem의 id | + + ### Error Cases + #### NOT_FOUND + 존재하는 id, groupId를 사용해야 합니다. +} diff --git a/collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru similarity index 73% rename from collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru rename to collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru index a0e9888b25..a9a7716232 100644 --- a/collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru +++ b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Error: No Contest found + name: NOT_FOUND type: graphql seq: 2 } @@ -34,9 +34,3 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Contest found } - -docs { - # Error: No Contest found - - - `contestId`가 `groupId`에 속하지 않으면, `No Contest found` Error를 반환합니다. -} diff --git a/collection/admin/Problem/Get Contest Problems/Succeed.bru b/collection/admin/Problem/Get Contest Problems/Succeed.bru new file mode 100644 index 0000000000..49971aaeca --- /dev/null +++ b/collection/admin/Problem/Get Contest Problems/Succeed.bru @@ -0,0 +1,51 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetContestProblems($groupId: Int!, $contestId: Int!) { + getContestProblems(groupId: $groupId, contestId: $contestId) { + order + contestId + problemId + score + createTime + updateTime + } + } + +} + +body:graphql:vars { + { + "groupId": 1, + "contestId": 1 + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Get Contest Problems + Contest Problem들을 가져옵니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | contest가 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | contestId | Int | contest의 id | + + ### Error Cases + #### NOT_FOUND + 존재하는 group id와 contest id가 필요합니다. +} diff --git a/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru b/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru deleted file mode 100644 index 5008a6bbb8..0000000000 --- a/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru +++ /dev/null @@ -1,48 +0,0 @@ -meta { - name: Succeed - type: graphql - seq: 1 -} - -post { - url: {{gqlUrl}} - body: graphql - auth: none -} - -body:graphql { - query GetContestProblems($groupId: Int!, $contestId: Int!) { - getContestProblems(groupId: $groupId, contestId: $contestId) { - order - contestId - problemId - score - createTime - updateTime - } - } - -} - -body:graphql:vars { - { - "groupId": 1, - "contestId": 1 - } -} - -assert { - res.body.data.getContestProblems[0].order: isNumber - res.body.data.getContestProblems[0].contestId: isNumber - res.body.data.getContestProblems[0].problemId: isNumber - res.body.data.getContestProblems[0].score: isNumber - res.body.data.getContestProblems[0].createTime: isString - res.body.data.getContestProblems[0].createTime: isString -} - -docs { - # Get ContestProblems by ID - - - `contestId`와 `workbookId`를 이용하여, `WorkbookProblem`들을 모두 가져 옵니다. - - `contestId`가 `groupId`에 속하지 않으면, 에러를 반환합니다. -} diff --git a/collection/admin/Problem/Get Problems/Succeed.bru b/collection/admin/Problem/Get Problems/Succeed.bru new file mode 100644 index 0000000000..0cce046df0 --- /dev/null +++ b/collection/admin/Problem/Get Problems/Succeed.bru @@ -0,0 +1,57 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblems($groupId: Int!, $cursor: Int, $take: Int!, $input: FilterProblemsInput!) { + getProblems(groupId: $groupId, cursor: $cursor, take: $take, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "cursor": 1, + "take": 10, + "input": { + "difficulty": ["Level1", "Level2", "Level3", "Level4", "Level5"], + "languages": ["C", "Cpp", "Java", "Python3"] + } + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Get Problems + 조건에 맞는 Problem들을 가져옵니다. + 조건에 맞는 Problem이 없다면, 빈 배열을 반환합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | Problem이 속해있는 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | cursor | Int | pagenation을 위한 cursor값| + | take | Int | 가져올 값의 개수 | + | input | FilterProblemsInput | 가져올 Problem의 조건 지정을 위한 객체 | + +} diff --git a/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru deleted file mode 100644 index 525aabcd08..0000000000 --- a/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru +++ /dev/null @@ -1,46 +0,0 @@ -meta { - name: Succeed - type: graphql - seq: 1 -} - -post { - url: {{gqlUrl}} - body: graphql - auth: none -} - -body:graphql { - query GetWorkbookProblems($groupId: Int!, $workbookId: Int!) { - getWorkbookProblems(groupId: $groupId, workbookId: $workbookId) { - order - workbookId - problemId - createTime - updateTime - } - } - -} - -body:graphql:vars { - { - "groupId": 1, - "workbookId": 1 - } -} - -assert { - res.body.data.getWorkbookProblems[0].order: isNumber - res.body.data.getWorkbookProblems[0].workbookId: isNumber - res.body.data.getWorkbookProblems[0].problemId: isNumber - res.body.data.getWorkbookProblems[0].createTime: isString - res.body.data.getWorkbookProblems[0].updateTime: isString -} - -docs { - # Get WorkbookProblems by ID - - - `groupId`와 `workbookId`를 이용하여, `WorkbookProblem`들을 모두 가져 옵니다. - - `workbookId`가 `groupId`에 속하지 않으면, 에러를 반환합니다. -} diff --git a/collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru similarity index 53% rename from collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru rename to collection/admin/Problem/Get WorkbookProblems/Succeed.bru index 1c12907334..4569c9256b 100644 --- a/collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -1,7 +1,7 @@ meta { - name: Error: No Workbook found + name: Succeed type: graphql - seq: 2 + seq: 1 } post { @@ -26,16 +26,24 @@ body:graphql { body:graphql:vars { { "groupId": 1, - "workbookId": 99 + "workbookId": 1 } } assert { - res.body.errors[0].message: eq No Workbook found + res.body.data: isDefined } docs { - # Error: No Workbook found + ## Get WorkbookProblems + workbook problem들을 가져옵니다. - - `workbookId`가 `groupId`에 속하지 않으면, `No Workbook found` Error를 반환합니다. + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | workbook이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | workbookId | Int | workbook의 id | + + ### Error Cases + (TODO) } diff --git a/collection/admin/Problem/Get a Problem/NOT_FOUND.bru b/collection/admin/Problem/Get a Problem/NOT_FOUND.bru new file mode 100644 index 0000000000..d4271dce52 --- /dev/null +++ b/collection/admin/Problem/Get a Problem/NOT_FOUND.bru @@ -0,0 +1,38 @@ +meta { + name: NOT_FOUND + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblem($groupId: Int!, $id: Int!) { + getProblem(groupId: $groupId, id: $id) { + id + groupId + inputDescription + outputDescription + languages + submissionCount + difficulty + exposeTime + } + } +} + +body:graphql:vars { + { + "groupId": 99999, + "id": 1 + } +} + +assert { + res.body.errors[0].extensions.code: eq NOT_FOUND + res.body.errors[0].message: eq No Problem found +} diff --git a/collection/admin/Problem/Get a Problem/Succeed.bru b/collection/admin/Problem/Get a Problem/Succeed.bru new file mode 100644 index 0000000000..b7c2b289d3 --- /dev/null +++ b/collection/admin/Problem/Get a Problem/Succeed.bru @@ -0,0 +1,52 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblem($groupId: Int!, $id: Int!) { + getProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "id": 1 + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Get a Problem + Problem을 가져옵니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | Problem이 속해있는 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | id | Int | Problem의 id | + + ### Error Cases + #### NOT_FOUND + 존재하지 않는 groupId 또는 id를 전달하는 경우 발생합니다. +} diff --git a/collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru similarity index 76% rename from collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru rename to collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru index 43f62d6947..63c704baf5 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru +++ b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Erro: No Contest found + name: NOT_FOUND type: graphql seq: 1 } @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -35,9 +35,3 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Contest found } - -docs { - # Error: No Contest found - - - `contestId`가 `groupId`에 속하지 않으면, `No Contest found` Error를 반환합니다. -} diff --git a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru index 49c806347d..7ee333ad05 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -33,21 +33,26 @@ body:graphql:vars { } assert { - res.body.data.getContestProblems[0].order: isNumber - res.body.data.getContestProblems[0].contestId: isNumber - res.body.data.getContestProblems[0].problemId: isNumber - res.body.data.getContestProblems[0].score: isNumber - res.body.data.getContestProblems[0].createTime: isString - res.body.data.getContestProblems[0].createTime: isString + res.body.data: isDefined } docs { - # Update ContestProblems Order - - - `groupId`, `contestId` and `orders`가 필요합니다. - - `contestId`가 `groupId`에 속해있지 않으면 실패합니다. - - `orders`의 길이가 `contestId`에 속한 `problem`의 개수와 다르면 실패합니다. - - `orders`의 원소값은 `contestId`에 속한 `problemId`를 의미합니다. - - `orders`: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. - - 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + ## Update ContestProblems order + contest problems의 정렬 순서를 변경합니다. + + order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. + 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | contest가 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | contestId | Int | contest의 id | + | orders | Int[] | 변경할 정렬 순서 | + + ### Error Cases + #### UNPROCESSABLE + `orders`의 길이는 contest에 속한 문제들의 개수와 같아야 합니다. + #### NOT_FOUND + 존재하는 group id와 contest id가 필요합니다. } diff --git a/collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru similarity index 72% rename from collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru rename to collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru index a0c6d21d18..74dc89c398 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru +++ b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru @@ -1,5 +1,5 @@ meta { - name: Error: Length not equal + name: UNPROCESSABLE type: graphql seq: 1 } @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -35,9 +35,3 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of contestProblem are not equal. } - -docs { - # Error: the len of orders and the len of contestProblem are not equal - - - `orders`와 `contestId`에서 긁어온 `contestProblem`의 길이가 다를 때 발생하는 에러입니다. -} diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru similarity index 95% rename from collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru rename to collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru index c99518bbf2..f81292f565 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Error: No Workbook found + name: NOT_FOUND type: graphql seq: 1 } @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -37,6 +37,6 @@ assert { docs { # Error: No Workbook found - + - `workbookId`가 `groupId`에 속하지 않으면, `No Workbook found` Error를 반환합니다. } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru index 4ed0bd085e..666a08900b 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -31,22 +31,23 @@ body:graphql:vars { } } -assert { - res.body.data.getWorkbookProblems[0].order: isNumber - res.body.data.getWorkbookProblems[0].workbookId: isNumber - res.body.data.getWorkbookProblems[0].problemId: isNumber - res.body.data.getWorkbookProblems[0].createTime: isString - res.body.data.getWorkbookProblems[0].updateTime: isString -} - docs { - # Update WorkbookProblems Order - - - `groupId`, `workbookId` and `orders`가 필요합니다. - - `workbookId`가 `groupId`에 속해있지 않으면 실패합니다. - - `orders`의 길이가 `workbookId`에 속한 `problem`의 개수와 다르면 실패합니다. - - `orders`의 원소값은 `workbookId`에 속한 `problemId`를 의미합니다. - - `orders`: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. - - 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. - + ## Update WorkbookProblems order + workbook problems의 정렬 순서를 변경합니다. + + order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. + 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | workbook이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | workbookId | Int | workbook의 id | + | orders | Int[] | 변경할 정렬 순서 | + + ### Error Cases + #### UNPROCESSABLE + `orders`의 길이는 workbook에 속한 문제들의 개수와 같아야 합니다. + #### NOT_FOUND + 존재하는 group id와 workbook id가 필요합니다. } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru similarity index 71% rename from collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru rename to collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru index faa1abc27a..76c2139ef8 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru @@ -1,5 +1,5 @@ meta { - name: Error: Length not equal + name: UNPROCESSABLE type: graphql seq: 1 } @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -34,9 +34,3 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of workbookProblem are not equal. } - -docs { - # Error: the len of orders and the len of workbookProblem are not equal - - - `orders`와 `workbookId`에서 긁어온 `workbookProblem`의 길이가 다를 때 발생하는 에러입니다. -} diff --git a/collection/admin/Problem/Update a Problem/Succeed.bru b/collection/admin/Problem/Update a Problem/Succeed.bru new file mode 100644 index 0000000000..3a429b02e3 --- /dev/null +++ b/collection/admin/Problem/Update a Problem/Succeed.bru @@ -0,0 +1,61 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint" + } + } +} + +assert { + res.body.data: isDefined +} + +docs { + ## Update Problem + Problem 정보를 수정합니다. + + ### Args + | 이름 | 타입 | 설명 | + | -- | -- | -- | + | groupId | Int | 생성된 Problem이 속할 Group의 ID (기본값: `OPEN_SPACE_ID`) | + | input | UpdateProblemInput | 수정할 Problem 데이터 | + + ### Error Cases + #### UNPROCESSABLE(1) + 수정된 Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. + #### UNPROCESSABLE(2) + 수정된 Problem은 Template에 존재하는 프로그래밍 언어를 지원해야 합니다. +} diff --git a/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru new file mode 100644 index 0000000000..d1f645289a --- /dev/null +++ b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru @@ -0,0 +1,56 @@ +meta { + name: UNPROCESSABLE (1) + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": [] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq A problem should support at least one language +} diff --git a/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru new file mode 100644 index 0000000000..975c4e62ee --- /dev/null +++ b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru @@ -0,0 +1,56 @@ +meta { + name: UNPROCESSABLE (2) + type: graphql + seq: 3 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Python3"] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq This problem does not support Cpp +} From 13c463cd011ad49e3645de61e7a67958060e201f Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Sun, 4 Feb 2024 06:20:54 +0000 Subject: [PATCH 2/7] =?UTF-8?q?fix(be):=20add=20missing=20await=20-=20pris?= =?UTF-8?q?ma=20=EC=A0=91=EA=B7=BC=20=EC=BD=94=EB=93=9C=EC=97=90=20await?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC=20=EC=95=88=EB=90=98=EC=96=B4=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95=20-=20docs?= =?UTF-8?q?=20=EC=97=90=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/admin/src/problem/problem.resolver.ts | 8 ++++---- collection/admin/Problem/Get WorkbookProblems/Succeed.bru | 3 ++- .../Update ContestProblems Order/UNPROCESSABLE.bru | 1 + .../Update WorkbookProblems Order/UNPROCESSABLE.bru | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/apps/admin/src/problem/problem.resolver.ts b/backend/apps/admin/src/problem/problem.resolver.ts index 2b93a8142e..20765810d7 100644 --- a/backend/apps/admin/src/problem/problem.resolver.ts +++ b/backend/apps/admin/src/problem/problem.resolver.ts @@ -197,7 +197,7 @@ export class ProblemResolver { workbookId: number ) { try { - return this.problemService.getWorkbookProblems(groupId, workbookId) + return await this.problemService.getWorkbookProblems(groupId, workbookId) } catch (error) { if ( error instanceof UnprocessableDataException || @@ -226,7 +226,7 @@ export class ProblemResolver { @Args('orders', { type: () => [Int] }, ParseArrayPipe) orders: number[] ) { try { - return this.problemService.updateWorkbookProblemsOrder( + return await this.problemService.updateWorkbookProblemsOrder( groupId, workbookId, orders @@ -257,7 +257,7 @@ export class ProblemResolver { contestId: number ) { try { - return this.problemService.getContestProblems(groupId, contestId) + return await this.problemService.getContestProblems(groupId, contestId) } catch (error) { if ( error instanceof UnprocessableDataException || @@ -285,7 +285,7 @@ export class ProblemResolver { @Args('orders', { type: () => [Int] }, ParseArrayPipe) orders: number[] ) { try { - return this.problemService.updateContestProblemsOrder( + return await this.problemService.updateContestProblemsOrder( groupId, contestId, orders diff --git a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru index 4569c9256b..2501d4094c 100644 --- a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -45,5 +45,6 @@ docs { | workbookId | Int | workbook의 id | ### Error Cases - (TODO) + #### NOT_FOUND + 존재하는 groupId 또는 workbookId를 전달해야 합니다. } diff --git a/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru index 74dc89c398..ac070f4db8 100644 --- a/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru +++ b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru @@ -34,4 +34,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of contestProblem are not equal. + res.body.errors[0].extensions.code: eq UNPROCESSABLE } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru index 76c2139ef8..ee3aa9257c 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru @@ -33,4 +33,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of workbookProblem are not equal. + res.body.errors[0].extensions.code: eq UNPROCESSABLE } From c3d127303828c2411a41864b6db26f8881ada3d0 Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Mon, 5 Feb 2024 06:51:03 +0000 Subject: [PATCH 3/7] docs(be): modify assert option --- collection/admin/Problem/Create Problem/Succeed.bru | 2 +- collection/admin/Problem/Delete a Problem/Succeed.bru | 2 +- collection/admin/Problem/Get Contest Problems/Succeed.bru | 2 +- collection/admin/Problem/Get Problems/Succeed.bru | 2 +- collection/admin/Problem/Get WorkbookProblems/Succeed.bru | 2 +- collection/admin/Problem/Get a Problem/Succeed.bru | 2 +- .../admin/Problem/Update ContestProblems Order/Succeed.bru | 2 +- .../admin/Problem/Update WorkbookProblems Order/Succeed.bru | 4 ++++ collection/admin/Problem/Update a Problem/Succeed.bru | 2 +- 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/collection/admin/Problem/Create Problem/Succeed.bru b/collection/admin/Problem/Create Problem/Succeed.bru index 00f19a0b7a..803d9cffd1 100644 --- a/collection/admin/Problem/Create Problem/Succeed.bru +++ b/collection/admin/Problem/Create Problem/Succeed.bru @@ -63,7 +63,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.createProblem: isDefined } docs { diff --git a/collection/admin/Problem/Delete a Problem/Succeed.bru b/collection/admin/Problem/Delete a Problem/Succeed.bru index 09ebf7c3ab..c5d295be06 100644 --- a/collection/admin/Problem/Delete a Problem/Succeed.bru +++ b/collection/admin/Problem/Delete a Problem/Succeed.bru @@ -33,7 +33,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.deleteProblem: isDefined } docs { diff --git a/collection/admin/Problem/Get Contest Problems/Succeed.bru b/collection/admin/Problem/Get Contest Problems/Succeed.bru index 49971aaeca..a52432561f 100644 --- a/collection/admin/Problem/Get Contest Problems/Succeed.bru +++ b/collection/admin/Problem/Get Contest Problems/Succeed.bru @@ -32,7 +32,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.getContestProblems: isDefined } docs { diff --git a/collection/admin/Problem/Get Problems/Succeed.bru b/collection/admin/Problem/Get Problems/Succeed.bru index 0cce046df0..cde84e4574 100644 --- a/collection/admin/Problem/Get Problems/Succeed.bru +++ b/collection/admin/Problem/Get Problems/Succeed.bru @@ -38,7 +38,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.getProblems: isDefined } docs { diff --git a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru index 2501d4094c..c5d6f71e9f 100644 --- a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -31,7 +31,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.getWorkbookProblems: isDefined } docs { diff --git a/collection/admin/Problem/Get a Problem/Succeed.bru b/collection/admin/Problem/Get a Problem/Succeed.bru index b7c2b289d3..c559549c4c 100644 --- a/collection/admin/Problem/Get a Problem/Succeed.bru +++ b/collection/admin/Problem/Get a Problem/Succeed.bru @@ -33,7 +33,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.getProblem: isDefined } docs { diff --git a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru index 7ee333ad05..2d2ef49531 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru @@ -33,7 +33,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.updateContestProblemsOrder: isDefined } docs { diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru index 666a08900b..472ca3c284 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru @@ -31,6 +31,10 @@ body:graphql:vars { } } +assert { + res.body.data.updateWorkbookProblemsOrder: +} + docs { ## Update WorkbookProblems order workbook problems의 정렬 순서를 변경합니다. diff --git a/collection/admin/Problem/Update a Problem/Succeed.bru b/collection/admin/Problem/Update a Problem/Succeed.bru index 3a429b02e3..bb78d84338 100644 --- a/collection/admin/Problem/Update a Problem/Succeed.bru +++ b/collection/admin/Problem/Update a Problem/Succeed.bru @@ -40,7 +40,7 @@ body:graphql:vars { } assert { - res.body.data: isDefined + res.body.data.updateProblem: isDefined } docs { From 33df6caf580d1ced774b2ce007436b9be0a200dc Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Mon, 5 Feb 2024 06:57:24 +0000 Subject: [PATCH 4/7] =?UTF-8?q?docs(be):=20delete=20args=20table=20-=20?= =?UTF-8?q?=EC=83=88=EB=A1=AD=EA=B2=8C=20=EC=A0=95=ED=95=B4=EC=A7=84=20con?= =?UTF-8?q?vention=EC=97=90=20=EB=94=B0=EB=9D=BC=20args=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EB=AA=85=ED=95=98=EB=8A=94=20=ED=91=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collection/admin/Problem/Create Problem/Succeed.bru | 6 ------ collection/admin/Problem/Delete a Problem/Succeed.bru | 6 ------ .../admin/Problem/Get Contest Problems/Succeed.bru | 6 ------ collection/admin/Problem/Get Problems/Succeed.bru | 9 --------- .../admin/Problem/Get WorkbookProblems/Succeed.bru | 6 ------ collection/admin/Problem/Get a Problem/Succeed.bru | 6 ------ .../Problem/Update ContestProblems Order/Succeed.bru | 7 ------- .../Problem/Update WorkbookProblems Order/Succeed.bru | 9 +-------- collection/admin/Problem/Update a Problem/Succeed.bru | 6 ------ 9 files changed, 1 insertion(+), 60 deletions(-) diff --git a/collection/admin/Problem/Create Problem/Succeed.bru b/collection/admin/Problem/Create Problem/Succeed.bru index 803d9cffd1..c5f37c0fa4 100644 --- a/collection/admin/Problem/Create Problem/Succeed.bru +++ b/collection/admin/Problem/Create Problem/Succeed.bru @@ -70,12 +70,6 @@ docs { ## Create Problem Problem을 생성합니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | 생성된 Problem이 속할 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | input | CreateProblemInput | Problem 생성에 필요한 데이터 | - ### Error Cases #### UNPROCESSABLE(1) Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. diff --git a/collection/admin/Problem/Delete a Problem/Succeed.bru b/collection/admin/Problem/Delete a Problem/Succeed.bru index c5d295be06..7c7d5e85dc 100644 --- a/collection/admin/Problem/Delete a Problem/Succeed.bru +++ b/collection/admin/Problem/Delete a Problem/Succeed.bru @@ -40,12 +40,6 @@ docs { ## Delete Problem Problem을 삭제합니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | 삭제할 Problem이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | id | Int | 삭제할 Problem의 id | - ### Error Cases #### NOT_FOUND 존재하는 id, groupId를 사용해야 합니다. diff --git a/collection/admin/Problem/Get Contest Problems/Succeed.bru b/collection/admin/Problem/Get Contest Problems/Succeed.bru index a52432561f..68fa5e1ee2 100644 --- a/collection/admin/Problem/Get Contest Problems/Succeed.bru +++ b/collection/admin/Problem/Get Contest Problems/Succeed.bru @@ -39,12 +39,6 @@ docs { ## Get Contest Problems Contest Problem들을 가져옵니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | contest가 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | contestId | Int | contest의 id | - ### Error Cases #### NOT_FOUND 존재하는 group id와 contest id가 필요합니다. diff --git a/collection/admin/Problem/Get Problems/Succeed.bru b/collection/admin/Problem/Get Problems/Succeed.bru index cde84e4574..13d74aa306 100644 --- a/collection/admin/Problem/Get Problems/Succeed.bru +++ b/collection/admin/Problem/Get Problems/Succeed.bru @@ -45,13 +45,4 @@ docs { ## Get Problems 조건에 맞는 Problem들을 가져옵니다. 조건에 맞는 Problem이 없다면, 빈 배열을 반환합니다. - - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | Problem이 속해있는 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | cursor | Int | pagenation을 위한 cursor값| - | take | Int | 가져올 값의 개수 | - | input | FilterProblemsInput | 가져올 Problem의 조건 지정을 위한 객체 | - } diff --git a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru index c5d6f71e9f..80d927fc7e 100644 --- a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -38,12 +38,6 @@ docs { ## Get WorkbookProblems workbook problem들을 가져옵니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | workbook이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | workbookId | Int | workbook의 id | - ### Error Cases #### NOT_FOUND 존재하는 groupId 또는 workbookId를 전달해야 합니다. diff --git a/collection/admin/Problem/Get a Problem/Succeed.bru b/collection/admin/Problem/Get a Problem/Succeed.bru index c559549c4c..147d6fd720 100644 --- a/collection/admin/Problem/Get a Problem/Succeed.bru +++ b/collection/admin/Problem/Get a Problem/Succeed.bru @@ -40,12 +40,6 @@ docs { ## Get a Problem Problem을 가져옵니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | Problem이 속해있는 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | id | Int | Problem의 id | - ### Error Cases #### NOT_FOUND 존재하지 않는 groupId 또는 id를 전달하는 경우 발생합니다. diff --git a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru index 2d2ef49531..6424a35b55 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru @@ -43,13 +43,6 @@ docs { order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | contest가 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | contestId | Int | contest의 id | - | orders | Int[] | 변경할 정렬 순서 | - ### Error Cases #### UNPROCESSABLE `orders`의 길이는 contest에 속한 문제들의 개수와 같아야 합니다. diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru index 472ca3c284..a6a0e481da 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru @@ -32,7 +32,7 @@ body:graphql:vars { } assert { - res.body.data.updateWorkbookProblemsOrder: + res.body.data.updateWorkbookProblemsOrder: isDefined } docs { @@ -42,13 +42,6 @@ docs { order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | workbook이 속한 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | workbookId | Int | workbook의 id | - | orders | Int[] | 변경할 정렬 순서 | - ### Error Cases #### UNPROCESSABLE `orders`의 길이는 workbook에 속한 문제들의 개수와 같아야 합니다. diff --git a/collection/admin/Problem/Update a Problem/Succeed.bru b/collection/admin/Problem/Update a Problem/Succeed.bru index bb78d84338..7e6657ad9d 100644 --- a/collection/admin/Problem/Update a Problem/Succeed.bru +++ b/collection/admin/Problem/Update a Problem/Succeed.bru @@ -47,12 +47,6 @@ docs { ## Update Problem Problem 정보를 수정합니다. - ### Args - | 이름 | 타입 | 설명 | - | -- | -- | -- | - | groupId | Int | 생성된 Problem이 속할 Group의 ID (기본값: `OPEN_SPACE_ID`) | - | input | UpdateProblemInput | 수정할 Problem 데이터 | - ### Error Cases #### UNPROCESSABLE(1) 수정된 Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. From 1c25f69b13db0943a564a8ceedc02395e0cfa1d9 Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Mon, 5 Feb 2024 07:00:07 +0000 Subject: [PATCH 5/7] docs(be): modify assert --- collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru index a9a7716232..703aff49ca 100644 --- a/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru +++ b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru @@ -32,5 +32,5 @@ body:graphql:vars { } assert { - res.body.errors[0].message: eq No Contest found + res.body.errors[0].message: eq No Contest found does not exist } From 48cdb652b3f79e1e042f980bcb562e71f6956c4b Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Mon, 5 Feb 2024 07:03:59 +0000 Subject: [PATCH 6/7] fix(be): apply http error --- backend/apps/admin/src/problem/problem.resolver.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/apps/admin/src/problem/problem.resolver.ts b/backend/apps/admin/src/problem/problem.resolver.ts index 20765810d7..db0bcac843 100644 --- a/backend/apps/admin/src/problem/problem.resolver.ts +++ b/backend/apps/admin/src/problem/problem.resolver.ts @@ -13,7 +13,6 @@ import { AuthenticatedRequest } from '@libs/auth' import { OPEN_SPACE_ID } from '@libs/constants' import { ConflictFoundException, - EntityNotExistException, ForbiddenAccessException, UnprocessableDataException } from '@libs/exception' @@ -205,7 +204,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -238,7 +237,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -265,7 +264,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -297,7 +296,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) From 30a3de3a35dc4e863e854828f70ad1c7a7275725 Mon Sep 17 00:00:00 2001 From: Jaehyeon1020 Date: Mon, 5 Feb 2024 07:12:24 +0000 Subject: [PATCH 7/7] docs(be): modify api docs --- .../Get Contest Problems/NOT_FOUND.bru | 3 +- .../Get WorkbookProblems/NOT_FOUND.bru | 36 +++++++++++++++++++ .../Problem/Get WorkbookProblems/Succeed.bru | 2 +- .../NOT_FOUND.bru | 1 + .../NOT_FOUND.bru | 7 +--- 5 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru diff --git a/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru index 703aff49ca..8c7cedd9ba 100644 --- a/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru +++ b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru @@ -32,5 +32,6 @@ body:graphql:vars { } assert { - res.body.errors[0].message: eq No Contest found does not exist + res.body.errors[0].message: eq No Contest found + res.body.errors[0].extensions.code: eq NOT_FOUND } diff --git a/collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru b/collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru new file mode 100644 index 0000000000..d1994bd90c --- /dev/null +++ b/collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru @@ -0,0 +1,36 @@ +meta { + name: NOT_FOUND + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetWorkbookProblems($groupId: Int!, $workbookId: Int!) { + getWorkbookProblems(groupId: $groupId, workbookId: $workbookId) { + order + workbookId + problemId + createTime + updateTime + } + } + +} + +body:graphql:vars { + { + "groupId": 99999, + "workbookId": 1 + } +} + +assert { + res.body.errors[0].extensions.code: eq NOT_FOUND + res.body.errors[0].message: eq No Workbook found +} diff --git a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru index 80d927fc7e..8f58fe9df8 100644 --- a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -31,7 +31,7 @@ body:graphql:vars { } assert { - res.body.data.getWorkbookProblems: isDefined + res.body.data.getWorkbookProblems: isDefined NOT_FOUND } docs { diff --git a/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru index 63c704baf5..2a56432f22 100644 --- a/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru +++ b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru @@ -34,4 +34,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Contest found + res.body.errors[0].extensions.code: eq NOT_FOUND } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru index f81292f565..2be3c19001 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru @@ -33,10 +33,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Workbook found -} - -docs { - # Error: No Workbook found - - - `workbookId`가 `groupId`에 속하지 않으면, `No Workbook found` Error를 반환합니다. + res.body.errors[0].extensions.code: eq NOT_FOUND }