Skip to content
Snippets Groups Projects
Commit fc48c687 authored by Dominika Zemanovičová's avatar Dominika Zemanovičová
Browse files

Change endpoints of UserController according to REST

parent 80657e46
No related branches found
No related tags found
3 merge requests!31M2,!28M2 user,!27Draft: M2 user
......@@ -30,7 +30,6 @@ public class UserController {
@Autowired
public UserController(UserFacade facade) {
this.facade = facade;
}
@Operation(summary = "Get a user by Id", description = "Returns a user with specified Id")
......@@ -78,7 +77,7 @@ public class UserController {
@ApiResponse(responseCode = "400", description = "Invalid input."),
@ApiResponse(responseCode = "404", description = "User with the specified ID was not found.")
})
@PutMapping("/update/{id}")
@PutMapping("/{id}")
public ResponseEntity<UserDto> update(@PositiveOrZero @PathVariable Long id, @Valid @RequestBody UserCreateDto dto) {
try {
......@@ -93,9 +92,8 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "Successfully retrieved paginated Users"),
@ApiResponse(responseCode = "400", description = "Invalid page number supplied"),
})
@GetMapping("/all")
@GetMapping
public ResponseEntity<Result<UserDto>> findAll(@PositiveOrZero @RequestParam int page) {
return ResponseEntity.ok(facade.findAll(page));
}
......@@ -117,7 +115,7 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "Successfully retrieved finished courses"),
@ApiResponse(responseCode = "400", description = "Invalid input")
})
@GetMapping("/finished/{id}")
@GetMapping("/{id}/finished-courses")
public ResponseEntity<List<CourseDto>> getFinished(@PathVariable Long id) {
return ResponseEntity.ok(facade.getFinished(id));
}
......@@ -127,7 +125,7 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "Successfully retrieved enrolled courses"),
@ApiResponse(responseCode = "400", description = "Invalid input")
})
@GetMapping("/enrolled/{id}")
@GetMapping("/{id}/courses")
public ResponseEntity<List<CourseDto>> getEnrolled(@PathVariable Long id) {
return ResponseEntity.ok(facade.getEnrolled(id));
}
......@@ -138,7 +136,7 @@ public class UserController {
@ApiResponse(responseCode = "404", description = "User with given Id does not exist"),
@ApiResponse(responseCode = "400", description = "Invalid input")
})
@PutMapping("/addLanguage/{id}")
@PutMapping("/{id}/languages")
public ResponseEntity<UserDto> addLanguage(@PathVariable Long id, @Valid @RequestBody UserAddLanguageDto body) {
try {
return ResponseEntity.ok(facade.addLanguage(id, body));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment