package gaf3.core.services.code

import gaf3.core.data.PagedData
import gaf3.core.services.code.domain.CodeItem
import gaf3.core.services.code.service.impl.AutoCodeStore
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController

@RestController
class CodeStoreController(val service: AutoCodeStore) {
    @GetMapping(path = ["/gaf/code/{type}/items"])
    fun load(@PathVariable type: String): PagedData<CodeItem> {
        return service.load(type).let {
            PagedData(it, it.size)
        }
    }
}