//是否包含下级授权点 1 包含 2 不包含
List<AuthorizationPoint> authList = null;
List<Long> pointIdList = Lists.newArrayList();
if (isContain != null) {
if (1 == isContain) {
if(authStr != null && !"".equals(authStr.trim())){
authList = this.authorizationPointService.getAuthPointChildrenListByAuthName(authStr);
}
}
}
if(!CollectionUtils.isEmpty(authList)){
for (AuthorizationPoint point : authList) {
pointIdList.add(point.getId());
}
}
List<AuthorizationPoint> finalAuthList = authList;
Specification<BaseUser> specification = new Specification<BaseUser>() {
@Override
public Predicate toPredicate(Root<BaseUser> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> predicateList = Lists.newArrayList();
//isDelete
Predicate isDeletePredicate = criteriaBuilder.equal(root.get("isDelete"), Constant.NOT_DELETE);
predicateList.add(isDeletePredicate);
//非管理员
Predicate rolePredicate = criteriaBuilder.isNull(root.join("role", JoinType.LEFT).get("id"));
predicateList.add(rolePredicate);
// 非禁用用户
Predicate accountPredicate = criteriaBuilder.equal(root.get("account").get("status"), status == null ? "A" : status);
predicateList.add(accountPredicate);
//authCategoryId
if (authCategoryId != null) {
Predicate predicate = criteriaBuilder.equal(root.join("authorizationPoint", JoinType.LEFT).join("authCategory", JoinType.LEFT).get("id"), authCategoryId);
predicateList.add(predicate);
}
//authId
if (authId != null) {
Predicate predicate = criteriaBuilder.equal(root.join("authorizationPoint", JoinType.LEFT).get("id"), authId);
predicateList.add(predicate);
}
//searchText
if (searchText != null && !searchText.trim().isEmpty()) {
Predicate predicate = criteriaBuilder.like(root.get("name"), "%" + searchText.trim() + "%");
predicateList.add(predicate);
}
//创建用户的开始时间和结束时间
/*if (startDate != null) {
Predicate predicate = criteriaBuilder.greaterThanOrEqualTo(root.get("createTime"), startDate);
predicateList.add(predicate);
}
if (endDate != null) {
Predicate predicate = criteriaBuilder.lessThanOrEqualTo(root.get("createTime"), endDate);
predicateList.add(predicate);
}*/
// 授权点名称
if (authStr != null && !authStr.isEmpty()) {
Predicate predicate = criteriaBuilder.like(root.join("authorizationPoint", JoinType.LEFT).get("name"), "%" + authStr + "%");
predicateList.add(predicate);
//授权点点击子级授权点集合
if(!CollectionUtils.isEmpty(pointIdList)){
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.join("authorizationPoint", JoinType.LEFT).get("id"));
Iterator<Long> iterator = pointIdList.iterator();
while (iterator.hasNext()){
in.value(iterator.next());
}
predicateList.add(in);
}
}
Order createTimeOrder = criteriaBuilder.desc(root.get("createTime"));
return criteriaQuery.orderBy(createTimeOrder).where(predicateList.toArray(new Predicate[predicateList.size()])).getRestriction();
}
};