feat:优化
This commit is contained in:
parent
b20bce9ba3
commit
5f6d967bf4
@ -49,8 +49,10 @@ public abstract class AbstractAuthorizedQo<T extends AuthorizedDomain> extends N
|
||||
Criteria.where("published").is(false)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// 未指定发布状态,查询已发布内容
|
||||
return Criteria.where("published").is(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
|
||||
@ -90,10 +93,11 @@ public class DepartmentService extends BaseReactiveServiceImpl<Department> {
|
||||
Mono<Qo<Department>> mono = Mono.just(qo);
|
||||
// 使用列表内的部门作为条件
|
||||
AdminUserDetails userDetails = (AdminUserDetails) query.getUser();
|
||||
// 是否设置过
|
||||
qo.setIds(userDetails.getVisibleDeparts());
|
||||
// 查询根节点下的节点
|
||||
if (Department.ROOT.equals(qo.getParentId())) {
|
||||
qo.setParentId(null);
|
||||
qo.setIds(userDetails.getVisibleDeparts());
|
||||
// 不递归,指定深度,保证单层
|
||||
if (BooleanUtils.isNotTrue(qo.getRecursive())) {
|
||||
// 指定深度,从可见的列表中获取
|
||||
@ -104,17 +108,13 @@ public class DepartmentService extends BaseReactiveServiceImpl<Department> {
|
||||
});
|
||||
}
|
||||
}
|
||||
// 父id均为空,返回所有可见部门即可
|
||||
if (null == qo.getParentId() && CollectionUtils.isEmpty(qo.getParentIds())) {
|
||||
qo.setIds(userDetails.getVisibleDeparts());
|
||||
}
|
||||
// 如果存在额外的id,追加记录
|
||||
if (StringUtils.isNotBlank(qo.getAdditional())) {
|
||||
Collection<String> ids = defaultIfNull(qo.getIds(), new HashSet<>());
|
||||
ids.add(qo.getAdditional());
|
||||
qo.setIds(ids);
|
||||
}
|
||||
// qo中ids为空,返回无效查询
|
||||
// 如果设置过ids,但是qo中ids为空,返回无效查询
|
||||
if (CollectionUtils.isEmpty(qo.getIds())) {
|
||||
qo.setIds(Collections.singleton("null"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user