package de.avatic.taric.controller;

import de.avatic.taric.model.Measure;
import de.avatic.taric.model.MeasureAction;
import de.avatic.taric.model.MeasureSeries;
import de.avatic.taric.repository.MeasureActionRepository;
import de.avatic.taric.repository.MeasureRepository;
import de.avatic.taric.repository.MeasureSeriesRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/measures")
public class MeasureController {

    private final MeasureRepository measureRepository;
    private final MeasureSeriesRepository measureSeriesRepository;
    private final MeasureActionRepository measureActionRepository;

    public MeasureController(MeasureRepository measureRepository, MeasureSeriesRepository measureSeriesRepository, MeasureActionRepository measureActionRepository) {
        this.measureRepository = measureRepository;
        this.measureSeriesRepository = measureSeriesRepository;
        this.measureActionRepository = measureActionRepository;
    }

    @GetMapping
    public Iterable<Measure> getMeasures() {
        return measureRepository.findAll();
    }

    @GetMapping("/series")
    public Iterable<MeasureSeries> getMeasuresSeries() {
        return measureSeriesRepository.findAll();
    }

    @GetMapping("/action")
    public Iterable<MeasureAction> getMeasuresAction() {
        return measureActionRepository.findAll();
    }
}
