chunk업로드 공통, 모델관리 수정
This commit is contained in:
@@ -4,6 +4,7 @@ import com.kamco.cd.kamcoback.common.utils.zip.ZipUtils;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.service.ModelMngService;
|
||||
import com.kamco.cd.kamcoback.upload.dto.UploadDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -11,16 +12,20 @@ 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 jakarta.transaction.Transactional;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
@@ -36,6 +41,27 @@ public class ModelMngApiController {
|
||||
|
||||
private final ModelMngService modelMngService;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
@Value("${file.dataset-tmp-dir}")
|
||||
private String datasetTmpDir;
|
||||
|
||||
@Value("${file.model-dir}")
|
||||
private String modelDir;
|
||||
|
||||
@Value("${file.model-tmp-dir}")
|
||||
private String modelTmpDir;
|
||||
|
||||
@Autowired private ZipUtils zipUtils;
|
||||
|
||||
@Operation(summary = "모델관리 목록")
|
||||
@@ -70,19 +96,59 @@ public class ModelMngApiController {
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@DeleteMapping("/{modelVer}")
|
||||
@DeleteMapping("/{uuid}")
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> removeModel(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "모델 삭제 요청 정보",
|
||||
required = true)
|
||||
@PathVariable
|
||||
String modelVer) {
|
||||
return ApiResponseDto.okObject(modelMngService.removeModel(modelVer));
|
||||
String uuid) {
|
||||
return ApiResponseDto.okObject(modelMngService.removeModel(UUID.fromString(uuid)));
|
||||
}
|
||||
|
||||
@Operation(summary = "모델 zip 파일 업로드", description = "모델 zip 파일 업로드")
|
||||
@PostMapping(value = "/upload/zip", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public void upload(@RequestPart MultipartFile zipFilie) throws IOException {
|
||||
zipUtils.processZip(zipFilie.getInputStream());
|
||||
|
||||
@Operation(summary = "모델등록")
|
||||
@PostMapping
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> ModelMgmt(
|
||||
@RequestBody @Valid ModelMngDto.AddReq addReq) {
|
||||
|
||||
return ApiResponseDto.ok(modelMngService.insertModel(addReq));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "데이터셋 대용량 파일 분할 전송", description = "데이터셋 파일 대용량 파일을 청크 단위로 전송합니다.")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(responseCode = "200", description = "청크 업로드 성공", content = @Content),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
||||
@ApiResponse(responseCode = "404", description = "업로드 세션을 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping(value = "/file-chunk-upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ApiResponseDto<UploadDto.UploadRes> fileChunkUpload(
|
||||
@RequestParam("uuid") UUID uuid,
|
||||
@RequestParam("fileName") String fileName,
|
||||
@RequestParam("fileSize") long fileSize,
|
||||
// @RequestParam("fileHash") String fileHash,
|
||||
@RequestParam("chunkIndex") Integer chunkIndex,
|
||||
@RequestParam("chunkTotalIndex") Integer chunkTotalIndex,
|
||||
@RequestPart("chunkFile") MultipartFile chunkFile) {
|
||||
|
||||
String uploadDivi = "model";
|
||||
|
||||
UploadDto.UploadAddReq upAddReqDto = new UploadDto.UploadAddReq();
|
||||
upAddReqDto.setDatasetId(0L);
|
||||
upAddReqDto.setUuid(uuid);
|
||||
upAddReqDto.setFileName(fileName);
|
||||
upAddReqDto.setFileSize(fileSize);
|
||||
upAddReqDto.setChunkIndex(chunkIndex);
|
||||
upAddReqDto.setChunkTotalIndex(chunkTotalIndex);
|
||||
upAddReqDto.setUploadDivi(uploadDivi);
|
||||
upAddReqDto.setFinalPath(modelDir);
|
||||
upAddReqDto.setTempPath(modelTmpDir);
|
||||
|
||||
System.out.println("uuid === "+ uuid);
|
||||
|
||||
return ApiResponseDto.ok(modelMngService.uploadChunkModelFile(upAddReqDto, chunkFile));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user