package kr.re.etri.autoflow.service; import kr.re.etri.autoflow.entity.KubeflowRunEntity; import kr.re.etri.autoflow.payload.request.KubeflowRunSearchRequest; import kr.re.etri.autoflow.repository.KubeflowRunRepository; import kr.re.etri.autoflow.specification.KubeflowRunSpecification; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.*; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class KubeflowRunService { private final KubeflowRunRepository runRepository; private final KubeflowRunSpecification runSpecification; @Transactional(readOnly = true) public Page search(KubeflowRunSearchRequest request) { int pageIndex = request.getPage() > 0 ? request.getPage() - 1 : 0; Pageable pageable = PageRequest.of( pageIndex, request.getSize(), Sort.by(Sort.Direction.fromString(request.getSortDirection()), request.getSortField()) ); Specification spec = runSpecification.searchByConditions( request.getExperimentId(), // experimentId는 필수 request.getSearchType(), request.getKeyword() ); return runRepository.findAll(spec, pageable); } }