package org.nstart.dep265.requestservice.controller

import org.nstart.dep265.requestservice.dto.CellPriorityMapResponseDto
import org.nstart.dep265.requestservice.dto.CellsListResponseDto
import org.nstart.dep265.requestservice.service.CellsQueryService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/v1/cells")
class CellsController(
    private val cellsQueryService: CellsQueryService,
) {
    @GetMapping
    fun listCells(
        @RequestParam(required = false) minImportance: Double?,
        @RequestParam(required = false) countLat: Int?,
        @RequestParam(required = false) countLong: Int?,
        @RequestParam(defaultValue = "0") page: Int,
        @RequestParam(defaultValue = "50") size: Int,
        @RequestParam(required = false) sort: String?,
    ): CellsListResponseDto {
        return cellsQueryService.listCells(
            minImportance = minImportance,
            countLat = countLat,
            countLong = countLong,
            page = page,
            size = size,
            sort = sort,
        )
    }

    @GetMapping("/priority-map")
    fun listCellsPriorityMap(
        @RequestParam(required = false) minImportance: Double?,
        @RequestParam(required = false) countLat: Int?,
        @RequestParam(required = false) countLong: Int?,
    ): CellPriorityMapResponseDto {
        return cellsQueryService.listCellsPriorityMap(
            minImportance = minImportance,
            countLat = countLat,
            countLong = countLong,
        )
    }
}
