增加分页查询
This commit is contained in:
@@ -9,6 +9,9 @@ import java.util.UUID;
|
|||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ApplicationContext;
|
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;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,14 +34,38 @@ public class SpringFlowableManager extends FlowableManager {
|
|||||||
return repository.listNodes(specification);
|
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) {
|
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification) {
|
||||||
return repository.listInstances(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) {
|
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification) {
|
||||||
return repository.listHistories(instanceId, 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
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
protected <T> T createBean(String classpath) {
|
protected <T> T createBean(String classpath) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
import javax.transaction.Transactional;
|
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.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
@@ -73,8 +75,9 @@ public class SpringFlowableRepository implements FlowableRepository {
|
|||||||
return toNodes(flowableNodeRepository.findAll(specification, sort));
|
return toNodes(flowableNodeRepository.findAll(specification, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Pageable pageable) {
|
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableNode> listNodes(Specification<FlowableNode> specification, Pageable pageable) {
|
||||||
return toNodes(flowableNodeRepository.findAll(specification, pageable));
|
Page<FlowableNode> page = flowableNodeRepository.findAll(specification, pageable);
|
||||||
|
return new PageImpl<>(toNodes(page.getContent()), pageable, page.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,8 +117,9 @@ public class SpringFlowableRepository implements FlowableRepository {
|
|||||||
return toInstances(flowableInstanceRepository.findAll(specification, sort));
|
return toInstances(flowableInstanceRepository.findAll(specification, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Pageable pageable) {
|
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableInstance> listInstances(Specification<FlowableInstance> specification, Pageable pageable) {
|
||||||
return toInstances(flowableInstanceRepository.findAll(specification, pageable));
|
Page<FlowableInstance> page = flowableInstanceRepository.findAll(specification, pageable);
|
||||||
|
return new PageImpl<>(toInstances(page.getContent()), pageable, page.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
public Page<com.lanyuanxiaoyao.flowable.core.model.FlowableHistory> listHistories(String instanceId, Specification<FlowableHistory> specification, Pageable pageable) {
|
||||||
return toHistories(
|
Page<FlowableHistory> page = flowableHistoryRepository.findAll(
|
||||||
flowableHistoryRepository.findAll(
|
|
||||||
(root, query, builder) -> builder.and(
|
(root, query, builder) -> builder.and(
|
||||||
builder.equal(root.get("instanceId"), instanceId),
|
builder.equal(root.get("instanceId"), instanceId),
|
||||||
specification.toPredicate(root, query, builder)
|
specification.toPredicate(root, query, builder)
|
||||||
),
|
),
|
||||||
pageable
|
pageable
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
return new PageImpl<>(toHistories(page.getContent()), pageable, page.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackOn = Exception.class)
|
@Transactional(rollbackOn = Exception.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user