| 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 | import io.swagger.v3.oas.annotations.Operation; | |
| 7 | import io.swagger.v3.oas.annotations.Parameter; | |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 9 | import jakarta.validation.Valid; | |
| 10 | import lombok.extern.slf4j.Slf4j; | |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 14 | import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | import org.springframework.web.bind.annotation.PutMapping; | |
| 17 | import org.springframework.web.bind.annotation.RequestBody; | |
| 18 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 19 | import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | import org.springframework.web.bind.annotation.RestController; | |
| 21 | ||
| 22 | /** This is a REST controller for UCSBDiningCommonsMenuItem */ | |
| 23 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 24 | @RequestMapping("/api/ucsbdiningcommonsmenuitem") | |
| 25 | @RestController | |
| 26 | @Slf4j | |
| 27 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 28 | ||
| 29 | @Autowired UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 30 | ||
| 31 | /** Get all records in the table and return as a JSON array */ | |
| 32 | @Operation(summary = "List all ucsb dining commons menu items") | |
| 33 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 34 | @GetMapping("/all") | |
| 35 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItem() { | |
| 36 | Iterable<UCSBDiningCommonsMenuItem> diningcommonsmenuitem = | |
| 37 | ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 38 |
1
1. allUCSBDiningCommonsMenuItem : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItem → KILLED |
return diningcommonsmenuitem; |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Get a single menu item by id | |
| 43 | * | |
| 44 | * @param id the id of the menu item | |
| 45 | * @return a UCSBDiningCommonsMenuItem | |
| 46 | */ | |
| 47 | @Operation(summary = "Get a single ucsbdiningcommonsmenuitem") | |
| 48 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 49 | @GetMapping("") | |
| 50 | public UCSBDiningCommonsMenuItem getById(@Parameter(name = "id") @RequestParam Long id) { | |
| 51 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 52 | ucsbDiningCommonsMenuItemRepository | |
| 53 | .findById(id) | |
| 54 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 55 | ||
| 56 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItem; |
| 57 | } | |
| 58 | ||
| 59 | /* | |
| 60 | Use the data in the input parameters to | |
| 61 | create a new row in the table | |
| 62 | and return the data as JSON | |
| 63 | */ | |
| 64 | @Operation(summary = "Create a new ucsbDiningCommonsMenuItem") | |
| 65 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 66 | @PostMapping("/post") | |
| 67 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 68 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 69 | @Parameter(name = "name") @RequestParam String name, | |
| 70 | @Parameter(name = "station") @RequestParam String station) { | |
| 71 | ||
| 72 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = new UCSBDiningCommonsMenuItem(); | |
| 73 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(diningCommonsCode); |
| 74 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(name); |
| 75 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(station); |
| 76 | ||
| 77 | UCSBDiningCommonsMenuItem savedUcsbDiningCommonsMenuItem = | |
| 78 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 79 | ||
| 80 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedUcsbDiningCommonsMenuItem; |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * Update a single menu item | |
| 85 | * | |
| 86 | * @param id id of the date to update | |
| 87 | * @param incoming the new date | |
| 88 | * @return the updated date object | |
| 89 | */ | |
| 90 | @Operation(summary = "Update a single menu item") | |
| 91 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 92 | @PutMapping("") | |
| 93 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 94 | @Parameter(name = "id") @RequestParam Long id, | |
| 95 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 96 | ||
| 97 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 98 | ucsbDiningCommonsMenuItemRepository | |
| 99 | .findById(id) | |
| 100 |
1
1. lambda$updateUCSBDiningCommonsMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonsMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 101 | ||
| 102 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 103 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(incoming.getName()); |
| 104 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(incoming.getStation()); |
| 105 | ||
| 106 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 107 | ||
| 108 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItem; |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Delete a UCSBDiningCommonsMenuItem | |
| 113 | * | |
| 114 | * @param id the id of the menu item to delete | |
| 115 | * @return a message indicating the menu item was deleted | |
| 116 | */ | |
| 117 | @Operation(summary = "Delete a UCSBDiningCommonsMenuItem") | |
| 118 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 119 | @DeleteMapping("") | |
| 120 | public Object deleteUCSBDiningCommonsMenuItem(@Parameter(name = "id") @RequestParam Long id) { | |
| 121 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 122 | ucsbDiningCommonsMenuItemRepository | |
| 123 | .findById(id) | |
| 124 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 125 | ||
| 126 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
| 127 |
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)); |
| 128 | } | |
| 129 | } | |
Mutations | ||
| 38 |
1.1 |
|
| 54 |
1.1 |
|
| 56 |
1.1 |
|
| 73 |
1.1 |
|
| 74 |
1.1 |
|
| 75 |
1.1 |
|
| 80 |
1.1 |
|
| 100 |
1.1 |
|
| 102 |
1.1 |
|
| 103 |
1.1 |
|
| 104 |
1.1 |
|
| 108 |
1.1 |
|
| 124 |
1.1 |
|
| 126 |
1.1 |
|
| 127 |
1.1 |