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