package dev.fyloz.trial.colorrecipesexplorer.rest

import dev.fyloz.trial.colorrecipesexplorer.model.*
import dev.fyloz.trial.colorrecipesexplorer.service.MixService
import dev.fyloz.trial.colorrecipesexplorer.service.RecipeService
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid


private const val RECIPE_CONTROLLER_PATH = "api/recipe"
private const val MIX_CONTROLLER_PATH = "api/recipe/mix"

@RestController
@RequestMapping(RECIPE_CONTROLLER_PATH)
class RecipeController(recipeService: RecipeService) :
    AbstractModelRestApiController<Recipe, RecipeSaveDto, RecipeUpdateDto, RecipeService>(
        recipeService,
        RECIPE_CONTROLLER_PATH
    ) {
    @PutMapping("public")
    fun updatePublicData(@Valid @RequestBody publicDataDto: RecipePublicDataDto): ResponseEntity<Void> {
        service.updatePublicData(publicDataDto)
        return ResponseEntity.noContent().build()
    }
}

@RestController
@RequestMapping(MIX_CONTROLLER_PATH)
class MixController(val mixService: MixService) :
    AbstractModelRestApiController<Mix, MixSaveDto, MixUpdateDto, MixService>(mixService, MIX_CONTROLLER_PATH)
