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