Skip to content

Commit

Permalink
fix: submission-language entity 간 관계 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
yechan2468 committed Feb 27, 2024
1 parent 6ecc58f commit 7e7a432
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import {
} from 'typeorm';

import { CompetitionParticipant } from './competition.participant.entity';
import { CompetitionProblem } from '../../problem/entities/competition.problem.entity';
import { Submission } from './submission.entity';

import { Dashboard } from '@src/dashboard/entities/dashboard.entity';
import { User } from '@src/user/entities/user.entity';
import { Dashboard } from '../../dashboard/entities/dashboard.entity';
import { CompetitionProblem } from '../../problem/entities/competition.problem.entity';
import { User } from '../../user/entities/user.entity';

@Entity()
export class Competition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from 'typeorm';

import { Competition } from './competition.entity';
import { Language } from '../../problem/entities/language.entity';
import { Problem } from '../../problem/entities/problem.entity';
import { User } from '../../user/entities/user.entity';
import { RESULT } from '../competition.enums';

import { User } from '@src/user/entities/user.entity';

@Entity()
export class Submission {
@PrimaryGeneratedColumn()
Expand Down Expand Up @@ -49,6 +49,12 @@ export class Submission {
@ManyToOne(() => User, (user) => user.submissions, { nullable: false })
user: User;

@Column()
languageId: number;

@ManyToOne(() => Language, (language) => language.submissions, { nullable: false })
language: Language;

@CreateDateColumn()
createdAt: Date;

Expand Down
4 changes: 4 additions & 0 deletions be/algo-with-me-api/src/problem/entities/language.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'typeorm';

import { ProblemLanguage } from './problem.language.entity';
import { Submission } from '../../competition/entities/submission.entity';

@Entity()
export class Language {
Expand All @@ -20,6 +21,9 @@ export class Language {
@OneToMany(() => ProblemLanguage, (ProblemLanguage) => ProblemLanguage.problem)
problemLanguages: ProblemLanguage[];

@OneToMany(() => Submission, (submission) => submission.problem)
submissions: Submission[];

@CreateDateColumn()
createdAt: Date;

Expand Down

0 comments on commit 7e7a432

Please sign in to comment.