Skip to content
Snippets Groups Projects

Resolve "StudentGroup endpoint: getGroupsPerPerson"

4 files
+ 169
3
Compare changes
  • Side-by-side
  • Inline

Files

@@ -31,6 +31,7 @@ import nl.tudelft.labracore.dto.view.structured.summary.RoleSummaryDTO;
import nl.tudelft.labracore.repository.StudentGroupRepository;
import nl.tudelft.labracore.service.RoleService;
import nl.tudelft.labracore.service.StudentGroupService;
import nl.tudelft.librador.dto.view.View;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -250,4 +251,46 @@ public class StudentGroupController {
return sgs.getRoleOfMember(personId, id);
}
/**
* Gets all groups for a given person.
*
* @param personId The id of the person to lookup.
* @return The list of groups the given person is in.
*/
@GetMapping("/by-person/{personId}")
@PreAuthorize("hasAuthority('STUDENT_GROUP_READ')")
public List<StudentGroupSummaryDTO> getGroupsForPerson(@PathVariable Long personId) {
return View.convertList(sgr.findAllByPersonIn(personId), StudentGroupSummaryDTO.class);
}
/**
* Gets all groups for a given person within the given course.
*
* @param personId The id of the person to lookup.
* @param courseId The id of the course to lookup.
* @return The list of groups in the given course the given person is in.
*/
@GetMapping("/by-person-and-course/{personId}/{courseId}")
@PreAuthorize("hasAuthority('STUDENT_GROUP_READ')")
public List<StudentGroupSummaryDTO> getGroupsForPersonAndCourse(@PathVariable Long personId,
@PathVariable Long courseId) {
return View.convertList(sgr.findAllByCourseAndPersonIn(personId, courseId),
StudentGroupSummaryDTO.class);
}
/**
* Gets all groups for a given person within the given module.
*
* @param personId The id of the person to lookup.
* @param moduleId The id of the module to lookup.
* @return The list of groups in the given module the given person is in.
*/
@GetMapping("/by-person-and-module/{personId}/{moduleId}")
@PreAuthorize("hasAuthority('STUDENT_GROUP_READ')")
public List<StudentGroupSummaryDTO> getGroupsForPersonAndModule(@PathVariable Long personId,
@PathVariable Long moduleId) {
return View.convertList(sgr.findAllByModuleAndPersonIn(personId, moduleId),
StudentGroupSummaryDTO.class);
}
}
Loading