Specification使用in
//是否包含下级授权点 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();
}
};
Specification使用in的更多相关文章
- 使用CocoaPods过程中 Unable to find a specification for
文章转自:http://blog.csdn.net/zhangao0086/article/details/39703083 当把CocoaPods生成的workspace移动到上层目录时,需要改下P ...
- 规约模式Specification的学习
最近一直在看DDD开发 规约似乎用得很普遍. 但是还是理解不了.所以记录下学习的进度.- 规约(Specification)模式 目的:查询语句和查询条件的分离 写了一个关于规约的模拟小程序 cla ...
- [.NET领域驱动设计实战系列]专题三:前期准备之规约模式(Specification Pattern)
一.前言 在专题二中已经应用DDD和SOA的思想简单构建了一个网上书店的网站,接下来的专题中将会对该网站补充更多的DDD的内容.本专题作为一个准备专题,因为在后面一个专题中将会网上书店中的仓储实现引入 ...
- EF架构~引入规约(Specification)模式,让程序扩展性更强
回到目录 规约(Specification)模式:第一次看到这东西是在microsoft NLayer项目中,它是微软对DDD的解说,就像petshop告诉了我们MVC如何使用一样,这个规约模式最重要 ...
- Tomcat7.0启动报错:java.lang.illegalargumentexception:taglib definition not consisten with specification version
Tomcat7.0启动报错:java.lang.illegalargumentexception:taglib definition not consisten with specification ...
- The JSP specification requires that an attribute name is preceded by whitespace
一个jsp页面在本地运行一点问题没有,发布到服务器就报错了: The JSP specification requires that an attribute name is preceded by ...
- 如何阅读《ECMAScript 2015 Language Specification》
你不需要把<ECMAScript 2015 Language Specification>通读一遍,因为没那个必要. 阮一峰建议: 对于一般用户来说,除了第4章,其他章节都涉及某一方面 ...
- ORA-00119: invalid specification for system parameter LOCAL_LISTENER - 转
错误分析 listener 可以正常启动: [oracle@o_target admin]$ cat listener.ora# listener.ora Network Configuration ...
- The server does not support version 3.0 of the J2EE Web module specification
1.错误: 在eclipse中使用run->run on server的时候,选择tomcat6会报错误:The server does not support version 3.0 of t ...
- The P4 Language Specification v1.0.2 Header and Fields
前言 本文参考P4.org网站给出的<The P4 Language Specification v1.0.2>的第二部分首部及字段,仅供学习:). 欢迎交流! Header and Fi ...
随机推荐
- libzip开发笔记(二):libzip库介绍、ubuntu平台编译和工程模板
前言 Qt使用一些压缩解压功能,选择libzip库,libzip库比较原始,也是很多其他库的基础支撑库,编译过了windows版本,有需求编译一个ubuntu版本的,交叉编译需求的同样可参照本文章 ...
- Emoji.voto,Linkerd 服务网格(service mesh)的示例应用程序
一个微服务应用程序,允许用户为他们最喜欢的表情符号(emoji)投票,并跟踪排行榜上收到的投票.愿最好的 emoji 获胜. 该应用程序由以下 3 个服务组成: emojivoto-web:Web 前 ...
- CRC校验原理
此文为转载文,原作者博客传送门 CRC校验原理 CRC校验原理看起来比较复杂,好难懂,因为大多数书上基本上是以二进制的多项式形式来说明的.其实很简单的问题,其根本思想就是先在要发送的帧后面附加一个数( ...
- Leetcode:169. 多数元素
Leetcode:169. 多数元素 传送门 思路 一开始想到的一个很简单的做法就是hash法,直接利用打表记录次数再输出结果. 而利用BM算法可以令算法复杂度同样也在\(O(n)\)的情况下,将空间 ...
- session及cookie详解(七)
前言 文章说明 在每整理一个技术点的时候,都要清楚,为什么去记录它.是为了工作上项目的需要?还是为了搭建技术基石,为学习更高深的技术做铺垫? 让每一篇文章都不是泛泛而谈,复制粘贴,都有它对自己技术提升 ...
- pytest框架运用
import pytest ''' 运行方式 1. pytest -s test01.py 把print信息打印出来运行用例 2. 通过main运行 前置后置方法 1. 函数级 setup teard ...
- [考试总结]noip模拟7
为啥博客园 \(\LaTeX\) 老挂???! \(\huge{\text{菜}}\) 刚开始写 \(T1\) 的时候,在看到后缀前缀之后,直接想到 \(AC\) 自动机,在画了半个 \(trie\) ...
- .NET 6 预览版 5 发布
很高兴.NET 6 预览版5终于跟大家见面了.我们现在正处于.NET 6 的后半部分,开始整合一些重要的功能. 例如.NET SDK 工作负载,它是我们.NET 统一愿景的基础,可以支持更多类型的应用 ...
- 简明易懂,将细节隐藏,面向新手树立web开发概念——学完Java基础语法,超快速上手springboot+mybatiJavaWeb开发
简明易懂,将细节隐藏,面向新手树立web开发概念 --学完Java基础语法,超快速上手JavaWeb开发 Web本质(先忽视各种协议) Web应用可以理解为浏览器和服务器之间的交互. 我们可以看一个简 ...
- JUC学习笔记(五)
JUC学习笔记(一)https://www.cnblogs.com/lm66/p/15118407.html JUC学习笔记(二)https://www.cnblogs.com/lm66/p/1511 ...