package de.avatic.taric.controller;

import de.avatic.taric.model.ConditionType;
import de.avatic.taric.repository.ConditionTypeRepository;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/conditions")
@Tag(name = "Conditions", description = "API endpoints for retrieving condition types")
public class ConditionController {

    private final ConditionTypeRepository conditionTypeRepository;

    public ConditionController(ConditionTypeRepository conditionTypeRepository) {
        this.conditionTypeRepository = conditionTypeRepository;
    }

    @Operation(
            summary = "Get all condition types",
            description = "Retrieves a complete list of all available condition types in the system"
    )
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = "200",
                    description = "Successfully retrieved condition types",
                    content = @Content(mediaType = "application/json", schema = @Schema(implementation = ConditionType.class))
            )
    })
    @GetMapping
    public Iterable<ConditionType> getConditions() {
        return conditionTypeRepository.findAll();
    }
}