1 | package edu.ucsb.cs156.frontiers.controllers; | |
2 | ||
3 | import com.fasterxml.jackson.core.JsonProcessingException; | |
4 | import edu.ucsb.cs156.frontiers.models.UserDataDTO; | |
5 | import edu.ucsb.cs156.frontiers.services.UserDataDTOService; | |
6 | import io.swagger.v3.oas.annotations.Operation; | |
7 | import io.swagger.v3.oas.annotations.tags.Tag; | |
8 | import org.springframework.beans.factory.annotation.Autowired; | |
9 | import org.springframework.data.domain.Page; | |
10 | import org.springframework.data.domain.Pageable; | |
11 | import org.springframework.security.access.prepost.PreAuthorize; | |
12 | import org.springframework.web.bind.annotation.GetMapping; | |
13 | import org.springframework.web.bind.annotation.RequestMapping; | |
14 | import org.springframework.web.bind.annotation.RestController; | |
15 | ||
16 | /** | |
17 | * This is a REST controller for getting information about the users. | |
18 | * | |
19 | * <p>These endpoints are only accessible to users with the role "ROLE_ADMIN". | |
20 | */ | |
21 | @Tag(name = "User information (admin only)") | |
22 | @RequestMapping("/api/admin/users") | |
23 | @RestController | |
24 | public class UsersController extends ApiController { | |
25 | @Autowired private UserDataDTOService userDataDTOService; | |
26 | ||
27 | /** | |
28 | * This method returns a list of all users. Accessible only to users with the role "ROLE_ADMIN". | |
29 | * | |
30 | * @return a list of all users | |
31 | * @throws JsonProcessingException if there is an error processing the JSON | |
32 | */ | |
33 | @Operation(summary = "Get a list of all users") | |
34 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
35 | @GetMapping("") | |
36 | public Page<UserDataDTO> users(Pageable pageable) throws JsonProcessingException { | |
37 |
1
1. users : replaced return value with null for edu/ucsb/cs156/frontiers/controllers/UsersController::users → KILLED |
return userDataDTOService.getUserDataDTOs(pageable); |
38 | } | |
39 | } | |
Mutations | ||
37 |
1.1 |