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.format.annotation.DateTimeFormat; | |
16 | import org.springframework.security.access.prepost.PreAuthorize; | |
17 | import org.springframework.web.bind.annotation.DeleteMapping; | |
18 | import org.springframework.web.bind.annotation.GetMapping; | |
19 | import org.springframework.web.bind.annotation.PostMapping; | |
20 | import org.springframework.web.bind.annotation.PutMapping; | |
21 | import org.springframework.web.bind.annotation.RequestBody; | |
22 | import org.springframework.web.bind.annotation.RequestMapping; | |
23 | import org.springframework.web.bind.annotation.RequestParam; | |
24 | import org.springframework.web.bind.annotation.RestController; | |
25 | ||
26 | import javax.validation.Valid; | |
27 | ||
28 | import java.time.LocalDateTime; | |
29 | ||
30 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
31 | @RequestMapping("/api/UCSBDiningCommonsMenuItem") | |
32 | @RestController | |
33 | @Slf4j | |
34 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
35 | ||
36 | @Autowired | |
37 | UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
38 | ||
39 | @Operation(summary= "List all ucsb Dining Commons Menu Items") | |
40 | @PreAuthorize("hasRole('ROLE_USER')") | |
41 | @GetMapping("/all") | |
42 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItems() { | |
43 | Iterable<UCSBDiningCommonsMenuItem> menuItems = ucsbDiningCommonsMenuItemRepository.findAll(); | |
44 |
1
1. allUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItems → KILLED |
return menuItems; |
45 | } | |
46 | ||
47 | @Operation(summary= "Create a new menu item") | |
48 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
49 | @PostMapping("/post") | |
50 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
51 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
52 | @Parameter(name="name") @RequestParam String name, | |
53 | @Parameter(name="station") @RequestParam String station | |
54 | ) | |
55 | { | |
56 | ||
57 | UCSBDiningCommonsMenuItem menuItem = new UCSBDiningCommonsMenuItem(); | |
58 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(diningCommonsCode); |
59 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
menuItem.setName(name); |
60 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
menuItem.setStation(station); |
61 | | |
62 | UCSBDiningCommonsMenuItem savedMenuItems = ucsbDiningCommonsMenuItemRepository.save(menuItem); | |
63 | ||
64 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedMenuItems; |
65 | } | |
66 | ||
67 | ||
68 | @Operation(summary= "Get a single menu item") | |
69 | @PreAuthorize("hasRole('ROLE_USER')") | |
70 | @GetMapping("") | |
71 | public UCSBDiningCommonsMenuItem getById( | |
72 | @Parameter(name="id") @RequestParam Long id) { | |
73 | UCSBDiningCommonsMenuItem ucsbMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
74 |
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)); |
75 | ||
76 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbMenuItem; |
77 | } | |
78 | @Operation(summary= "Update a single menu item") | |
79 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
80 | @PutMapping("") | |
81 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
82 | @Parameter(name="id") @RequestParam Long id, | |
83 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
84 | ||
85 | UCSBDiningCommonsMenuItem ucsbMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
86 |
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)); |
87 | ||
88 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
89 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbMenuItem.setName(incoming.getName()); |
90 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbMenuItem.setStation(incoming.getStation()); |
91 | ||
92 | ucsbDiningCommonsMenuItemRepository.save(ucsbMenuItem); | |
93 | ||
94 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbMenuItem; |
95 | } | |
96 | ||
97 | @Operation(summary= "Delete a UCSBDiningCommonsMenuItem") | |
98 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
99 | @DeleteMapping("") | |
100 | public Object deleteUCSBDiningCommonsMenuItem( | |
101 | @Parameter(name="id") @RequestParam Long id) { | |
102 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
103 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
104 | ||
105 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
106 |
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)); |
107 | } | |
108 | ||
109 | ||
110 | ||
111 | | |
112 | } | |
Mutations | ||
44 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
64 |
1.1 |
|
74 |
1.1 |
|
76 |
1.1 |
|
86 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
94 |
1.1 |
|
103 |
1.1 |
|
105 |
1.1 |
|
106 |
1.1 |