feat(backend): Entities toegevoegd
Entites Class, Class Join Request, Class Invitation, Assignment, Group en entities om de Dwengo-leerinhoud te modelleren, toegevoegd.
This commit is contained in:
parent
62a278a6e0
commit
d5101737ef
14 changed files with 289 additions and 7 deletions
18
backend/src/entities/classes/class-invitation.entity.ts
Normal file
18
backend/src/entities/classes/class-invitation.entity.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import {Entity, ManyToOne} from "@mikro-orm/core";
|
||||
import {Teacher} from "../users/teacher.entity";
|
||||
import {Class} from "./class.entity";
|
||||
|
||||
/**
|
||||
* Invitation of a teacher into a class (in order to teach it).
|
||||
*/
|
||||
@Entity()
|
||||
export class TeacherInvitation {
|
||||
@ManyToOne({entity: () => Teacher, primary: true})
|
||||
sender!: Teacher;
|
||||
|
||||
@ManyToOne({entity: () => Teacher, primary: true})
|
||||
receiver!: Teacher;
|
||||
|
||||
@ManyToOne({entity: () => Class, primary: true})
|
||||
class!: Class;
|
||||
}
|
21
backend/src/entities/classes/class-join-request.entity.ts
Normal file
21
backend/src/entities/classes/class-join-request.entity.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import {Entity, Enum, ManyToOne} from "@mikro-orm/core";
|
||||
import {Student} from "../users/student.entity";
|
||||
import {Class} from "./class.entity";
|
||||
|
||||
@Entity()
|
||||
export class ClassJoinRequest {
|
||||
@ManyToOne({entity: () => Student, primary: true})
|
||||
requester!: Student;
|
||||
|
||||
@ManyToOne({entity: () => Class, primary: true})
|
||||
class!: Class;
|
||||
|
||||
@Enum(() => ClassJoinRequestStatus)
|
||||
status!: ClassJoinRequestStatus;
|
||||
}
|
||||
|
||||
export enum ClassJoinRequestStatus {
|
||||
Open = "open",
|
||||
Accepted = "accepted",
|
||||
Declined = "declined"
|
||||
}
|
19
backend/src/entities/classes/class.entity.ts
Normal file
19
backend/src/entities/classes/class.entity.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import {Collection, Entity, ManyToMany, PrimaryKey, Property} from "@mikro-orm/core";
|
||||
import { v4 } from 'uuid';
|
||||
import {Teacher} from "../users/teacher.entity";
|
||||
import {Student} from "../users/student.entity";
|
||||
|
||||
@Entity()
|
||||
export class Class {
|
||||
@PrimaryKey()
|
||||
classId = v4();
|
||||
|
||||
@Property({type: "string"})
|
||||
displayName!: string;
|
||||
|
||||
@ManyToMany(() => Teacher)
|
||||
teachers!: Collection<Teacher>;
|
||||
|
||||
@ManyToMany(() => Student)
|
||||
students!: Collection<Student>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue