package de.thpeetz.kontor.comics

import de.thpeetz.kontor.KontorProperties
import de.thpeetz.kontor.Navigation
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.ui.set
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping

@Controller
@RequestMapping("/comics")
class ComicsController(private val properties: KontorProperties,
                       val navigation: Navigation,
                       val comicRepository: ComicRepository
) {

    @GetMapping("/")
    fun blog(model: Model): String {
        model["title"] = properties.title
        model["title"] = "Comics"
        model["banner"] = properties.banner
        model["navigation"] = navigation.links()
        model["comics"] = comicRepository.findAll().map { it }
        return "comics"
    }


}
