package dp.kotul.templategroupsbackend.controller

import dp.kotul.starter.global.DefaultApiResponses
import dp.kotul.templategroupsbackend.facade.TemplateVariableFacade
import dp.kotul.templategroupsbackend.model.response.TemplateVariableBasicResponse
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Api(tags = ["Template variables"], description = "Provides API for template variables operations")
@DefaultApiResponses
@RestController
@RequestMapping("/templates", produces = [MediaType.APPLICATION_JSON_VALUE])
class TemplateVariableController(val templateVariableFacade: TemplateVariableFacade) {

    @ApiOperation(value = "Get template variables basic", notes = "Returns template variables with basic information defined by template id")
    @GetMapping("{templateId}/variables")
    fun getTemplateVariablesBasic(
            @ApiParam(value = "Template ID", required = true) @PathVariable templateId: Int,
            @ApiParam(value = "Language ID", required = false) @RequestParam laeId: Int?
    ): List<TemplateVariableBasicResponse> {
        return templateVariableFacade.getTemplateVariables(templateId, laeId)
    }
}
