-
Notifications
You must be signed in to change notification settings - Fork 0
ERD 기반 Entity 구성 (question, question-solution, answer-evalutaion, answer-submission, category, audio-asset) #106
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
330fd82
feat(#104): question, answer 도메인 엔티티 초기 설정
rwaeng 0eb479e
feat(#104): category, audio-asset 도메인 엔티티 초기 설정
rwaeng 15aeba2
feat(#104): question, answer 도메인 엔티티 필요한 관계 매핑
rwaeng ef7f792
fix(#104): 엔티티 관계 수정
rwaeng 4fb814e
fix(#104): attempts_id -> submission_id로 이름 변경
rwaeng 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
22 changes: 22 additions & 0 deletions
22
apps/api/src/answer-evaluation/answer-evaluation.constants.ts
This file contains hidden or 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,22 @@ | ||
| const AccuracyEval = { | ||
| PERFECT: 'PERFECT', | ||
| MINOR_ERROR: 'MINOR_ERROR', | ||
| WRONG: 'WRONG', | ||
| } as const; | ||
| type AccuracyEval = (typeof AccuracyEval)[keyof typeof AccuracyEval]; | ||
|
|
||
| const LogicEval = { | ||
| CLEAR: 'CLEAR', | ||
| WEAK: 'WEAK', | ||
| NONE: 'NONE', | ||
| } as const; | ||
| type LogicEval = (typeof LogicEval)[keyof typeof LogicEval]; | ||
|
|
||
| const DepthEval = { | ||
| DEEP: 'DEEP', | ||
| BASIC: 'BASIC', | ||
| NONE: 'NONE', | ||
| } as const; | ||
| type DepthEval = (typeof DepthEval)[keyof typeof DepthEval]; | ||
|
|
||
| export { AccuracyEval, LogicEval, DepthEval }; |
56 changes: 56 additions & 0 deletions
56
apps/api/src/answer-evaluation/answer-evaluation.entity.ts
This file contains hidden or 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,56 @@ | ||
| import { | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| Column, | ||
| CreateDateColumn, | ||
| OneToOne, | ||
| JoinColumn, | ||
| } from 'typeorm'; | ||
| import { | ||
| AccuracyEval, | ||
| LogicEval, | ||
| DepthEval, | ||
| } from './answer-evaluation.constants'; | ||
| import { AnswerSubmission } from 'src/answer-submission/answer-submission.entity'; | ||
|
|
||
| @Entity('answer_evaluations') | ||
| class AnswerEvaluation { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ name: 'attempt_id', type: 'int' }) | ||
| attemptId: number; | ||
|
|
||
| @Column({ name: 'feedback_message', type: 'text' }) | ||
| feedbackMessage: string; | ||
|
|
||
| @Column({ name: 'detail_analysis', type: 'jsonb' }) | ||
| detailAnalysis: any; | ||
|
|
||
| @Column({ name: 'score_details', type: 'jsonb' }) | ||
| scoreDetails: any; | ||
|
|
||
| @Column({ name: 'accuracy_eval', type: 'enum', enum: AccuracyEval }) | ||
| accuracyEval: AccuracyEval; | ||
|
|
||
| @Column({ name: 'logic_eval', type: 'enum', enum: LogicEval }) | ||
| logicEval: LogicEval; | ||
|
|
||
| @Column({ name: 'depth_eval', type: 'enum', enum: DepthEval }) | ||
| depthEval: DepthEval; | ||
|
|
||
| @Column({ name: 'has_application', type: 'boolean', default: false }) | ||
| hasApplication: boolean; | ||
|
|
||
| @Column({ name: 'is_complete_sentence', type: 'boolean', default: false }) | ||
| isCompleteSentence: boolean; | ||
|
|
||
| @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) | ||
| createdAt: Date; | ||
|
|
||
| @OneToOne(() => AnswerSubmission) | ||
| @JoinColumn({ name: 'attempt_id' }) | ||
| submission: AnswerSubmission; | ||
| } | ||
|
|
||
| export { AnswerEvaluation }; | ||
20 changes: 20 additions & 0 deletions
20
apps/api/src/answer-submission/answer-submission.constants.ts
This file contains hidden or 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,20 @@ | ||
| const QuizMode = { | ||
| DAILY: 'DAILY', | ||
| INTERVIEW: 'INTERVIEW', | ||
| } as const; | ||
| type QuizMode = (typeof QuizMode)[keyof typeof QuizMode]; | ||
|
|
||
| const InputType = { | ||
| VOICE: 'VOICE', | ||
| TEXT: 'TEXT', | ||
| } as const; | ||
| type InputType = (typeof InputType)[keyof typeof InputType]; | ||
|
|
||
| const ProcessStatus = { | ||
| PENDING: 'PENDING', | ||
| DONE: 'DONE', | ||
| FAILED: 'FAILED', | ||
| } as const; | ||
| type ProcessStatus = (typeof ProcessStatus)[keyof typeof ProcessStatus]; | ||
|
|
||
| export { QuizMode, InputType, ProcessStatus }; |
75 changes: 75 additions & 0 deletions
75
apps/api/src/answer-submission/answer-submission.entity.ts
This file contains hidden or 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,75 @@ | ||
| import { | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| Column, | ||
| CreateDateColumn, | ||
| ManyToOne, | ||
| JoinColumn, | ||
| OneToOne, | ||
| } from 'typeorm'; | ||
| import { | ||
| QuizMode, | ||
| InputType, | ||
| ProcessStatus, | ||
| } from './answer-submission.constants'; | ||
| import { Question } from 'src/question/question.entity'; | ||
| import { AudioAsset } from 'src/audio-asset/audio-asset.entity'; | ||
|
|
||
| @Entity('answer_submissions') | ||
| class AnswerSubmission { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ name: 'quiz_mode', type: 'enum', enum: QuizMode }) | ||
| quizMode: QuizMode; | ||
|
|
||
| @Column({ name: 'input_type', type: 'enum', enum: InputType }) | ||
| inputType: InputType; | ||
|
|
||
| @Column({ name: 'raw_answer', type: 'text' }) | ||
| rawAnswer: string; | ||
|
|
||
| @Column({ name: 'taken_time', type: 'int' }) | ||
| takenTime: number; | ||
|
|
||
| @Column({ type: 'int', default: 0 }) | ||
| score: number; | ||
|
|
||
| @CreateDateColumn({ name: 'submitted_at', type: 'timestamp' }) | ||
| submittedAt: Date; | ||
|
|
||
| @Column({ | ||
| name: 'stt_status', | ||
| type: 'enum', | ||
| enum: ProcessStatus, | ||
| default: ProcessStatus.PENDING, | ||
| }) | ||
| sttStatus: ProcessStatus; | ||
|
|
||
| @Column({ | ||
| name: 'evaluation_status', | ||
| type: 'enum', | ||
| enum: ProcessStatus, | ||
| default: ProcessStatus.PENDING, | ||
| }) | ||
| evaluationStatus: ProcessStatus; | ||
|
|
||
| @Column({ name: 'user_id', type: 'int' }) | ||
| userId: number; | ||
|
|
||
| @Column({ name: 'question_id', type: 'int' }) | ||
| questionId: number; | ||
|
|
||
| @Column({ name: 'audio_asset_id', type: 'int' }) | ||
| audioAssetId: number; | ||
|
|
||
| @ManyToOne(() => Question) | ||
| @JoinColumn({ name: 'question_id' }) | ||
| question: Question; | ||
|
|
||
| @OneToOne(() => AudioAsset) | ||
| @JoinColumn({ name: 'audio_asset_id' }) | ||
| audioAsset: AudioAsset; | ||
| } | ||
|
|
||
| export { AnswerSubmission }; |
This file contains hidden or 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,27 @@ | ||
| import { | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| Column, | ||
| CreateDateColumn, | ||
| } from 'typeorm'; | ||
|
|
||
| @Entity('audio_assets') | ||
| class AudioAsset { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ name: 'storage_url', type: 'text' }) | ||
| storageUrl: string; | ||
|
|
||
| // BIGINT는 JS에서 범위 문제로 string으로 반환 | ||
| @Column({ name: 'byte_size', type: 'bigint' }) | ||
| byteSize: string; | ||
|
|
||
| @Column({ name: 'duration_ms', type: 'int' }) | ||
| durationMs: number; | ||
|
|
||
| @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) | ||
| createdAt: Date; | ||
| } | ||
|
|
||
| export { AudioAsset }; |
This file contains hidden or 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,18 @@ | ||
| import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | ||
|
|
||
| @Entity('categories') | ||
| class Category { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ type: 'varchar', length: 255 }) | ||
| name: string; | ||
|
|
||
| @Column({ name: 'parent_id', type: 'int', nullable: true }) | ||
| parentId: number | null; | ||
|
|
||
| @Column({ type: 'int', default: 1 }) | ||
| depth: number; | ||
| } | ||
|
|
||
| export { Category }; |
45 changes: 45 additions & 0 deletions
45
apps/api/src/question-solution/question-solution.entity.ts
This file contains hidden or 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,45 @@ | ||
| import { Question } from 'src/question/question.entity'; | ||
| import { | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| Column, | ||
| CreateDateColumn, | ||
| OneToOne, | ||
| JoinColumn, | ||
| } from 'typeorm'; | ||
|
|
||
| @Entity('question_solutions') | ||
| class QuestionSolution { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ name: 'question_id', type: 'int' }) | ||
| questionId: number; | ||
|
|
||
| @Column({ name: 'reference_source', type: 'varchar', length: 255 }) | ||
| referenceSource: string; | ||
|
|
||
| @Column({ name: 'standard_definition', type: 'text' }) | ||
| standardDefinition: string; | ||
|
|
||
| @Column({ name: 'technical_mechanism', type: 'jsonb' }) | ||
| technicalMechanism: any; | ||
|
|
||
| @Column({ name: 'key_terminology', type: 'jsonb' }) | ||
| keyTerminology: any; | ||
|
|
||
| @Column({ name: 'practical_application', type: 'text' }) | ||
| practicalApplication: string; | ||
|
|
||
| @Column({ name: 'common_misconceptions', type: 'text' }) | ||
| commonMisconceptions: string; | ||
|
|
||
| @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) | ||
| createdAt: Date; | ||
|
|
||
| @OneToOne(() => Question) | ||
| @JoinColumn({ name: 'question_id' }) | ||
| question: Question; | ||
| } | ||
|
|
||
| export { QuestionSolution }; |
This file contains hidden or 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,38 @@ | ||
| import { Category } from 'src/category/category.entity'; | ||
| import { | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| Column, | ||
| JoinColumn, | ||
| OneToOne, | ||
| } from 'typeorm'; | ||
|
|
||
| @Entity('questions') | ||
| class Question { | ||
| @PrimaryGeneratedColumn() | ||
| id: number; | ||
|
|
||
| @Column({ type: 'varchar', length: 255 }) | ||
| title: string; | ||
|
|
||
| @Column({ type: 'text' }) | ||
| content: string; | ||
|
|
||
| @Column({ name: 'tts_url', type: 'varchar', length: 255, nullable: true }) | ||
| ttsUrl: string; | ||
|
|
||
| @Column({ name: 'avg_score', type: 'float', default: 0 }) | ||
| avgScore: number; | ||
|
|
||
| @Column({ name: 'avg_importance', type: 'float', default: 0 }) | ||
| avgImportance: number; | ||
|
|
||
| @Column({ name: 'category_id', type: 'int', nullable: true }) | ||
| categoryId: number; | ||
|
|
||
| @OneToOne(() => Category) | ||
| @JoinColumn({ name: 'category_id' }) | ||
| category: Category; | ||
| } | ||
|
|
||
| export { Question }; |
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.
아 attemp -> submission으로 테이블 이름이 바뀌었으니까 이것도 submissionId로 할까요?
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.
오! 좋습니다