refactor(common): Class
This commit is contained in:
parent
757c89d841
commit
24ed39d04e
7 changed files with 18 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Request, Response } from 'express';
|
||||
import { createClass, getAllClasses, getClass, getClassStudents, getClassStudentsIds, getClassTeacherInvitations } from '../services/classes.js';
|
||||
import { ClassDTO } from '../interfaces/class.js';
|
||||
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
export async function getAllClassesHandler(req: Request, res: Response): Promise<void> {
|
||||
const full = req.query.full === 'true';
|
||||
|
|
|
@ -2,14 +2,7 @@ import { Collection } from '@mikro-orm/core';
|
|||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { Student } from '../entities/users/student.entity.js';
|
||||
import { Teacher } from '../entities/users/teacher.entity.js';
|
||||
|
||||
export interface ClassDTO {
|
||||
id: string;
|
||||
displayName: string;
|
||||
teachers: string[];
|
||||
students: string[];
|
||||
joinRequests: string[];
|
||||
}
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
export function mapToClassDTO(cls: Class): ClassDTO {
|
||||
return {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js';
|
||||
import { ClassDTO, mapToClassDTO } from './class.js';
|
||||
import { mapToClassDTO } from './class.js';
|
||||
import { mapToUserDTO, UserDTO } from './user.js';
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
export interface TeacherInvitationDTO {
|
||||
sender: string | UserDTO;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { getClassRepository, getStudentRepository, getTeacherInvitationRepository, getTeacherRepository } from '../data/repositories.js';
|
||||
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
|
||||
import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js';
|
||||
import { getLogger } from '../logging/initalize.js';
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
const logger = getLogger();
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { getClassRepository, getGroupRepository, getStudentRepository, getSubmissionRepository } from '../data/repositories.js';
|
||||
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToClassDTO } from '../interfaces/class.js';
|
||||
import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js';
|
||||
import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
|
||||
import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js';
|
||||
import { getAllAssignments } from './assignments.js';
|
||||
import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment';
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> {
|
||||
const studentRepository = getStudentRepository();
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { getClassRepository, getLearningObjectRepository, getQuestionRepository, getTeacherRepository } from '../data/repositories.js';
|
||||
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToClassDTO } from '../interfaces/class.js';
|
||||
import { getClassStudents } from './classes.js';
|
||||
import { StudentDTO } from '../interfaces/student.js';
|
||||
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js';
|
||||
import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js';
|
||||
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
|
||||
|
||||
export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> {
|
||||
const teacherRepository = getTeacherRepository();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue