| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBDate; | |
| 4 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItem; | |
| 5 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 6 | import edu.ucsb.cs156.example.repositories.UCSBDateRepository; | |
| 7 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
| 8 | import io.swagger.v3.oas.annotations.Operation; | |
| 9 | import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 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.format.annotation.DateTimeFormat; | |
| 17 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 19 | import org.springframework.web.bind.annotation.GetMapping; | |
| 20 | import org.springframework.web.bind.annotation.PostMapping; | |
| 21 | import org.springframework.web.bind.annotation.PutMapping; | |
| 22 | import org.springframework.web.bind.annotation.RequestBody; | |
| 23 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 24 | import org.springframework.web.bind.annotation.RequestParam; | |
| 25 | import org.springframework.web.bind.annotation.RestController; | |
| 26 | ||
| 27 | import jakarta.validation.Valid; | |
| 28 | ||
| 29 | import java.time.LocalDateTime; | |
| 30 | ||
| 31 | /** | |
| 32 | * This is a REST controller for UCSBDiningCommonsMenuItem | |
| 33 | */ | |
| 34 | ||
| 35 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 36 | @RequestMapping("/api/ucsbdiningcommonsmenuitem") | |
| 37 | @RestController | |
| 38 | @Slf4j | |
| 39 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 40 | ||
| 41 | @Autowired | |
| 42 | UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 43 | ||
| 44 | /** | |
| 45 | * List all UCSB Dining Commmons Menu Items | |
| 46 | * | |
| 47 | * @return an iterable of UCSBDiningCommonsMenuItem | |
| 48 | */ | |
| 49 | @Operation(summary = "List all ucsb items") | |
| 50 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 51 | @GetMapping("/all") | |
| 52 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItem() { | |
| 53 | Iterable<UCSBDiningCommonsMenuItem> items = ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 54 |
1
1. allUCSBDiningCommonsMenuItem : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItem → KILLED |
return items; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Get a single item by id | |
| 59 | * | |
| 60 | * @param id the id of the item | |
| 61 | * @return a UCSBDiningCommonsMenuItem | |
| 62 | */ | |
| 63 | @Operation(summary = "Get a single item") | |
| 64 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 65 | @GetMapping("") | |
| 66 | public UCSBDiningCommonsMenuItem getById( | |
| 67 | @Parameter(name = "id") @RequestParam Long id) { | |
| 68 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 69 |
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)); |
| 70 | ||
| 71 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItem; |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * Create a new item | |
| 76 | * | |
| 77 | * @param diningCommonsCode the code of the dining common | |
| 78 | * @param name the name of the itenm | |
| 79 | * @param station the station where the item is located | |
| 80 | * @return the saved item | |
| 81 | */ | |
| 82 | @Operation(summary = "Create a new item") | |
| 83 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 84 | @PostMapping("/post") | |
| 85 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 86 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 87 | @Parameter(name = "name") @RequestParam String name, | |
| 88 | @Parameter(name = "station") @RequestParam String station) | |
| 89 | throws JsonProcessingException { | |
| 90 | ||
| 91 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = new UCSBDiningCommonsMenuItem(); | |
| 92 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(diningCommonsCode); |
| 93 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(name); |
| 94 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(station); |
| 95 | ||
| 96 | UCSBDiningCommonsMenuItem savedUcsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository | |
| 97 | .save(ucsbDiningCommonsMenuItem); | |
| 98 | ||
| 99 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedUcsbDiningCommonsMenuItem; |
| 100 | } | |
| 101 | ||
| 102 | /** | |
| 103 | * Update a single item | |
| 104 | * | |
| 105 | * @param id id of the item to update | |
| 106 | * @param incoming the new item | |
| 107 | * @return the updated UCSBDiningCommonsMenuItem object | |
| 108 | */ | |
| 109 | @Operation(summary = "Update a single item") | |
| 110 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 111 | @PutMapping("") | |
| 112 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 113 | @Parameter(name = "id") @RequestParam Long id, | |
| 114 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 115 | ||
| 116 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 117 |
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)); |
| 118 | ||
| 119 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 120 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(incoming.getName()); |
| 121 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(incoming.getStation()); |
| 122 | ||
| 123 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 124 | ||
| 125 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItem; |
| 126 | } | |
| 127 | ||
| 128 | /** | |
| 129 | * Delete a UCSBDiningCommonsMenuItem | |
| 130 | * | |
| 131 | * @param id the id of the item to delete | |
| 132 | * @return a message indicating the item was deleted | |
| 133 | */ | |
| 134 | @Operation(summary = "Delete a UCSBDiningCommoneMenuItem") | |
| 135 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 136 | @DeleteMapping("") | |
| 137 | public Object deleteUCSBDiningCommonMenObject( | |
| 138 | @Parameter(name = "id") @RequestParam Long id) { | |
| 139 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 140 |
1
1. lambda$deleteUCSBDiningCommonMenObject$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonMenObject$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 141 | ||
| 142 |
1
1. deleteUCSBDiningCommonMenObject : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
| 143 |
1
1. deleteUCSBDiningCommonMenObject : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteUCSBDiningCommonMenObject → KILLED |
return genericMessage("UCSBDiningCommonsMenuItem with id %s deleted".formatted(id)); |
| 144 | } | |
| 145 | ||
| 146 | } | |
Mutations | ||
| 54 |
1.1 |
|
| 69 |
1.1 |
|
| 71 |
1.1 |
|
| 92 |
1.1 |
|
| 93 |
1.1 |
|
| 94 |
1.1 |
|
| 99 |
1.1 |
|
| 117 |
1.1 |
|
| 119 |
1.1 |
|
| 120 |
1.1 |
|
| 121 |
1.1 |
|
| 125 |
1.1 |
|
| 140 |
1.1 |
|
| 142 |
1.1 |
|
| 143 |
1.1 |