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 | 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 jakarta.validation.Valid; | |
27 | ||
28 | import java.time.LocalDateTime; | |
29 | ||
30 | @Tag(name = "UCSBDiningCommonsMenuItems") | |
31 | @RequestMapping("/api/ucsbdiningcommonsmenuitems") | |
32 | @RestController | |
33 | @Slf4j | |
34 | ||
35 | public class UCSBDiningCommonsMenuItemsController extends ApiController { | |
36 | ||
37 | @Autowired | |
38 | UCSBDiningCommonsMenuItemsRepository ucsbDiningCommonsMenuItemsRepository; | |
39 | ||
40 | /** | |
41 | * List all UCSB dining common items | |
42 | * | |
43 | * @return an iterable of UCSBDiningCommonsMenuItems | |
44 | */ | |
45 | @Operation(summary= "List all ucsb dining common menu items") | |
46 | @PreAuthorize("hasRole('ROLE_USER')") | |
47 | @GetMapping("/all") | |
48 | public Iterable<UCSBDiningCommonsMenuItems> allUCSBDiningCommonsMenuItems() { | |
49 | Iterable<UCSBDiningCommonsMenuItems> items = ucsbDiningCommonsMenuItemsRepository.findAll(); | |
50 |
1
1. allUCSBDiningCommonsMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::allUCSBDiningCommonsMenuItems → KILLED |
return items; |
51 | } | |
52 | ||
53 | /** | |
54 | * Get a single DiningCommonsMenuItems by id | |
55 | * | |
56 | * @param id the id of the DiningCommonsMenuItems | |
57 | * @return a UCSBDiningCommonsMenuItems | |
58 | */ | |
59 | @Operation(summary= "Get a single DiningCommonsMenuItems") | |
60 | @PreAuthorize("hasRole('ROLE_USER')") | |
61 | @GetMapping("") | |
62 | public UCSBDiningCommonsMenuItems getById( | |
63 | @Parameter(name="id") @RequestParam Long id) { | |
64 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
65 |
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)); |
66 | ||
67 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::getById → KILLED |
return ucsbDiningCommonsMenuItems; |
68 | } | |
69 | ||
70 | /** | |
71 | * Create a new DiningCommonsMenuItems | |
72 | * | |
73 | * @param diningCommonsCode the dining common code | |
74 | * @param name the name items | |
75 | * @param station the item station | |
76 | * @return the saved menu item | |
77 | */ | |
78 | @Operation(summary= "Create a new menu item") | |
79 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
80 | @PostMapping("/post") | |
81 | public UCSBDiningCommonsMenuItems postUCSBDiningCommonsMenuItems( | |
82 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
83 | @Parameter(name="name") @RequestParam String name, | |
84 | @Parameter(name="station") @RequestParam String station) | |
85 | throws JsonProcessingException { | |
86 | ||
87 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = new UCSBDiningCommonsMenuItems(); | |
88 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItems.setDiningCommonsCode(diningCommonsCode); |
89 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
ucsbDiningCommonsMenuItems.setName(name); |
90 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
ucsbDiningCommonsMenuItems.setStation(station); |
91 | ||
92 | UCSBDiningCommonsMenuItems savedUcsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.save(ucsbDiningCommonsMenuItems); | |
93 | ||
94 |
1
1. postUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::postUCSBDiningCommonsMenuItems → KILLED |
return savedUcsbDiningCommonsMenuItems; |
95 | } | |
96 | ||
97 | /** | |
98 | * Delete a UCSBDiningCommonsMenuItems | |
99 | * | |
100 | * @param id the id of the DiningCommonsMenuItems to delete | |
101 | * @return a message indicating the DiningCommonsMenuItems was deleted | |
102 | */ | |
103 | @Operation(summary= "Delete a UCSBDiningCommonsMenuItems") | |
104 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
105 | @DeleteMapping("") | |
106 | public Object deleteUCSBDiningCommonsMenuItems( | |
107 | @Parameter(name="id") @RequestParam Long id) { | |
108 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
109 |
1
1. lambda$deleteUCSBDiningCommonsMenuItems$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$deleteUCSBDiningCommonsMenuItems$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
110 | ||
111 |
1
1. deleteUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED |
ucsbDiningCommonsMenuItemsRepository.delete(ucsbDiningCommonsMenuItems); |
112 |
1
1. deleteUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::deleteUCSBDiningCommonsMenuItems → KILLED |
return genericMessage("UCSBDiningCommonsMenuItems with id %s deleted".formatted(id)); |
113 | } | |
114 | ||
115 | /** | |
116 | * Update a single DiningCommonsMenuItems | |
117 | * | |
118 | * @param id id of the DiningCommonsMenuItems to update | |
119 | * @param incoming the new DiningCommonsMenuItems | |
120 | * @return the updated DiningCommonsMenuItems object | |
121 | */ | |
122 | @Operation(summary= "Update a single DiningCommonsMenuItems") | |
123 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
124 | @PutMapping("") | |
125 | public UCSBDiningCommonsMenuItems updateUCSBDiningCommonsMenuItems( | |
126 | @Parameter(name="id") @RequestParam Long id, | |
127 | @RequestBody @Valid UCSBDiningCommonsMenuItems incoming) { | |
128 | ||
129 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
130 |
1
1. lambda$updateUCSBDiningCommonsMenuItems$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$updateUCSBDiningCommonsMenuItems$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
131 | ||
132 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItems.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
133 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
ucsbDiningCommonsMenuItems.setName(incoming.getName()); |
134 |
1
1. updateUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
ucsbDiningCommonsMenuItems.setStation(incoming.getStation()); |
135 | ||
136 | ucsbDiningCommonsMenuItemsRepository.save(ucsbDiningCommonsMenuItems); | |
137 | ||
138 |
1
1. updateUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::updateUCSBDiningCommonsMenuItems → KILLED |
return ucsbDiningCommonsMenuItems; |
139 | } | |
140 | } | |
Mutations | ||
50 |
1.1 |
|
65 |
1.1 |
|
67 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
94 |
1.1 |
|
109 |
1.1 |
|
111 |
1.1 |
|
112 |
1.1 |
|
130 |
1.1 |
|
132 |
1.1 |
|
133 |
1.1 |
|
134 |
1.1 |
|
138 |
1.1 |