1 | package edu.ucsb.cs156.dining.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.dining.models.Meal; | |
4 | import edu.ucsb.cs156.dining.services.MealService; | |
5 | import io.swagger.v3.oas.annotations.Operation; | |
6 | import io.swagger.v3.oas.annotations.tags.Tag; | |
7 | import lombok.extern.slf4j.Slf4j; | |
8 | import org.springframework.beans.factory.annotation.Autowired; | |
9 | import org.springframework.security.access.prepost.PreAuthorize; | |
10 | import org.springframework.web.bind.annotation.GetMapping; | |
11 | import org.springframework.web.bind.annotation.PathVariable; | |
12 | import io.swagger.v3.oas.annotations.Parameter; | |
13 | import org.springframework.web.bind.annotation.RequestMapping; | |
14 | import org.springframework.web.bind.annotation.RestController; | |
15 | ||
16 | import java.time.LocalDateTime; | |
17 | import java.util.List; | |
18 | ||
19 | /** Controller for Meal */ | |
20 | @Tag(name = "Meal") | |
21 | @RestController | |
22 | @RequestMapping("/api/diningcommons") | |
23 | @Slf4j | |
24 | public class MealController { | |
25 | ||
26 | @Autowired | |
27 | private MealService mealService; | |
28 | ||
29 | /** | |
30 | * Endpoint to fetch all meals served in a particular dining commons on a specific date. | |
31 | * | |
32 | * @param dateTime the date and time as a LocalDateTime | |
33 | * @param diningCommonsCode the dining commons code | |
34 | * @return a list of meals | |
35 | * @throws Exception if the API request fails | |
36 | */ | |
37 | @Operation(summary = "Get all meals for a specific date and dining commons") | |
38 | @PreAuthorize("hasRole('ROLE_USER')") | |
39 | @GetMapping("/{dateTime}/{diningCommonsCode}") | |
40 | public List<Meal> getMeals( | |
41 | @Parameter(description = "ISO date and time (e.g., 2005-12-06T00:00:00)") | |
42 | @PathVariable LocalDateTime dateTime, | |
43 | @PathVariable String diningCommonsCode) throws Exception { | |
44 | log.info("Fetching meals for date: {} and dining commons: {}", dateTime, diningCommonsCode); | |
45 |
1
1. getMeals : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/MealController::getMeals → KILLED |
return mealService.getMeals(dateTime, diningCommonsCode); |
46 | } | |
47 | } | |
Mutations | ||
45 |
1.1 |