-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl MEE 006 008 010 api #1217
Open
ChaeyeonAhn
wants to merge
8
commits into
dev
Choose a base branch
from
1215-impl-mee-005-007-009-api
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+534
−2
Open
Impl MEE 006 008 010 api #1217
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d299459
feat: impl mee006
ChaeyeonAhn 3b2942e
feat: impl mee008
ChaeyeonAhn 56ee88b
feat: impl mee010
ChaeyeonAhn eda5b29
Merge branch 'dev' into 1215-impl-mee-005-007-009-api
ChaeyeonAhn 1f84d70
fix: merge conflict
ChaeyeonAhn 9ffcdf0
fix: change meeting schema and create agenda module
ChaeyeonAhn e2372e1
feat: add update on meeting table, status enum
ChaeyeonAhn bdd3313
feat: add module and fix repository
ChaeyeonAhn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/api/src/feature/meeting/agenda/agenda.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Delete, | ||
Param, | ||
Patch, | ||
Post, | ||
UsePipes, | ||
} from "@nestjs/common"; | ||
|
||
import apiMee006, { | ||
ApiMee006RequestBody, | ||
ApiMee006RequestParam, | ||
ApiMee006ResponseCreated, | ||
} from "@sparcs-clubs/interface/api/meeting/apiMee006"; | ||
|
||
import apiMee008, { | ||
ApiMee008RequestBody, | ||
ApiMee008RequestParam, | ||
ApiMee008ResponseOk, | ||
} from "@sparcs-clubs/interface/api/meeting/apiMee008"; | ||
|
||
import apiMee010, { | ||
ApiMee010RequestParam, | ||
ApiMee010ResponseOk, | ||
} from "@sparcs-clubs/interface/api/meeting/apiMee010"; | ||
|
||
import { ZodPipe } from "@sparcs-clubs/api/common/pipe/zod-pipe"; | ||
import { Executive } from "@sparcs-clubs/api/common/util/decorators/method-decorator"; | ||
import { GetExecutive } from "@sparcs-clubs/api/common/util/decorators/param-decorator"; | ||
|
||
import { AgendaService } from "./agenda.service"; | ||
|
||
@Controller() | ||
export default class AgendaController { | ||
constructor(private meetingService: AgendaService) {} | ||
|
||
@Executive() | ||
@Post("/executive/meetings/meeting/:meetingId/agendas/agenda") | ||
@UsePipes(new ZodPipe(apiMee006)) | ||
async postExecutiveMeetingAgenda( | ||
@GetExecutive() user: GetExecutive, | ||
@Param() { meetingId }: ApiMee006RequestParam, | ||
@Body() { meetingEnumId, description, title }: ApiMee006RequestBody, | ||
): Promise<ApiMee006ResponseCreated> { | ||
const result = await this.meetingService.postExecutiveMeetingAgenda( | ||
user.executiveId, | ||
meetingId, | ||
meetingEnumId, | ||
description, | ||
title, | ||
); | ||
return result; | ||
} | ||
|
||
@Executive() | ||
@Patch("/executive/meetings/meeting/:meetingId/agendas/agenda/:agendaId") | ||
@UsePipes(new ZodPipe(apiMee008)) | ||
async patchExecutiveMeetingAgenda( | ||
@GetExecutive() user: GetExecutive, | ||
@Param() { agendaId }: ApiMee008RequestParam, | ||
@Body() { agendaEnumId, description, title }: ApiMee008RequestBody, | ||
): Promise<ApiMee008ResponseOk> { | ||
const result = await this.meetingService.patchExecutiveMeetingAgenda( | ||
user.executiveId, | ||
agendaId, | ||
agendaEnumId, | ||
description, | ||
title, | ||
); | ||
return result; | ||
} | ||
|
||
@Executive() | ||
@Delete("/executive/meetings/meeting/:meetingId/agendas/agenda/:agendaId") | ||
@UsePipes(new ZodPipe(apiMee010)) | ||
async deleteExecutiveMeetingAgenda( | ||
@GetExecutive() user: GetExecutive, | ||
@Param() { meetingId, agendaId }: ApiMee010RequestParam, | ||
): Promise<ApiMee010ResponseOk> { | ||
const result = await this.meetingService.deleteExecutiveMeetingAgenda( | ||
user.executiveId, | ||
meetingId, | ||
agendaId, | ||
); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Module } from "@nestjs/common"; | ||
|
||
import { DrizzleModule } from "@sparcs-clubs/api/drizzle/drizzle.module"; | ||
import UserModule from "@sparcs-clubs/api/feature/user/user.module"; | ||
|
||
import { MeetingRepository } from "../meeting.repository"; | ||
|
||
import AgendaController from "./agenda.controller"; | ||
|
||
import { AgendaService } from "./agenda.service"; | ||
|
||
@Module({ | ||
imports: [DrizzleModule, UserModule], | ||
providers: [AgendaService, MeetingRepository], | ||
controllers: [AgendaController], | ||
}) | ||
export class AgendaModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { | ||
HttpException, | ||
HttpStatus, | ||
Injectable, | ||
UnauthorizedException, | ||
} from "@nestjs/common"; | ||
|
||
import { ApiMee006ResponseCreated } from "@sparcs-clubs/interface/api/meeting/apiMee006"; | ||
|
||
import { ApiMee008ResponseOk } from "@sparcs-clubs/interface/api/meeting/apiMee008"; | ||
|
||
import { ApiMee010ResponseOk } from "@sparcs-clubs/interface/api/meeting/apiMee010"; | ||
|
||
import UserPublicService from "@sparcs-clubs/api/feature/user/service/user.public.service"; | ||
|
||
import { MeetingRepository } from "../meeting.repository"; | ||
|
||
@Injectable() | ||
export class AgendaService { | ||
constructor( | ||
private readonly meetingRepository: MeetingRepository, | ||
private readonly userPublicService: UserPublicService, | ||
) {} | ||
|
||
async postExecutiveMeetingAgenda( | ||
executiveId: number, | ||
meetingId: number, | ||
meetingEnumId: number, | ||
description: string, | ||
title: string, | ||
): Promise<ApiMee006ResponseCreated> { | ||
const user = await this.userPublicService.getExecutiveById({ | ||
id: executiveId, | ||
}); | ||
|
||
if (!user) { | ||
throw new UnauthorizedException("Not allowed type"); | ||
} | ||
|
||
await this.meetingRepository.insertMeetingAgendaAndMapping( | ||
meetingId, | ||
meetingEnumId, | ||
description, | ||
title, | ||
); | ||
|
||
return {}; | ||
} | ||
|
||
async patchExecutiveMeetingAgenda( | ||
executiveId: number, | ||
agendaId: number, | ||
agendaEnumId: number, | ||
description: string, | ||
title: string, | ||
): Promise<ApiMee008ResponseOk> { | ||
const user = await this.userPublicService.getExecutiveById({ | ||
id: executiveId, | ||
}); | ||
|
||
if (!user) { | ||
throw new HttpException("Executive not found", HttpStatus.NOT_FOUND); | ||
} | ||
|
||
await this.meetingRepository.updateMeetingAgenda( | ||
agendaId, | ||
agendaEnumId, | ||
description, | ||
title, | ||
); | ||
|
||
return {}; | ||
} | ||
|
||
async deleteExecutiveMeetingAgenda( | ||
executiveId: number, | ||
meetingId: number, | ||
agendaId: number, | ||
): Promise<ApiMee010ResponseOk> { | ||
const user = await this.userPublicService.getExecutiveById({ | ||
id: executiveId, | ||
}); | ||
|
||
if (!user) { | ||
throw new HttpException("Executive not found", HttpStatus.NOT_FOUND); | ||
} | ||
|
||
await this.meetingRepository.deleteMeetingAgendaMapping( | ||
meetingId, | ||
agendaId, | ||
); | ||
|
||
return {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 원래는 서비스 + 컨트롤러 + 레포지토리가 전부 모듈 안으로 들어오는게 좋다고 생각했는데, 이번에는 한 쿼리가 agenda가 아닌 테이블도 건드리다 보니까 그 범위가 애매하다고 느껴집니다. 가능한 한 agendarepository 안으로 가져오고, 한 트랜잭션으로 묶이지 않아도 괜찮을 것 같은 쿼리를 분리하는 것에 대해 어떻게 생각해요?