mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
refactor: change the convert method's name
This commit is contained in:
parent
0912964ec3
commit
895e69f043
@ -1,11 +1,16 @@
|
|||||||
package com.github.kfcfans.powerjob.common;
|
package com.github.kfcfans.powerjob.common;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PowerJob Query interface
|
* PowerJob Query interface
|
||||||
*
|
*
|
||||||
* @author tjq
|
* @author tjq
|
||||||
* @since 2021/1/15
|
* @since 2021/1/15
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public abstract class PowerQuery {
|
public abstract class PowerQuery {
|
||||||
|
|
||||||
public static String EQUAL = "Eq";
|
public static String EQUAL = "Eq";
|
||||||
@ -33,12 +38,4 @@ public abstract class PowerQuery {
|
|||||||
public static String IS_NOT_NULL = "IsNotNull";
|
public static String IS_NOT_NULL = "IsNotNull";
|
||||||
|
|
||||||
private Long appIdEq;
|
private Long appIdEq;
|
||||||
|
|
||||||
public Long getAppIdEq() {
|
|
||||||
return appIdEq;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppIdEq(Long appIdEq) {
|
|
||||||
this.appIdEq = appIdEq;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
@SuppressWarnings("unchecked, rawtypes")
|
@SuppressWarnings("unchecked, rawtypes")
|
||||||
public class QueryConvertUtils {
|
public class QueryConvertUtils {
|
||||||
|
|
||||||
public static <T> Specification<T> autoConvert(PowerQuery powerQuery) {
|
public static <T> Specification<T> toSpecification(PowerQuery powerQuery) {
|
||||||
|
|
||||||
return (Specification<T>) (root, query, cb) -> {
|
return (Specification<T>) (root, query, cb) -> {
|
||||||
List<Predicate> predicates = Lists.newLinkedList();
|
List<Predicate> predicates = Lists.newLinkedList();
|
||||||
|
@ -101,7 +101,7 @@ public class JobService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<JobInfoDTO> queryJob(PowerQuery powerQuery) {
|
public List<JobInfoDTO> queryJob(PowerQuery powerQuery) {
|
||||||
Specification<JobInfoDO> specification = QueryConvertUtils.autoConvert(powerQuery);
|
Specification<JobInfoDO> specification = QueryConvertUtils.toSpecification(powerQuery);
|
||||||
return jobInfoRepository.findAll(specification).stream().map(JobService::convert).collect(Collectors.toList());
|
return jobInfoRepository.findAll(specification).stream().map(JobService::convert).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public class InstanceService {
|
|||||||
|
|
||||||
public List<InstanceInfoDTO> queryInstanceInfo(PowerQuery powerQuery) {
|
public List<InstanceInfoDTO> queryInstanceInfo(PowerQuery powerQuery) {
|
||||||
return instanceInfoRepository
|
return instanceInfoRepository
|
||||||
.findAll(QueryConvertUtils.autoConvert(powerQuery))
|
.findAll(QueryConvertUtils.toSpecification(powerQuery))
|
||||||
.stream()
|
.stream()
|
||||||
.map(InstanceService::directConvert)
|
.map(InstanceService::directConvert)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user