package dev.fyloz.trial.colorrecipesexplorer.rest

import dev.fyloz.trial.colorrecipesexplorer.model.Material
import dev.fyloz.trial.colorrecipesexplorer.model.MaterialSaveDto
import dev.fyloz.trial.colorrecipesexplorer.model.MaterialUpdateDto
import dev.fyloz.trial.colorrecipesexplorer.service.MaterialService
import org.springframework.context.annotation.Profile
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

private const val MATERIAL_CONTROLLER_PATH = "api/material"

@RestController
@RequestMapping(MATERIAL_CONTROLLER_PATH)
@Profile("rest")
class MaterialController(materialService: MaterialService) : AbstractRestModelApiController<Material, MaterialSaveDto, MaterialUpdateDto, MaterialService>(materialService, MATERIAL_CONTROLLER_PATH) {
    @PostMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
    override fun save(entity: MaterialSaveDto): ResponseEntity<Material> = super.save(entity)

    @PutMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
    override fun update(entity: MaterialUpdateDto): ResponseEntity<Void> {
        return super.update(entity)
    }
}
