From baca2e29a7545adeaed7cae0a16dc1b413fb5237 Mon Sep 17 00:00:00 2001 From: bjkim Date: Mon, 22 Sep 2025 10:54:18 +0900 Subject: [PATCH] =?UTF-8?q?TODO:=EC=97=85=EB=A1=9C=EB=93=9C=EC=8B=9C=20pro?= =?UTF-8?q?jectid=ED=99=95=EC=9D=B8=20[ADD]=20AuditingEntityListener=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20WorkflowEntity=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91=20=ED=9B=84=20=EC=A0=80=EC=9E=A5=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84=20(PipelineUploadController)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/PipelineUploadController.java | 59 +++++++++++-------- .../etri/autoflow/entity/DataGroupEntity.java | 2 + .../etri/autoflow/entity/ProjectEntity.java | 2 + .../etri/autoflow/entity/WorkflowEntity.java | 43 +++++++++----- 4 files changed, 64 insertions(+), 42 deletions(-) diff --git a/src/main/java/kr/re/etri/autoflow/controllers/PipelineUploadController.java b/src/main/java/kr/re/etri/autoflow/controllers/PipelineUploadController.java index 556a982..5814cc0 100644 --- a/src/main/java/kr/re/etri/autoflow/controllers/PipelineUploadController.java +++ b/src/main/java/kr/re/etri/autoflow/controllers/PipelineUploadController.java @@ -1,7 +1,9 @@ package kr.re.etri.autoflow.controllers; import io.swagger.v3.oas.annotations.tags.Tag; +import kr.re.etri.autoflow.entity.WorkflowEntity; import kr.re.etri.autoflow.service.PipelineUploadService; +import kr.re.etri.autoflow.service.WorkFlowService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.multipart.MultipartFile; +import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; @@ -23,6 +26,7 @@ import java.util.Map; public class PipelineUploadController { private final PipelineUploadService pipelineUploadService; + private final WorkFlowService workFlowService; @io.swagger.v3.oas.annotations.Operation( summary = "파이프라인 업로드", @@ -42,44 +46,47 @@ public class PipelineUploadController { description = "서버 내부 오류" ) }) + @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity> uploadPipeline( - @io.swagger.v3.oas.annotations.Parameter(description = "업로드할 파이프라인 파일", required = true) @RequestParam("uploadfile") MultipartFile file, - - @io.swagger.v3.oas.annotations.Parameter(description = "파이프라인 이름", required = true) - @RequestParam(value = "name", required = false) String name, - - @io.swagger.v3.oas.annotations.Parameter(description = "표시 이름", required = true) - @RequestParam(value = "display_name", required = false) String displayName, - - @io.swagger.v3.oas.annotations.Parameter(description = "파이프라인 설명", required = false) + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "display_name", required = true) String displayName, @RequestParam(value = "description", required = false) String description, - - @io.swagger.v3.oas.annotations.Parameter(description = "Kubeflow 네임스페이스", required = false) - @RequestParam(value = "namespace", required = false) String namespace + @RequestParam(value = "namespace", required = false) String namespace, + @RequestParam(value = "regUserId") String regUserId, + @RequestParam(value = "projectId") Long projectId ) { try { + // Kubeflow 업로드 Map result = pipelineUploadService.uploadPipeline(file, name, displayName, description, namespace); - return ResponseEntity.ok(result); - } catch (HttpClientErrorException e) { - log.error("Kubeflow API Error: status={}, response={}", e.getStatusCode(), e.getResponseBodyAsString(), e); + // WorkflowEntity 매핑 후 DB 저장 + WorkflowEntity workflow = WorkflowEntity.builder() + .pipelineId((String) result.get("pipeline_id")) + .displayName((String) result.get("display_name")) + .name((String) result.get("name")) + .description((String) result.get("description")) + .namespace((String) result.get("namespace")) + .regUserId(regUserId) + .projectId(projectId) + .kubeflowStatus("Created") + .version(1) + .build(); + + // 저장 + workFlowService.save(workflow); - Map error = new HashMap<>(); - error.put("status", e.getStatusCode().value()); - error.put("error", e.getStatusText()); - error.put("message", e.getResponseBodyAsString()); - return ResponseEntity.status(e.getStatusCode()).body(error); + return ResponseEntity.ok(result); } catch (Exception e) { log.error("Pipeline upload failed", e); - - Map error = new HashMap<>(); - error.put("status", 500); - error.put("error", "Internal Server Error"); - error.put("message", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); + Map error = Map.of( + "status", 500, + "error", "Internal Server Error", + "message", e.getMessage() + ); + return ResponseEntity.status(500).body(error); } } } diff --git a/src/main/java/kr/re/etri/autoflow/entity/DataGroupEntity.java b/src/main/java/kr/re/etri/autoflow/entity/DataGroupEntity.java index 31160c6..88c8a32 100644 --- a/src/main/java/kr/re/etri/autoflow/entity/DataGroupEntity.java +++ b/src/main/java/kr/re/etri/autoflow/entity/DataGroupEntity.java @@ -6,6 +6,7 @@ import lombok.*; import org.hibernate.annotations.Comment; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import java.time.LocalDateTime; import java.util.ArrayList; @@ -14,6 +15,7 @@ import java.util.List; @Schema(description = "데이터그룹") @Comment("데이터그룹") @Entity +@EntityListeners(AuditingEntityListener.class) @Table(name = "tb_datagroup") @Getter @Setter diff --git a/src/main/java/kr/re/etri/autoflow/entity/ProjectEntity.java b/src/main/java/kr/re/etri/autoflow/entity/ProjectEntity.java index 7ef4ec5..686190d 100644 --- a/src/main/java/kr/re/etri/autoflow/entity/ProjectEntity.java +++ b/src/main/java/kr/re/etri/autoflow/entity/ProjectEntity.java @@ -6,6 +6,7 @@ import lombok.*; import org.hibernate.annotations.Comment; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import java.time.LocalDate; import java.time.LocalDateTime; @@ -15,6 +16,7 @@ import java.util.List; @Schema(description = "프로젝트") @Comment("프로젝트") @Entity +@EntityListeners(AuditingEntityListener.class) @Table(name = "tb_project") @Getter @Setter diff --git a/src/main/java/kr/re/etri/autoflow/entity/WorkflowEntity.java b/src/main/java/kr/re/etri/autoflow/entity/WorkflowEntity.java index 8585bdd..8f7f084 100644 --- a/src/main/java/kr/re/etri/autoflow/entity/WorkflowEntity.java +++ b/src/main/java/kr/re/etri/autoflow/entity/WorkflowEntity.java @@ -5,8 +5,13 @@ import lombok.*; import java.time.LocalDateTime; import io.swagger.v3.oas.annotations.media.Schema; import org.hibernate.annotations.Comment; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Entity +@EntityListeners(AuditingEntityListener.class) + @Table(name = "tb_workflows") @Getter @Setter @@ -22,35 +27,41 @@ public class WorkflowEntity { @Comment("ID") private Long id; - @Schema(description = "워크플로우 이름", example = "데이터 전처리 워크플로우") - private String workflowName; + // Kubeflow pipeline_id 대응 + @Schema(description = "워크플로우 아이디", example = "b935cc31-0db5-405e-8ae9-f4dbdc418c59") + private String pipelineId; + + // Kubeflow display_name 대응 + @Schema(description = "워크플로우 표시 이름", example = "etri001") + private String displayName; + + // Kubeflow name 대응 + @Schema(description = "워크플로우 이름", example = "etri001") + private String name; + // Kubeflow description 대응 @Schema(description = "워크플로우 설명", example = "ETL 파이프라인 정의") - private String workflowDescription; + private String description; + + // Kubeflow created_at 대응 + @CreatedDate + @Schema(description = "워크플로우 등록 일시", example = "2025-08-05T04:11:24.745") + private LocalDateTime regDt; - @Column(columnDefinition = "CHAR(1) DEFAULT 'N'") - @Schema(description = "업로드 여부", example = "Y") - private String uploadYn; + // Kubeflow namespace 대응 + @Schema(description = "워크플로우 네임스페이스", example = "default") + private String namespace; @Schema(description = "등록자 ID", example = "admin") private String regUserId; - @Schema(description = "등록 일시", example = "2025-08-05T04:11:24.745") - private LocalDateTime regDt; - + @LastModifiedDate @Schema(description = "수정 일시", example = "2025-08-05T04:11:24.745") private LocalDateTime modDt; @Schema(description = "워크플로우 버전", example = "1.0") private Integer version; - @Schema(description = "스텝 개수", example = "5") - private Integer stepCount; - - // configProgress/토탈n개로 표현 - @Schema(description = "현재 구성 진행 개수", example = "1") - private Integer configProgress; - @Schema(description = "Kubeflow 상태", example = "Running") private String kubeflowStatus;