| 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 lombok.extern.slf4j.Slf4j; | |
| 11 | ||
| 12 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 13 | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 17 | import org.springframework.web.bind.annotation.GetMapping; | |
| 18 | import org.springframework.web.bind.annotation.PostMapping; | |
| 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 | ||
| 26 | ||
| 27 | /** | |
| 28 | * This is a REST controller for UCSBDiningCommonsMenuItem | |
| 29 | */ | |
| 30 | ||
| 31 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 32 | @RequestMapping("/api/ucsbdiningcommonsmenuitem") | |
| 33 | @RestController | |
| 34 | @Slf4j | |
| 35 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 36 | ||
| 37 | @Autowired | |
| 38 | UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 39 | ||
| 40 | /** | |
| 41 | * List all UCSB Dining Commons Menu Items | |
| 42 | */ | |
| 43 | @Operation(summary = "List all UCSB Dining Commons Menu Items") | |
| 44 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 45 | @GetMapping("/all") | |
| 46 | public Iterable<UCSBDiningCommonsMenuItem> allMenuItems() { | |
| 47 | Iterable<UCSBDiningCommonsMenuItem> items = ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 48 |
1
1. allMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allMenuItems → KILLED |
return items; |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 | * Get a single UCSB Dining Commons Menu Item by id | |
| 53 | * | |
| 54 | * @param id the id of the menu item | |
| 55 | * @return a UCSBDiningCommonsMenuItem | |
| 56 | */ | |
| 57 | @Operation(summary = "Get a single UCSB Dining Commons Menu Item by id") | |
| 58 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 59 | @GetMapping("") | |
| 60 | public UCSBDiningCommonsMenuItem getById( | |
| 61 | @Parameter(name = "id") @RequestParam Long id) { | |
| 62 | UCSBDiningCommonsMenuItem item = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 63 |
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)); |
| 64 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return item; |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Create a new UCSB Dining Commons Menu Item | |
| 69 | * | |
| 70 | * @param diningcommonscode dining commons code | |
| 71 | * @param name name of the menu item | |
| 72 | * @param station station where the item is located | |
| 73 | * @return the saved menu item | |
| 74 | */ | |
| 75 | @Operation(summary = "Create a new UCSB Dining Commons Menu Item") | |
| 76 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 77 | @PostMapping("/post") | |
| 78 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 79 | @Parameter(name = "diningcommonscode") @RequestParam String diningcommonscode, | |
| 80 | @Parameter(name = "name") @RequestParam String name, | |
| 81 | @Parameter(name = "station") @RequestParam String station | |
| 82 | ) throws JsonProcessingException { | |
| 83 | ||
| 84 | UCSBDiningCommonsMenuItem item = new UCSBDiningCommonsMenuItem(); | |
| 85 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
item.setDiningCommonsCode(diningcommonscode); |
| 86 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
item.setName(name); |
| 87 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
item.setStation(station); |
| 88 | ||
| 89 | UCSBDiningCommonsMenuItem savedItem = ucsbDiningCommonsMenuItemRepository.save(item); | |
| 90 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedItem; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * Delete a UCSB Dining Commons Menu Item | |
| 95 | * | |
| 96 | * @param id the id of the menu item to delete | |
| 97 | * @return a message indicating the menu item was deleted | |
| 98 | */ | |
| 99 | @Operation(summary = "Delete a UCSB Dining Commons Menu Item") | |
| 100 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 101 | @DeleteMapping("") | |
| 102 | public Object deleteUCSBDiningCommonsMenuItem( | |
| 103 | @Parameter(name = "id") @RequestParam Long id) { | |
| 104 | UCSBDiningCommonsMenuItem item = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 105 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 106 | ||
| 107 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(item); |
| 108 |
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)); |
| 109 | } | |
| 110 | ||
| 111 | @Operation(summary = "Update a UCSB Dining Commons Menu Item") | |
| 112 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 113 | @PutMapping("") | |
| 114 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 115 | @Parameter(name = "id") @RequestParam Long id, | |
| 116 | @RequestBody UCSBDiningCommonsMenuItem newItem) { | |
| 117 | ||
| 118 | UCSBDiningCommonsMenuItem item = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 119 |
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)); |
| 120 | ||
| 121 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
item.setDiningCommonsCode(newItem.getDiningCommonsCode()); |
| 122 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
item.setName(newItem.getName()); |
| 123 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
item.setStation(newItem.getStation()); |
| 124 | ||
| 125 | ucsbDiningCommonsMenuItemRepository.save(item); | |
| 126 | ||
| 127 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return item; |
| 128 | } | |
| 129 | ||
| 130 | ||
| 131 | } | |
Mutations | ||
| 48 |
1.1 |
|
| 63 |
1.1 |
|
| 64 |
1.1 |
|
| 85 |
1.1 |
|
| 86 |
1.1 |
|
| 87 |
1.1 |
|
| 90 |
1.1 |
|
| 105 |
1.1 |
|
| 107 |
1.1 |
|
| 108 |
1.1 |
|
| 119 |
1.1 |
|
| 121 |
1.1 |
|
| 122 |
1.1 |
|
| 123 |
1.1 |
|
| 127 |
1.1 |