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 ...
随机推荐
- 你真的了解 Session 和 Cookie 吗?
我是陈皮,一个在互联网 Coding 的 ITer,微信搜索「陈皮的JavaLib」第一时间阅读最新文章,回复[资料],即可获得我精心整理的技术资料,电子书籍,一线大厂面试资料和优秀简历模板. 前言 ...
- Django基础012--接口开发
全局参数(get,post,put,delete) 接口:/api/parameter GET:获取全局参数的所有数据 POST:创建全局参数 PUT:更新全局参数 DELETE:删除全局参数 1.创 ...
- python 常用命令sys.exit()
Python的程序有两中退出方式:os._exit(), sys.exit() os._exit()会直接将python程序终止,之后的所有代码都不会继续执行. sys.exit()会引发一个异常:S ...
- C语言:自增 自减
一个整数类型的变量自身加 1 可以这样写: a = a + 1; 或者 a += 1; 不过,C语言还支持另外一种更加简洁的写法,就是: a++; 或者 ++a; 这种写法叫做自加或自增,意思很明确, ...
- C语言:特殊点
编译器给变量分配内存在函数外部定义的变量叫做全局变量(Global Variable),在函数内部定义的变量叫做局部变量(Local Variable)一个变量,即使不给它赋值,它也会有一个默认的值, ...
- C语言:宏定义 本质及体现
- PO封装设计模式 -- App移动端测试
前言: 一.App_Po 封装 (用互联网上随便一个app进行) base 存放的是页面基础类,后续的类需继承基础类 common 存放的是公共部分,测试固件分离部分,新增截图功能部分 Data 存放 ...
- Linux CentOS 7 安装配置vsftp
学习Linux时间不长,首次安装了vsftp,按照网上的各种帖子尝试配置,不过都没打到预期,不是被拒绝连接,就是连接超时,总之就是各种问题啊.当然了,不是别人配置的不对,而是自己不是太懂Linux,选 ...
- js 正序、倒序、按字段排序方法
js 基础--sort方法: arrayObject.sort(sortby); 参数:定义排序规则(正序.倒序.按字段排序)的函数: 返回值:对数组的引用.请注意,数组在原数组上进行排序,不生成副本 ...
- HTML之单词
段落 paragraph <a href="https://www.runoob.com">超链接 anchor (锚点,引申为连接,link已经被html占用) Hy ...