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