2018-02-22 22:47:45 +04:00
|
|
|
package ru.ulstu.controllers;
|
|
|
|
|
2020-09-12 13:11:09 +04:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
2018-02-22 22:47:45 +04:00
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
2020-09-12 13:11:09 +04:00
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
2018-02-22 22:47:45 +04:00
|
|
|
import ru.ulstu.configurations.ApiConfiguration;
|
|
|
|
import ru.ulstu.models.TimeSeries;
|
|
|
|
import ru.ulstu.services.TimeSeriesService;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping(ApiConfiguration.API_1_0)
|
|
|
|
public class TimeSeriesController {
|
|
|
|
|
|
|
|
private final TimeSeriesService timeSeriesService;
|
|
|
|
|
|
|
|
public TimeSeriesController(TimeSeriesService timeSeriesService) {
|
|
|
|
this.timeSeriesService = timeSeriesService;
|
|
|
|
}
|
|
|
|
|
2020-09-12 13:11:09 +04:00
|
|
|
@GetMapping("isAlive")
|
|
|
|
@ApiOperation("Проверка сервиса")
|
2018-02-22 22:47:45 +04:00
|
|
|
public ResponseEntity<Boolean> isAlive() {
|
|
|
|
return new ResponseEntity<>(true, HttpStatus.OK);
|
|
|
|
}
|
|
|
|
|
2020-09-12 13:11:09 +04:00
|
|
|
@GetMapping("getRandom")
|
|
|
|
@ApiOperation("Получить временной ряд рандомной длины")
|
2018-02-22 22:47:45 +04:00
|
|
|
public ResponseEntity<TimeSeries> getRandomTimeSeries(@RequestParam("length") int length) {
|
|
|
|
return new ResponseEntity<>(timeSeriesService.getRandomTimeSeries(length), HttpStatus.OK);
|
|
|
|
}
|
2018-02-24 23:00:30 +04:00
|
|
|
|
2020-09-12 13:11:09 +04:00
|
|
|
@PostMapping("getForecast")
|
|
|
|
@ApiOperation("Получить прогноз временного ряда")
|
2018-02-24 23:00:30 +04:00
|
|
|
public ResponseEntity<TimeSeries> getForecastTimeSeries(@RequestBody TimeSeries timeSeries) {
|
|
|
|
return new ResponseEntity<>(timeSeriesService.getForecast(timeSeries), HttpStatus.OK);
|
|
|
|
}
|
2018-02-22 22:47:45 +04:00
|
|
|
}
|