feat: endpoint voor alle groepen van een assignment geimplementeerd
This commit is contained in:
parent
3f62ab70e1
commit
7e051d412a
4 changed files with 62 additions and 13 deletions
|
@ -33,4 +33,35 @@ export async function getGroup(
|
|||
}
|
||||
|
||||
return mapToGroupDTOId(group);
|
||||
}
|
||||
|
||||
export async function getAllGroups(
|
||||
classId: string,
|
||||
assignmentNumber: number,
|
||||
full: boolean,
|
||||
): Promise<GroupDTO[]> {
|
||||
const classRepository = getClassRepository();
|
||||
const cls = await classRepository.findById(classId);
|
||||
|
||||
if (!cls) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const assignmentRepository = getAssignmentRepository();
|
||||
const assignment = await assignmentRepository.findByClassAndId(cls, assignmentNumber);
|
||||
|
||||
if (!assignment) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const groupRepository = getGroupRepository();
|
||||
const groups = await groupRepository.findAllGroupsForAssignment(assignment);
|
||||
|
||||
if (full) {
|
||||
console.log('full');
|
||||
console.log(groups);
|
||||
return groups.map(mapToGroupDTO);
|
||||
}
|
||||
|
||||
return groups.map(mapToGroupDTOId);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue