1
0

增加分页查询

This commit is contained in:
2025-01-24 11:01:38 +08:00
parent 6ef29b05c5
commit e1d50571d1
2 changed files with 43 additions and 13 deletions

View File

@@ -9,6 +9,9 @@ import java.util.UUID;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
/**
@@ -31,14 +34,38 @@ public class SpringFlowableManager extends FlowableManager {
return repository.listNodes(specification);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Sort sort) {
return repository.listNodes(specification, sort);
}
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Pageable pageable) {
return repository.listNodes(specification, pageable);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification) {
return repository.listInstances(specification);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Sort sort) {
return repository.listInstances(specification, sort);
}
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Pageable pageable) {
return repository.listInstances(specification, pageable);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification) {
return repository.listHistories(instanceId, specification);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification, Sort sort) {
return repository.listHistories(instanceId, specification, sort);
}
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification, Pageable pageable) {
return repository.listHistories(instanceId, specification, pageable);
}
@SneakyThrows
@Override
protected <T> T createBean(String classpath) {

View File

@@ -11,6 +11,8 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.transaction.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
@@ -73,8 +75,9 @@ public class SpringFlowableRepository implements FlowableRepository {
return toNodes(flowableNodeRepository.findAll(specification, sort));
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Pageable pageable) {
return toNodes(flowableNodeRepository.findAll(specification, pageable));
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Pageable pageable) {
Page<FlowableNode> page = flowableNodeRepository.findAll(specification, pageable);
return new PageImpl<>(toNodes(page.getContent()), pageable, page.getTotalElements());
}
@Override
@@ -114,8 +117,9 @@ public class SpringFlowableRepository implements FlowableRepository {
return toInstances(flowableInstanceRepository.findAll(specification, sort));
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Pageable pageable) {
return toInstances(flowableInstanceRepository.findAll(specification, pageable));
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Pageable pageable) {
Page<FlowableInstance> page = flowableInstanceRepository.findAll(specification, pageable);
return new PageImpl<>(toInstances(page.getContent()), pageable, page.getTotalElements());
}
@Override
@@ -170,16 +174,15 @@ public class SpringFlowableRepository implements FlowableRepository {
);
}
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification, Pageable pageable) {
return toHistories(
flowableHistoryRepository.findAll(
(root, query, builder) -> builder.and(
builder.equal(root.get("instanceId"), instanceId),
specification.toPredicate(root, query, builder)
),
pageable
)
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification, Pageable pageable) {
Page<FlowableHistory> page = flowableHistoryRepository.findAll(
(root, query, builder) -> builder.and(
builder.equal(root.get("instanceId"), instanceId),
specification.toPredicate(root, query, builder)
),
pageable
);
return new PageImpl<>(toHistories(page.getContent()), pageable, page.getTotalElements());
}
@Transactional(rollbackOn = Exception.class)