| 1 | package edu.ucsb.cs156.gauchoride.controllers; | |
| 2 | ||
| 3 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 4 | import lombok.extern.slf4j.Slf4j; | |
| 5 | import io.swagger.v3.oas.annotations.Operation; | |
| 6 | import io.swagger.v3.oas.annotations.Parameter; | |
| 7 | import lombok.extern.slf4j.Slf4j; | |
| 8 | ||
| 9 | import javax.validation.Valid; | |
| 10 | ||
| 11 | import edu.ucsb.cs156.gauchoride.repositories.UserRepository; | |
| 12 | import edu.ucsb.cs156.gauchoride.errors.EntityNotFoundException; | |
| 13 | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | import org.springframework.security.core.authority.SimpleGrantedAuthority; | |
| 17 | import org.springframework.web.bind.annotation.GetMapping; | |
| 18 | import org.springframework.web.bind.annotation.PathVariable; | |
| 19 | import org.springframework.web.bind.annotation.PutMapping; | |
| 20 | import org.springframework.web.bind.annotation.RequestBody; | |
| 21 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 22 | import org.springframework.web.bind.annotation.RequestParam; | |
| 23 | import org.springframework.web.bind.annotation.RestController; | |
| 24 | ||
| 25 | import edu.ucsb.cs156.gauchoride.entities.User; | |
| 26 | ||
| 27 | @Tag(name="User Profile") | |
| 28 | @RequestMapping("/api/userprofile") | |
| 29 | @RestController | |
| 30 | @Slf4j | |
| 31 | public class UserProfileController extends ApiController { | |
| 32 | ||
| 33 | @Autowired | |
| 34 | UserRepository userRepository; | |
| 35 | | |
| 36 | | |
| 37 | @Operation(summary = "Update a cellPhone") | |
| 38 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 39 | @PutMapping("/update-cellPhone") | |
| 40 | public Object updateCellPhone( | |
| 41 | @Parameter(name="cellPhone", description = "CellPhone number of User", required = true) @RequestParam String cellPhone) { | |
| 42 | Long id = super.getCurrentUser().getUser().getId(); | |
| 43 | User user = userRepository.findById(id) | |
| 44 |
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)); |
| 45 |
1
1. updateCellPhone : removed call to edu/ucsb/cs156/gauchoride/entities/User::setCellPhone → KILLED |
user.setCellPhone(cellPhone); |
| 46 | userRepository.save(user); | |
| 47 |
1
1. updateCellPhone : replaced return value with null for edu/ucsb/cs156/gauchoride/controllers/UserProfileController::updateCellPhone → KILLED |
return genericMessage("User with id %s has cellPhone %s".formatted(user.getId(), cellPhone)); |
| 48 | } | |
| 49 | } | |
Mutations | ||
| 44 |
1.1 |
|
| 45 |
1.1 |
|
| 47 |
1.1 |