| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItem; | |
| 4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
| 6 | ||
| 7 | import io.swagger.v3.oas.annotations.Operation; | |
| 8 | import io.swagger.v3.oas.annotations.Parameter; | |
| 9 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 10 | import jakarta.validation.Valid; | |
| 11 | import lombok.extern.slf4j.Slf4j; | |
| 12 | ||
| 13 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 14 | ||
| 15 | import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 17 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 18 | import org.springframework.web.bind.annotation.GetMapping; | |
| 19 | import org.springframework.web.bind.annotation.PostMapping; | |
| 20 | import org.springframework.web.bind.annotation.PutMapping; | |
| 21 | import org.springframework.web.bind.annotation.RequestBody; | |
| 22 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 23 | import org.springframework.web.bind.annotation.RequestParam; | |
| 24 | import org.springframework.web.bind.annotation.RestController; | |
| 25 | ||
| 26 | ||
| 27 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 28 | @RequestMapping("/api/ucsbdiningcommonsmenuitem") | |
| 29 | @RestController | |
| 30 | @Slf4j | |
| 31 | ||
| 32 | public class UCSBDiningCommonsMenuItemController extends ApiController{ | |
| 33 | ||
| 34 | @Autowired | |
| 35 | UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 36 | ||
| 37 | //GET ALL | |
| 38 | @Operation(summary= "List all ucsb menu items") | |
| 39 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 40 | @GetMapping("/all") | |
| 41 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBMenuItems() { | |
| 42 | Iterable<UCSBDiningCommonsMenuItem> menuItems = ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 43 |
1
1. allUCSBMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBMenuItems → KILLED |
return menuItems; |
| 44 | } | |
| 45 | ||
| 46 | //POST | |
| 47 | @Operation(summary= "Create a new menu item") | |
| 48 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 49 | @PostMapping("/post") | |
| 50 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 51 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 52 | @Parameter(name="name") @RequestParam String name, | |
| 53 | @Parameter(name="station") @RequestParam String station) | |
| 54 | throws JsonProcessingException { | |
| 55 | ||
| 56 | ||
| 57 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = new UCSBDiningCommonsMenuItem(); | |
| 58 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(diningCommonsCode); |
| 59 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(name); |
| 60 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(station); |
| 61 | ||
| 62 | UCSBDiningCommonsMenuItem savedUcsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 63 | ||
| 64 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedUcsbDiningCommonsMenuItem; |
| 65 | } | |
| 66 | ||
| 67 | //DELETE | |
| 68 | @Operation(summary= "Delete a menu item") | |
| 69 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 70 | @DeleteMapping("") | |
| 71 | public Object deleteUCSBDiningCommonsMenuItem( | |
| 72 | @Parameter(name="id") @RequestParam Long id) { | |
| 73 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 74 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 75 | ||
| 76 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
| 77 |
1
1. deleteUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteUCSBDiningCommonsMenuItem → KILLED |
return genericMessage("UCSBDiningCommonsMenuItem with id %s deleted".formatted(id)); |
| 78 | } | |
| 79 | ||
| 80 | //GET (single) | |
| 81 | @Operation(summary= "Get a single menu item") | |
| 82 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 83 | @GetMapping("") | |
| 84 | public UCSBDiningCommonsMenuItem getById( | |
| 85 | @Parameter(name="id") @RequestParam Long id) { | |
| 86 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 87 |
1
1. lambda$getById$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 88 | ||
| 89 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItem; |
| 90 | } | |
| 91 | ||
| 92 | //PUT | |
| 93 | @Operation(summary= "Update a single menu item") | |
| 94 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 95 | @PutMapping("") | |
| 96 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 97 | @Parameter(name="id") @RequestParam Long id, | |
| 98 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 99 | ||
| 100 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 101 |
1
1. lambda$updateUCSBDiningCommonsMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonsMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 102 | ||
| 103 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 104 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(incoming.getName()); |
| 105 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(incoming.getStation()); |
| 106 | ||
| 107 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 108 | ||
| 109 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItem; |
| 110 | } | |
| 111 | | |
| 112 | } | |
Mutations | ||
| 43 |
1.1 |
|
| 58 |
1.1 |
|
| 59 |
1.1 |
|
| 60 |
1.1 |
|
| 64 |
1.1 |
|
| 74 |
1.1 |
|
| 76 |
1.1 |
|
| 77 |
1.1 |
|
| 87 |
1.1 |
|
| 89 |
1.1 |
|
| 101 |
1.1 |
|
| 103 |
1.1 |
|
| 104 |
1.1 |
|
| 105 |
1.1 |
|
| 109 |
1.1 |