Skip to content
Snippets Groups Projects

Add query endpoints for courses

Files

@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import jakarta.transaction.Transactional;
import nl.tudelft.labracore.dto.create.CourseCreateDTO;
import nl.tudelft.labracore.dto.create.CourseWithManagerCreateDTO;
import nl.tudelft.labracore.dto.patch.CoursePatchDTO;
import nl.tudelft.labracore.dto.view.structured.details.CourseDetailsDTO;
import nl.tudelft.labracore.dto.view.structured.summary.CourseSummaryDTO;
@@ -157,4 +158,24 @@ public class CourseController {
public void deleteCourse(@PathVariable Long id) {
cr.deleteById(id);
}
/**
* Query course by course code
*/
@GetMapping("/by-course-code")
public CourseSummaryDTO queryCourseByCourseCode(@RequestParam String code) {
return cs.getCourseByCourseCode(code);
}
/**
* Setup or patch a course for which we know the user is a manager based on the tudelft api.
*
* @param dto A dto with a manager related to the course based on the tudelft api.
* @return The id of the course.
*/
@PreAuthorize("@tuDelftApiService.validateManagerInDTO(dto)")
@PostMapping("/setup-course-with-manager")
public Long setupCourseWithManager(@RequestBody CourseWithManagerCreateDTO dto) {
return cs.setupCourse(dto);
}
}
Loading