Skip to content

Commit

Permalink
added api routes instead of literal string
Browse files Browse the repository at this point in the history
  • Loading branch information
AWerbrouck committed Mar 9, 2024
1 parent cf42a31 commit 567508b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
public final class ApiRoutes {
public static final String USER_BASE_PATH = "/api/user/";
public static final String COURSE_BASE_PATH = "/api/course/";

public static final String PROJECT_BASE_PATH = "/api/project/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CourseController {
@Autowired
private TestRepository testRepository;

@GetMapping("/api/courses/{courseId}")
@GetMapping(ApiRoutes.COURSE_BASE_PATH + "{courseId}")
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<List<ProjectEntity>> getProjectByCourseId(@PathVariable Long courseId) {
List<ProjectEntity> projects = projectRepository.findByCourseId(courseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ProjectController {
@Autowired
private TestRepository testRepository;

@GetMapping("/api/projects")
@GetMapping(ApiRoutes.PROJECT_BASE_PATH)
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<?> getProjects() {
List<ProjectEntity> allProjects = projectRepository.findAll();
Expand All @@ -42,7 +42,7 @@ public ResponseEntity<?> getProjects() {
return ResponseEntity.ok().body(projectsWithUrls);
}

@GetMapping("/api/projects/{projectId}")
@GetMapping(ApiRoutes.PROJECT_BASE_PATH + "{projectId}")
@Roles({UserRole.teacher, UserRole.student})
public ResponseEntity<?> getProjectById(@PathVariable Long projectId, Auth auth) {
return projectRepository.findById(projectId)
Expand Down

0 comments on commit 567508b

Please sign in to comment.