package com.ffii.fpsms.modules.dashboard.web

import com.ffii.fpsms.modules.dashboard.service.GoodsReceiptStatusService
import com.ffii.fpsms.modules.dashboard.web.models.GoodsReceiptStatusResponse
import org.springframework.format.annotation.DateTimeFormat
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
import java.time.LocalDate

@RestController
@RequestMapping("/dashboard")
class DashboardController(
    private val goodsReceiptStatusService: GoodsReceiptStatusService
) {
    @GetMapping("/goods-receipt-status")
    fun getGoodsReceiptStatus(
        @RequestParam(required = false)
        @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
        date: LocalDate?
    ): List<GoodsReceiptStatusResponse> {
        return goodsReceiptStatusService.getGoodsReceiptStatus(date ?: LocalDate.now())
    }
}

