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 ...
随机推荐
- Android控件总结
最常用的控件:TextView.EditText.Button.ImageView TextView 文本 ...
- sort,wc,uniq 排序与统计命令
sort命令 语法:sort [parameter] [file or stdin]参数: -f:忽略大小写的差异,例如A和a视为编码相同 -b:忽略最前面的空格符部分 -n:使用"纯数字& ...
- 「CF559E」 Gerald and Path
「CF559E」 Gerald and Path 为啥我现在做啥题都在想网络流啊 考虑 \(\texttt{DP}\). 容易想到状态应该包含当前枚举了前 \(i\) 条线段,且第 \(i\) 条线段 ...
- 前端-Vue基础3(父子组件交互)
1.子组件往父组件传值 点击子组件的值,子组件自增,父组件的值也跟着自增 通过:this.$emit('change')方法向父组件暴露事件,在子组件中引用,可以调用父组件的方法 点击子组件触发cli ...
- 以太网MAC地址组成与交换机基本知识
以太网MAC地址 MAC地址由48位二进制组成,通常分为六段,用十六进制表示,工作在数据链路层. 数据链路层功能: 链路的建立,维护与拆除 帧包装,帧传输,帧同步 帧的差错恢复 简单的流量控制 第八位 ...
- Java基础00-抽象类20
1. 抽象类 1.1 抽象类概述 代码示例:没有{}大括号的方法就是一个没有方法体的方法,要把它定义成抽象方法,就要给它加一个abstract关键字,而类中有抽象方法,该类也必须是一个抽象类,所以给类 ...
- 基于SSM小区物业管理系统
随着计算机的不断发展和广泛应用,人们的工作效率得到不断的提高.互联网的发展,更是缩短了人们之间的距离.如何充分利用互联网,这是大家共同关心的问题.本文主要介绍了关于小区管理系统的实现方法,设计规划了小 ...
- linux下系统时间和时钟时间
linux中有关系统时间.时钟时间的命令: 1显示系统时间的命令 ># date 2显示时钟时间的命令 ># clock或hwclock 3系统时间与互联网同步的命令 ># ntpd ...
- HCNA Routing&Switching之动态路由协议OSPF DR和BDR
前文我们了解了OSPF建立邻居关系的条件,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15032907.html:今天我们来聊一聊OSPF中的DR和BDR: ...
- shell脚本(6)-shell数组
一.数组介绍 一个变量只能存一个值,现实中很多值需要存储,可以定义数组来存储一类的值. 二.基本数组 1.概念: 数组可以让用户一次性赋予多个值,需要读取数据时只需通过索引调用就可以方便读出. 2. ...