This repository was archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParkingAPI.java
More file actions
43 lines (32 loc) · 1.59 KB
/
ParkingAPI.java
File metadata and controls
43 lines (32 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dev.wms.pwrapi.api;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.core.JsonProcessingException;
import dev.wms.pwrapi.dto.parking.Parking;
import dev.wms.pwrapi.dto.parking.ParkingWithHistory;
import dev.wms.pwrapi.service.parking.ParkingService;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
@RestController
@RequestMapping(value="/api/parking", produces = "application/json")
@AllArgsConstructor
public class ParkingAPI {
private ParkingService parkingService;
@GetMapping
@Operation(summary = "Returns processed data from skd.pwr.edu.pl", description = "You can use it to get data from skd.pwr.edu.pl in simple format")
public ResponseEntity<List<Parking>> getProcessedParkingInfo() throws JsonProcessingException, IOException{
List<Parking> result = parkingService.getParkingData();
return ResponseEntity.status(HttpStatus.OK).body(result);
}
@GetMapping("/raw")
@Operation(summary = "Returns history data from skd.pwr.edu.pl",
description = "You can use it to get parking history data from last 24h")
public ResponseEntity<List<ParkingWithHistory>> getRawParkingInfo() throws IOException{
return ResponseEntity.status(HttpStatus.OK).body(parkingService.getRawParkingData());
}
}