package com.kt.event.eventservice.presentation.controller;

import com.kt.event.common.dto.ApiResponse;
import com.kt.event.eventservice.application.dto.response.JobStatusResponse;
import com.kt.event.eventservice.application.service.JobService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Job 컨트롤러
 *
 * 비동기 작업 상태 조회 API를 제공합니다.
 *
 * @author Event Service Team
 * @version 1.0.0
 * @since 2025-10-23
 */
@Slf4j
@RestController
@RequestMapping("/jobs")
@RequiredArgsConstructor
@Tag(name = "Job", description = "비동기 작업 상태 조회 API")
public class JobController {

    private final JobService jobService;

    /**
     * Job 상태 조회
     *
     * @param jobId Job ID
     * @return Job 상태 응답
     */
    @GetMapping("/{jobId}")
    @Operation(summary = "Job 상태 조회", description = "비동기 작업의 상태를 조회합니다 (폴링 방식).")
    public ResponseEntity<ApiResponse<JobStatusResponse>> getJobStatus(@PathVariable String jobId) {
        log.info("Job 상태 조회 API 호출 - jobId: {}", jobId);

        JobStatusResponse response = jobService.getJobStatus(jobId);

        return ResponseEntity.ok(ApiResponse.success(response));
    }
}
