package com.ffii.fpsms.modules.stock.web

import com.ffii.fpsms.modules.master.web.models.MessageResponse
import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderLine
import com.ffii.fpsms.modules.stock.entity.StockOutLine
import com.ffii.fpsms.modules.stock.entity.projection.StockOutLineInfo
import com.ffii.fpsms.modules.stock.service.StockInLineService
import com.ffii.fpsms.modules.stock.service.StockOutLineService
import com.ffii.fpsms.modules.stock.web.model.CreateStockOutLineRequest
import com.ffii.fpsms.modules.stock.web.model.UpdateStockOutLineRequest
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/stockOutLine")
class StockOutLineController(
    private val stockOutLineService: StockOutLineService
) {
    @GetMapping("/getByPickOrderLineId/{pickOrderLineId}")
    fun getByPurchaseOrderLineId(@Valid @PathVariable pickOrderLineId: Long): List<StockOutLineInfo> {
        return stockOutLineService.getAllStockOutLineByPickOrderLineId(pickOrderLineId)
    }

    @PostMapping("/create")
    fun create(@Valid @RequestBody request: CreateStockOutLineRequest): MessageResponse {
        return stockOutLineService.create(request)
    }
    @PostMapping("/update")
    fun update(@Valid @RequestBody request: UpdateStockOutLineRequest): MessageResponse {
        println("triggering")
        return stockOutLineService.update(request)
    }
}