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