Skip to content

Commit

Permalink
docs: submission bruno docs & rename API
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-won-hyeok committed Feb 19, 2024
1 parent 2c4a950 commit 710f50c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
12 changes: 6 additions & 6 deletions backend/apps/admin/src/announcement/announcement.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions backend/apps/admin/src/announcement/announcement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand All @@ -61,8 +60,7 @@ export class AnnouncementService {
})
}

//getAnnouncementById
async getAnnouncement(id: number) {
async getAnnouncementById(id: number) {
const announcement = await this.prisma.announcement
.findFirstOrThrow({
where: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body:graphql {
createAnnouncement(
createAnnouncementInput: {
problemId: -9999999
contestId: -9999999
content: "this is new announcment!"
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body:graphql {
createAnnouncement(
createAnnouncementInput: {
problemId: 1
contestId: 1
content: "this is new announcement"
}
) {
Expand Down
1 change: 1 addition & 0 deletions collection/admin/Announcement/Get Announcement/Succeed.bru
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ body:graphql {
) {
id
problemId
contestId
content
}
}
Expand Down
5 changes: 4 additions & 1 deletion collection/admin/Announcement/Get Announcements/Succeed.bru
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ post {
body:graphql {
query {
getAnnouncementsByProblemId(
contestId: 1
problemId: 1
) {
id
problemId
contestId
content
}
}
Expand All @@ -31,5 +33,6 @@ docs {
### Args
| 이름 | 타입 | 설명|
|--|--|--|
|problemId|int|Announment를 조회할 문제의 id|
|contestId|int|Announment를 조회할 contest의 id|
|problemId|int|Announment를 조회할 문제의 id (optional)|
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ body:graphql {
mutation {
updateAnnouncement(
id: -99999
announcementInput: {
problemId: 2
content: "updated announcement"
}
content: "updated announcement"
) {
id
problemId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ body:graphql {
mutation {
updateAnnouncement(
id: 1
announcementInput: {
problemId: 2
content: "updated announcement"
}
content: "updated announcement"
) {
id
problemId
Expand Down

0 comments on commit 710f50c

Please sign in to comment.