1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBDate; | |
4 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItems; | |
5 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
6 | import edu.ucsb.cs156.example.repositories.UCSBDateRepository; | |
7 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemsRepository; | |
8 | import io.swagger.v3.oas.annotations.Operation; | |
9 | import io.swagger.v3.oas.annotations.Parameter; | |
10 | import io.swagger.v3.oas.annotations.tags.Tag; | |
11 | import liquibase.pro.packaged.id; | |
12 | import lombok.extern.slf4j.Slf4j; | |
13 | ||
14 | import com.fasterxml.jackson.core.JsonProcessingException; | |
15 | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | |
17 | import org.springframework.format.annotation.DateTimeFormat; | |
18 | import org.springframework.security.access.prepost.PreAuthorize; | |
19 | import org.springframework.web.bind.annotation.DeleteMapping; | |
20 | import org.springframework.web.bind.annotation.GetMapping; | |
21 | import org.springframework.web.bind.annotation.PostMapping; | |
22 | import org.springframework.web.bind.annotation.PutMapping; | |
23 | import org.springframework.web.bind.annotation.RequestBody; | |
24 | import org.springframework.web.bind.annotation.RequestMapping; | |
25 | import org.springframework.web.bind.annotation.RequestParam; | |
26 | import org.springframework.web.bind.annotation.RestController; | |
27 | ||
28 | import javax.validation.Valid; | |
29 | ||
30 | import java.time.LocalDateTime; | |
31 | ||
32 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
33 | @RequestMapping("/api/UCSBDiningCommonsMenuItem") | |
34 | @RestController | |
35 | @Slf4j | |
36 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
37 | ||
38 | @Autowired | |
39 | UCSBDiningCommonsMenuItemsRepository ucsbDiningCommonsMenuItemsRepository; | |
40 | | |
41 | @PreAuthorize("hasRole('ROLE_USER')") | |
42 | @GetMapping("/all") | |
43 | public Iterable<UCSBDiningCommonsMenuItems> allUCSBDates() { | |
44 | Iterable<UCSBDiningCommonsMenuItems> dates = ucsbDiningCommonsMenuItemsRepository.findAll(); | |
45 |
1
1. allUCSBDates : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDates → KILLED |
return dates; |
46 | } | |
47 | ||
48 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
49 | @PostMapping("/post") | |
50 | public UCSBDiningCommonsMenuItems postUCSBDiningCommonsMenuItems( | |
51 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
52 | @Parameter(name="name") @RequestParam String name, | |
53 | @Parameter(name="station") @RequestParam String station) | |
54 | throws JsonProcessingException { | |
55 | ||
56 | // For an explanation of @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | |
57 | // See: https://www.baeldung.com/spring-date-parameters | |
58 | ||
59 | log.info("station={}", station); | |
60 | ||
61 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = new UCSBDiningCommonsMenuItems(); | |
62 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItems.setDiningCommonsCode(diningCommonsCode); |
63 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
ucsbDiningCommonsMenuItems.setName(name); |
64 |
1
1. postUCSBDiningCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
ucsbDiningCommonsMenuItems.setStation(station); |
65 | ||
66 | UCSBDiningCommonsMenuItems savedUcsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.save(ucsbDiningCommonsMenuItems); | |
67 | ||
68 |
1
1. postUCSBDiningCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItems → KILLED |
return savedUcsbDiningCommonsMenuItems; |
69 | } | |
70 | ||
71 | @Operation(summary= "Get a single menu item") | |
72 | @PreAuthorize("hasRole('ROLE_USER')") | |
73 | @GetMapping("") | |
74 | public UCSBDiningCommonsMenuItems getById( | |
75 | @Parameter(name="id") @RequestParam Long id) { | |
76 | | |
77 | UCSBDiningCommonsMenuItems ucsbDiningCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
78 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
79 | ||
80 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItems; |
81 | } | |
82 | ||
83 | @Operation(summary= "Update a single menu") | |
84 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
85 | @PutMapping("") | |
86 | public UCSBDiningCommonsMenuItems updateUCSBDiningCommonsMenuItem( | |
87 | @Parameter(name="id") @RequestParam Long id, | |
88 | @RequestBody @Valid UCSBDiningCommonsMenuItems incoming) { | |
89 | ||
90 | UCSBDiningCommonsMenuItems menuItem = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
91 |
1
1. lambda$updateUCSBDiningCommonsMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonsMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
92 | ||
93 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
94 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
menuItem.setName(incoming.getName()); |
95 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
menuItem.setStation(incoming.getStation()); |
96 | ||
97 | ucsbDiningCommonsMenuItemsRepository.save(menuItem); | |
98 | ||
99 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return menuItem; |
100 | } | |
101 | ||
102 | @Operation(summary= "Delete a UCSBDine") | |
103 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
104 | @DeleteMapping("") | |
105 | public Object deleteUCSBDate( | |
106 | @Parameter(name="id") @RequestParam Long id) { | |
107 | UCSBDiningCommonsMenuItems ucsbDate = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
108 |
1
1. lambda$deleteUCSBDate$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDate$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
109 | ||
110 |
1
1. deleteUCSBDate : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED |
ucsbDiningCommonsMenuItemsRepository.delete(ucsbDate); |
111 |
1
1. deleteUCSBDate : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteUCSBDate → KILLED |
return genericMessage("UCSBDiningCommonsMenuItems with id 123 not found".formatted(id)); |
112 | } | |
113 | } | |
Mutations | ||
45 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
68 |
1.1 |
|
78 |
1.1 |
|
80 |
1.1 |
|
91 |
1.1 |
|
93 |
1.1 |
|
94 |
1.1 |
|
95 |
1.1 |
|
99 |
1.1 |
|
108 |
1.1 |
|
110 |
1.1 |
|
111 |
1.1 |