parent
b1e1f687cd
commit
8f8644faed
@ -0,0 +1,68 @@
|
|||||||
|
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.tags.Tag;
|
||||||
|
import kr.re.etri.autoflow.entity.WorkflowEntity;
|
||||||
|
import kr.re.etri.autoflow.service.WorkflowService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "워크플로우", description = "워크플로우 API")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/workflows")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WorkflowController {
|
||||||
|
|
||||||
|
private final WorkflowService workflowService;
|
||||||
|
|
||||||
|
@Operation(summary = "모든 워크플로우 조회")
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<List<WorkflowEntity>> getAllWorkflows() {
|
||||||
|
return ResponseEntity.ok(workflowService.findAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "워크플로우 단건 조회")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseEntity<WorkflowEntity> getWorkflow(
|
||||||
|
@Parameter(description = "워크플로우 ID", example = "1") @PathVariable("id") Long id) {
|
||||||
|
|
||||||
|
return workflowService.findById(id)
|
||||||
|
.map(ResponseEntity::ok)
|
||||||
|
.orElse(ResponseEntity.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "워크플로우 등록")
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<WorkflowEntity> createWorkflow(@RequestBody WorkflowEntity workflow) {
|
||||||
|
return ResponseEntity.ok(workflowService.save(workflow));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "워크플로우 수정")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ResponseEntity<WorkflowEntity> updateWorkflow(
|
||||||
|
@Parameter(description = "워크플로우 ID", example = "1") @PathVariable("id") Long id,
|
||||||
|
@RequestBody WorkflowEntity workflow) {
|
||||||
|
|
||||||
|
return workflowService.findById(id)
|
||||||
|
.map(existing -> {
|
||||||
|
workflow.setWorkflowId(id);
|
||||||
|
return ResponseEntity.ok(workflowService.save(workflow));
|
||||||
|
})
|
||||||
|
.orElse(ResponseEntity.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "워크플로우 삭제")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseEntity<Void> deleteWorkflow(
|
||||||
|
@Parameter(description = "워크플로우 ID", example = "1") @PathVariable("id") Long id) {
|
||||||
|
|
||||||
|
if (workflowService.deleteById(id)) {
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package kr.re.etri.autoflow.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "tb_workflows")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(description = "워크플로우 엔티티")
|
||||||
|
public class WorkflowEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Schema(description = "워크플로우 ID", example = "null")
|
||||||
|
private Long workflowId;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "워크플로우 이름", example = "데이터 전처리 워크플로우")
|
||||||
|
private String workflowName;
|
||||||
|
|
||||||
|
@Schema(description = "워크플로우 설명", example = "ETL 파이프라인 정의")
|
||||||
|
private String workflowDescription;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "CHAR(1) DEFAULT 'N'")
|
||||||
|
@Schema(description = "업로드 여부", example = "Y")
|
||||||
|
private String uploadYn;
|
||||||
|
|
||||||
|
@Schema(description = "등록자 ID", example = "admin")
|
||||||
|
private String regUserId;
|
||||||
|
|
||||||
|
@Schema(description = "등록 일시", example = "2025-08-05T04:11:24.745")
|
||||||
|
private LocalDateTime regDt;
|
||||||
|
|
||||||
|
@Schema(description = "수정 일시", example = "2025-08-05T04:11:24.745")
|
||||||
|
private LocalDateTime modDt;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package kr.re.etri.autoflow.repository;
|
||||||
|
|
||||||
|
import kr.re.etri.autoflow.entity.WorkflowEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface WorkflowRepository extends JpaRepository<WorkflowEntity, Long> {
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package kr.re.etri.autoflow.service;
|
||||||
|
|
||||||
|
import kr.re.etri.autoflow.entity.WorkflowEntity;
|
||||||
|
import kr.re.etri.autoflow.repository.WorkflowRepository;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WorkflowService {
|
||||||
|
|
||||||
|
private final WorkflowRepository workflowRepository;
|
||||||
|
|
||||||
|
public List<WorkflowEntity> findAll() {
|
||||||
|
return workflowRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<WorkflowEntity> findById(Long id) {
|
||||||
|
return workflowRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkflowEntity save(WorkflowEntity entity) {
|
||||||
|
return workflowRepository.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteById(Long id) {
|
||||||
|
if (workflowRepository.existsById(id)) {
|
||||||
|
workflowRepository.deleteById(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue