|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package kr.re.etri.autoflow.service;
|
|
|
|
|
|
|
|
|
|
import jakarta.transaction.Transactional;
|
|
|
|
|
import kr.re.etri.autoflow.entity.WorkflowEntity;
|
|
|
|
|
import kr.re.etri.autoflow.payload.request.BaseSearchRequest;
|
|
|
|
|
import kr.re.etri.autoflow.payload.request.WorkFlowRequest;
|
|
|
|
|
@ -32,10 +33,20 @@ public class WorkFlowService {
|
|
|
|
|
return workflowRepository.findById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WorkflowEntity save(WorkflowEntity entity) {
|
|
|
|
|
return workflowRepository.save(entity);
|
|
|
|
|
@Transactional
|
|
|
|
|
public WorkflowEntity save(WorkflowEntity workflow) {
|
|
|
|
|
if (workflow.getId() == null) {
|
|
|
|
|
// 신규 생성
|
|
|
|
|
workflow.setVersion(1);
|
|
|
|
|
} else {
|
|
|
|
|
// 업데이트 시 기존 max 버전 + 1
|
|
|
|
|
Integer maxVersion = workflowRepository.findVersionById(workflow.getId());
|
|
|
|
|
workflow.setVersion(maxVersion != null ? maxVersion + 1 : 1);
|
|
|
|
|
}
|
|
|
|
|
return workflowRepository.save(workflow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public boolean deleteById(Long id) {
|
|
|
|
|
if (workflowRepository.existsById(id)) {
|
|
|
|
|
workflowRepository.deleteById(id);
|
|
|
|
|
@ -44,6 +55,7 @@ public class WorkFlowService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public Page<WorkflowEntity> search(WorkFlowRequest request) {
|
|
|
|
|
int pageIndex = request.getPage() > 0 ? request.getPage() - 1 : 0;
|
|
|
|
|
|
|
|
|
|
@ -67,5 +79,4 @@ public class WorkFlowService {
|
|
|
|
|
|
|
|
|
|
return workflowRepository.findAll(spec, pageable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|