package com.kamco.cd.kamcoback.scheduler;

import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "스캐쥴러 API", description = "스캐쥴러 API")
@RestController
@RequiredArgsConstructor
@RequestMapping({"/api/job"})
public class MapSheetMngFileJobApiController {

  private final CommonCodeService commonCodeService;
  private final MapSheetMngFileJobController mapSheetMngFileJobController;

  @Operation(summary = "영상관리 파일 싱크 스캐쥴러 Start/Stop", description = "영상관리 파일 싱크 스캐쥴러 Start/Stop API")
  @ApiResponses(
      value = {
        @ApiResponse(
            responseCode = "200",
            description = "조회 성공",
            content =
                @Content(
                    mediaType = "application/json",
                    schema = @Schema(implementation = CommonCodeDto.Basic.class))),
        @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
        @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
      })
  @PutMapping("/mng-sync-job")
  public ApiResponseDto<String> mngSyncOnOff(
      @RequestParam boolean jobStart, @RequestParam int pageSize) {

    mapSheetMngFileJobController.setSchedulerEnabled(jobStart);
    mapSheetMngFileJobController.setMngSyncPageSize(pageSize);

    return ApiResponseDto.createOK("OK");
  }
}
