feat:树对象完善
This commit is contained in:
parent
fe06915dfa
commit
b178308817
@ -15,6 +15,9 @@ public abstract class TreeDomain<T extends TreeDomain<T>> extends AuditDomain {
|
||||
// 父id,顶级是0
|
||||
private String parentId;
|
||||
|
||||
// 冗余的父ids,方便查询
|
||||
private List<String> parentIds;
|
||||
|
||||
// 深度,遍历标识
|
||||
private Integer depth;
|
||||
|
||||
|
@ -3,6 +3,8 @@ package com.flyfish.framework.domain.base;
|
||||
import com.flyfish.framework.builder.CriteriaBuilder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,9 +21,17 @@ public class TreeQo<T extends Domain> extends NameLikeQo<T> {
|
||||
|
||||
private List<String> parentIds;
|
||||
|
||||
private Boolean recursive;
|
||||
|
||||
@Override
|
||||
public CriteriaBuilder<T> criteriaBuilder() {
|
||||
return super.criteriaBuilder()
|
||||
.with("depth", "parentId").with("parentIds", "parentId", CriteriaBuilder.Builders.IN);
|
||||
CriteriaBuilder<T> builder = super.criteriaBuilder().with("depth");
|
||||
if (BooleanUtils.isTrue(recursive)) {
|
||||
builder.with("parentId", "parentIds", Criteria::is)
|
||||
.with("parentIds", "parentIds", Criteria::is);
|
||||
} else {
|
||||
builder.with("parentId").with("parentIds", "parentId", CriteriaBuilder.Builders.IN);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.flyfish.framework.controller.reactive;
|
||||
|
||||
import com.flyfish.framework.bean.Result;
|
||||
import com.flyfish.framework.domain.base.Qo;
|
||||
import com.flyfish.framework.domain.base.TreeDomain;
|
||||
import com.flyfish.framework.domain.base.TreeQo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -20,7 +20,7 @@ import java.util.stream.Collectors;
|
||||
* @param <T>
|
||||
* @param <Q>
|
||||
*/
|
||||
public abstract class ReactiveTreeController<T extends TreeDomain<T>, Q extends Qo<T>> extends ReactiveBaseController<T, Q> {
|
||||
public abstract class ReactiveTreeController<T extends TreeDomain<T>, Q extends TreeQo<T>> extends ReactiveBaseController<T, Q> {
|
||||
|
||||
/**
|
||||
* 获取权限树
|
||||
@ -29,6 +29,7 @@ public abstract class ReactiveTreeController<T extends TreeDomain<T>, Q extends
|
||||
*/
|
||||
@GetMapping("tree")
|
||||
public Mono<Result<List<T>>> getTree(Q qo) {
|
||||
qo.setRecursive(true);
|
||||
// 第一步,查询全部,并根据条件筛选
|
||||
return reactiveService.getList(qo)
|
||||
.collectList()
|
||||
|
Loading…
Reference in New Issue
Block a user