| 1 | package edu.ucsb.cs156.dining.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.dining.services.UCSBDiningMenuService; | |
| 4 | import io.swagger.v3.oas.annotations.Operation; | |
| 5 | import io.swagger.v3.oas.annotations.Parameter; | |
| 6 | import io.swagger.v3.oas.annotations.responses.ApiResponse; | |
| 7 | import io.swagger.v3.oas.annotations.responses.ApiResponses; | |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 9 | import lombok.extern.slf4j.Slf4j; | |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | import org.springframework.http.ResponseEntity; | |
| 12 | import org.springframework.web.bind.annotation.GetMapping; | |
| 13 | import org.springframework.web.bind.annotation.PathVariable; | |
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | import org.springframework.web.bind.annotation.RestController; | |
| 16 | import org.springframework.web.client.HttpClientErrorException; | |
| 17 | ||
| 18 | @Tag(name = "UCSBDiningMenuController") | |
| 19 | @RestController | |
| 20 | @RequestMapping("/api/diningcommons") | |
| 21 | @Slf4j | |
| 22 | public class UCSBDiningMenuController extends ApiController { | |
| 23 | ||
| 24 | @Autowired UCSBDiningMenuService ucsbDiningMenuService; | |
| 25 | ||
| 26 | @Operation(summary = "Get list of meals serving in given dining common on given date") | |
| 27 | @ApiResponses( | |
| 28 | value = { | |
| 29 | @ApiResponse(responseCode = "200", description = "OK"), | |
| 30 | @ApiResponse(responseCode = "204", description = "No meals offered on this date") | |
| 31 | }) | |
| 32 | @GetMapping(value = "/{date-time}/{dining-commons-code}", produces = "application/json") | |
| 33 | public ResponseEntity<String> menutimes( | |
| 34 | @Parameter( | |
| 35 | description = | |
| 36 | "date (in iso format, e.g. YYYY-mm-dd) or date-time (in iso format e.g. YYYY-mm-ddTHH:MM:SS)") | |
| 37 | @PathVariable("date-time") | |
| 38 | String datetime, | |
| 39 | @PathVariable("dining-commons-code") String diningcommoncode) | |
| 40 | throws Exception { | |
| 41 | ||
| 42 | try { | |
| 43 | String body = ucsbDiningMenuService.getJSON(datetime, diningcommoncode); | |
| 44 |
1
1. menutimes : replaced return value with null for edu/ucsb/cs156/dining/controllers/UCSBDiningMenuController::menutimes → KILLED |
return ResponseEntity.ok().body(body); |
| 45 | } catch ( | |
| 46 | HttpClientErrorException.NotFound | |
| 47 | e) { // Handle 404 (Happens when no meal is found) by returning 204 | |
| 48 |
1
1. menutimes : replaced return value with null for edu/ucsb/cs156/dining/controllers/UCSBDiningMenuController::menutimes → KILLED |
return ResponseEntity.noContent().build(); |
| 49 | } | |
| 50 | } | |
| 51 | } | |
Mutations | ||
| 44 |
1.1 |
|
| 48 |
1.1 |