package com.erp.controller;

import com.erp.dto.ApiResponse;
import com.erp.service.PopProductionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/api/pop-production")
@RequiredArgsConstructor
@Slf4j
public class PopProductionController {

    private final PopProductionService popProductionService;

    @PostMapping("/create-work-processes")
    public ResponseEntity<ApiResponse<Map<String, Object>>> createWorkProcesses(
            @RequestAttribute("company_code") String companyCode,
            @RequestAttribute("user_id") String userId,
            @RequestBody Map<String, Object> body) {
        body.put("company_code", companyCode);
        body.put("user_id", userId);
        return ResponseEntity.ok(ApiResponse.success(popProductionService.createWorkProcesses(body)));
    }

    @PostMapping("/timer")
    public ResponseEntity<ApiResponse<Map<String, Object>>> controlTimer(
            @RequestAttribute("company_code") String companyCode,
            @RequestBody Map<String, Object> body) {
        body.put("company_code", companyCode);
        return ResponseEntity.ok(ApiResponse.success(popProductionService.controlTimer(body)));
    }
}
