feat:优化

This commit is contained in:
wangyu 2022-03-10 21:01:00 +08:00
parent b20bce9ba3
commit 5f6d967bf4
2 changed files with 10 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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"));
}