1 | package edu.ucsb.cs156.gauchoride.controllers; | |
2 | ||
3 | import org.springframework.beans.factory.annotation.Autowired; | |
4 | import org.springframework.security.access.prepost.PreAuthorize; | |
5 | import org.springframework.web.bind.annotation.PutMapping; | |
6 | import org.springframework.web.bind.annotation.RequestMapping; | |
7 | import org.springframework.web.bind.annotation.RequestParam; | |
8 | import org.springframework.web.bind.annotation.RestController; | |
9 | ||
10 | import edu.ucsb.cs156.gauchoride.entities.User; | |
11 | import edu.ucsb.cs156.gauchoride.errors.EntityNotFoundException; | |
12 | import edu.ucsb.cs156.gauchoride.repositories.UserRepository; | |
13 | import io.swagger.v3.oas.annotations.Operation; | |
14 | import io.swagger.v3.oas.annotations.Parameter; | |
15 | import io.swagger.v3.oas.annotations.tags.Tag; | |
16 | ||
17 | @Tag(name = "User Profile") | |
18 | @RequestMapping("/api/userprofile") | |
19 | @RestController | |
20 | ||
21 | public class UserProfileController extends ApiController { | |
22 | ||
23 | @Autowired | |
24 | UserRepository userRepository; | |
25 | ||
26 | @Operation(summary = "Update a cellphone number") | |
27 | @PreAuthorize("hasRole('ROLE_USER')") | |
28 | @PutMapping("/updatecellphone") | |
29 | public Object updateCellphone( @Parameter (name = "cellphone", description = "a cellphone number", example = "805-000-0000", required = true) @RequestParam String cellphone) { | |
30 | Long id = super.getCurrentUser().getId(); | |
31 | User user = userRepository.findById(id) | |
32 |
1
1. lambda$updateCellphone$0 : replaced return value with null for edu/ucsb/cs156/gauchoride/controllers/UserProfileController::lambda$updateCellphone$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(User.class, id)); |
33 |
1
1. updateCellphone : removed call to edu/ucsb/cs156/gauchoride/entities/User::setCellphone → KILLED |
user.setCellphone(cellphone); |
34 | userRepository.save(user); | |
35 |
1
1. updateCellphone : replaced return value with null for edu/ucsb/cs156/gauchoride/controllers/UserProfileController::updateCellphone → KILLED |
return user; |
36 | } | |
37 | } | |
Mutations | ||
32 |
1.1 |
|
33 |
1.1 |
|
35 |
1.1 |