package com.kamco.cd.kamcoback.common.api;

import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.inference.dto.LearningModelResultDto;
import com.kamco.cd.kamcoback.inference.service.InferenceResultService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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 java.util.List;
import lombok.RequiredArgsConstructor;
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;

@Tag(name = "공통", description = "공통")
@RestController
@RequiredArgsConstructor
@RequestMapping({"/demo/common", "/api/common"})
public class CommonController {

  private final InferenceResultService inferenceResultService;

  @Operation(summary = "추론된 도엽 목록", description = "추론된 도엽 목록 5000:1")
  @ApiResponses(
      value = {
        @ApiResponse(
            responseCode = "200",
            description = "검색 성공",
            content =
                @Content(
                    mediaType = "application/json",
                    schema =
                        @Schema(
                            implementation = LearningModelResultDto.BatchProcessResponse.class))),
        @ApiResponse(responseCode = "400", description = "잘못된 요청", content = @Content),
        @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
      })
  @GetMapping("/sheets/{id}")
  public ApiResponseDto<List<String>> getSheets(
      @Parameter(description = "분석결과 id", example = "1") @PathVariable Long id) {
    return ApiResponseDto.ok(inferenceResultService.getSheets(id));
  }
}
