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