| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItems; | |
| 4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemsRepository; | |
| 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 UCSBDiningCommonsMenuItems */ | |
| 23 | @Tag(name = "UCSBDiningCommonsMenuItems") | |
| 24 | @RequestMapping("/api/ucsbdiningcommonsmenuitems") | |
| 25 | @RestController | |
| 26 | @Slf4j | |
| 27 | public class UCSBDiningCommonsMenuItemsController extends ApiController { | |
| 28 | ||
| 29 | @Autowired UCSBDiningCommonsMenuItemsRepository UCSBDiningCommonsMenuItemsRepository; | |
| 30 | ||
| 31 | /** | |
| 32 | * List all menu items | |
| 33 | * | |
| 34 | * @return an iterable of UCSBDiningCommonsMenuItems | |
| 35 | */ | |
| 36 | @Operation(summary = "List all items") | |
| 37 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 38 | @GetMapping("/all") | |
| 39 | public Iterable<UCSBDiningCommonsMenuItems> allItems() { | |
| 40 | Iterable<UCSBDiningCommonsMenuItems> items = UCSBDiningCommonsMenuItemsRepository.findAll(); | |
| 41 |
1
1. allItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::allItems → KILLED |
return items; |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * Get a single item by id | |
| 46 | * | |
| 47 | * @param id the id of the item | |
| 48 | * @return a item | |
| 49 | */ | |
| 50 | @Operation(summary = "Get a single item") | |
| 51 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 52 | @GetMapping("") | |
| 53 | public UCSBDiningCommonsMenuItems getById(@Parameter(name = "id") @RequestParam Long id) { | |
| 54 | UCSBDiningCommonsMenuItems UCSBDiningCommonsMenuItems = | |
| 55 | UCSBDiningCommonsMenuItemsRepository.findById(id) | |
| 56 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
| 57 | ||
| 58 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::getById → KILLED |
return UCSBDiningCommonsMenuItems; |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * Create a new menu item | |
| 63 | * | |
| 64 | * @param diningCommonsCode the dining hall name | |
| 65 | * @param name the name of the menu item | |
| 66 | * @param station where food is located | |
| 67 | * @return the saved menu item | |
| 68 | */ | |
| 69 | @Operation(summary = "Create a new item") | |
| 70 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 71 | @PostMapping("/post") | |
| 72 | public UCSBDiningCommonsMenuItems postItems( | |
| 73 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 74 | @Parameter(name = "name") @RequestParam String name, | |
| 75 | @Parameter(name = "station") @RequestParam String station) { | |
| 76 | ||
| 77 | UCSBDiningCommonsMenuItems items = new UCSBDiningCommonsMenuItems(); | |
| 78 |
1
1. postItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
items.setDiningCommonsCode(diningCommonsCode); |
| 79 |
1
1. postItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
items.setName(name); |
| 80 |
1
1. postItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
items.setStation(station); |
| 81 | ||
| 82 | UCSBDiningCommonsMenuItems savedItems = UCSBDiningCommonsMenuItemsRepository.save(items); | |
| 83 | ||
| 84 |
1
1. postItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::postItems → KILLED |
return savedItems; |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Update a single item | |
| 89 | * | |
| 90 | * @param id id of the item to update | |
| 91 | * @param incoming the new item | |
| 92 | * @return the updated item | |
| 93 | */ | |
| 94 | @Operation(summary = "Update a single item") | |
| 95 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 96 | @PutMapping("") | |
| 97 | public UCSBDiningCommonsMenuItems updateUCSBDiningCommonsMenuItems( | |
| 98 | @Parameter(name = "id") @RequestParam Long id, | |
| 99 | @RequestBody @Valid UCSBDiningCommonsMenuItems incoming) { | |
| 100 | ||
| 101 | UCSBDiningCommonsMenuItems UCSBDiningCommonsMenuItems = | |
| 102 | UCSBDiningCommonsMenuItemsRepository.findById(id) | |
| 103 |
1
1. lambda$updateUCSBDiningCommonsMenuItems$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$updateUCSBDiningCommonsMenuItems$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
| 104 | ||
| 105 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
UCSBDiningCommonsMenuItems.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 106 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
UCSBDiningCommonsMenuItems.setName(incoming.getName()); |
| 107 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
UCSBDiningCommonsMenuItems.setStation(incoming.getStation()); |
| 108 | ||
| 109 | UCSBDiningCommonsMenuItemsRepository.save(UCSBDiningCommonsMenuItems); | |
| 110 | ||
| 111 |
1
1. updateUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::updateUCSBDiningCommonsMenuItems → KILLED |
return UCSBDiningCommonsMenuItems; |
| 112 | } | |
| 113 | ||
| 114 | /** | |
| 115 | * Delete a UCSBDate | |
| 116 | * | |
| 117 | * @param id the id of the date to delete | |
| 118 | * @return a message indicating the date was deleted | |
| 119 | */ | |
| 120 | @Operation(summary = "Delete a UCSBDiningCommonsMenuItems") | |
| 121 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 122 | @DeleteMapping("") | |
| 123 | public Object deleteUCSBDiningCommonsMenuItems(@Parameter(name = "id") @RequestParam Long id) { | |
| 124 | UCSBDiningCommonsMenuItems UCSBDiningCommonsMenuItems = | |
| 125 | UCSBDiningCommonsMenuItemsRepository.findById(id) | |
| 126 |
1
1. lambda$deleteUCSBDiningCommonsMenuItems$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$deleteUCSBDiningCommonsMenuItems$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
| 127 | ||
| 128 |
1
1. deleteUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED |
UCSBDiningCommonsMenuItemsRepository.delete(UCSBDiningCommonsMenuItems); |
| 129 |
1
1. deleteUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::deleteUCSBDiningCommonsMenuItems → KILLED |
return genericMessage("UCSBDiningCommonsMenuItems with id %s deleted".formatted(id)); |
| 130 | } | |
| 131 | } | |
Mutations | ||
| 41 |
1.1 |
|
| 56 |
1.1 |
|
| 58 |
1.1 |
|
| 78 |
1.1 |
|
| 79 |
1.1 |
|
| 80 |
1.1 |
|
| 84 |
1.1 |
|
| 103 |
1.1 |
|
| 105 |
1.1 |
|
| 106 |
1.1 |
|
| 107 |
1.1 |
|
| 111 |
1.1 |
|
| 126 |
1.1 |
|
| 128 |
1.1 |
|
| 129 |
1.1 |