35 lines
1.3 KiB
Java
35 lines
1.3 KiB
Java
|
package ru.ulstu.controllers;
|
||
|
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.http.HttpStatus;
|
||
|
import org.springframework.http.ResponseEntity;
|
||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
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;
|
||
|
|
||
|
@Autowired
|
||
|
public TimeSeriesController(TimeSeriesService timeSeriesService) {
|
||
|
this.timeSeriesService = timeSeriesService;
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "ts.is_alive", method = RequestMethod.GET)
|
||
|
public ResponseEntity<Boolean> isAlive() {
|
||
|
return new ResponseEntity<>(true, HttpStatus.OK);
|
||
|
}
|
||
|
|
||
|
@RequestMapping(value = "ts.get_random", method = RequestMethod.GET)
|
||
|
public ResponseEntity<TimeSeries> getRandomTimeSeries(@RequestParam("length") int length) {
|
||
|
return new ResponseEntity<>(timeSeriesService.getRandomTimeSeries(length), HttpStatus.OK);
|
||
|
}
|
||
|
}
|