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

import com.ffii.fpsms.modules.stock.entity.EscalationLogInfo
import com.ffii.fpsms.modules.stock.service.EscalationLogService
import com.ffii.fpsms.modules.stock.web.model.SaveEscalationLogRequest
import com.ffii.fpsms.modules.stock.web.model.SaveEscalationLogResponse
import com.ffii.fpsms.modules.stock.web.model.SearchEscalationLogRequest
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/escalationLog")
class EscalationLogController(
    private val escalationLogService: EscalationLogService
) {
    @GetMapping("/stockInLines")
    fun getLogsByStockInLines(@ModelAttribute request: SearchEscalationLogRequest): List<EscalationLogInfo> {
        return escalationLogService.getLogsByStockInLines(request.stockInLineIds);
    }

    @GetMapping("/stockInLine")
    fun getLogsByStockInLine(@ModelAttribute request: SearchEscalationLogRequest): List<EscalationLogInfo> {
        return escalationLogService.getLogsByStockInLine(request.stockInLineId);
    }

    @GetMapping("/user")
    fun getLogsByUser(): List<EscalationLogInfo> {
        return escalationLogService.getLogsByUser();
    }

    @PostMapping("/save")
    fun saveEscalationLog(@Valid @RequestBody request: SaveEscalationLogRequest): SaveEscalationLogResponse {
        return escalationLogService.saveEscalationLog(request);
    }
}