package com.ffii.fpsms.modules.qc.web

import com.ffii.fpsms.modules.master.web.models.MessageResponse
import com.ffii.fpsms.modules.qc.entity.projection.QcResultInfo
import com.ffii.fpsms.modules.qc.service.QcResultService
import com.ffii.fpsms.modules.qc.web.model.SaveQcResultRequest
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/qcResult")
class QcResultController(
    private val qcResultService: QcResultService
) {

    @PostMapping("/new")
    fun saveItem(@Valid @RequestBody request: SaveQcResultRequest): MessageResponse {
        return qcResultService.createOrUpdate(request)
    }

    @GetMapping("/{stockInLineId}")
    fun getAllQcResultInfoByStockInLineId(@PathVariable stockInLineId: Long): List<QcResultInfo> {
        return qcResultService.getAllQcResultInfoByStockInLineId(stockInLineId)
    }

    @GetMapping("/pick-order/{stockOutLineId}")
    fun getAllQcResultInfoByStockOutLineId(@PathVariable stockOutLineId: Long): List<QcResultInfo> {
        return qcResultService.getAllQcResultInfoByStockOutLineId(stockOutLineId)
    }
}