You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.6 KiB
61 lines
2.6 KiB
|
8 months ago
|
package kr.re.etri.autoflow.controllers;
|
||
|
|
|
||
|
|
import io.swagger.v3.oas.annotations.Operation;
|
||
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
||
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||
|
|
import io.swagger.v3.oas.annotations.media.Content;
|
||
|
|
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 kr.re.etri.autoflow.service.DatasetService;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
@Tag(name = "Dataset API", description = "외부 데이터셋 목록 조회 API (Python requests 코드 기반)")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/datasets")
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
public class ExternalDataSetController {
|
||
|
|
|
||
|
|
private final DatasetService datasetService;
|
||
|
|
|
||
|
|
@Operation(
|
||
|
|
summary = "데이터셋 목록 조회",
|
||
|
|
description = "외부 API(/export/dataset_list)를 호출하여 데이터셋 목록을 조회합니다."
|
||
|
|
)
|
||
|
|
@ApiResponses({
|
||
|
|
@ApiResponse(responseCode = "200", description = "성공적으로 데이터셋을 조회했습니다."),
|
||
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청입니다.", content = @Content),
|
||
|
|
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content)
|
||
|
|
})
|
||
|
|
@GetMapping("/list")
|
||
|
|
public ResponseEntity<?> getDatasetList(
|
||
|
|
@Parameter(description = "프로젝트 인덱스", example = "10")
|
||
|
|
@RequestParam(required = false) Integer ds_prj_idx,
|
||
|
|
@Parameter(description = "검색 키워드", example = "traffic")
|
||
|
|
@RequestParam(required = false) String search_keyword,
|
||
|
|
@Parameter(description = "그룹 이름", example = "AIGroup")
|
||
|
|
@RequestParam(required = false) String grp_name
|
||
|
|
) {
|
||
|
|
Map<String, Object> result = datasetService.getDatasetList(ds_prj_idx, search_keyword, grp_name);
|
||
|
|
return ResponseEntity.ok(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/download")
|
||
|
|
@Operation(
|
||
|
|
summary = "데이터셋 다운로드",
|
||
|
|
description = "외부 API 서버로 POST 요청을 보내 ZIP 파일을 다운로드합니다.",
|
||
|
|
parameters = {
|
||
|
|
@Parameter(name = "datasetName", description = "다운로드할 데이터셋 이름", in = ParameterIn.QUERY, required = true)
|
||
|
|
}
|
||
|
|
)
|
||
|
|
public ResponseEntity<?> downloadDataset(
|
||
|
|
@RequestParam("datasetName") String datasetName
|
||
|
|
) {
|
||
|
|
return datasetService.downloadDataset(datasetName);
|
||
|
|
}
|
||
|
|
}
|