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 ...
随机推荐
- sql 建立新表
USE [exam]GO /****** Object: Table [dbo].[tx] Script Date: 12/13/2020 22:19:59 ******/SET ANSI_NULLS ...
- hadoop ——完全分布式环境搭建
hadoop 完全分布式环境搭建 1.虚拟机角色分配: 192.168.44.184 hadoop02 NameNode/DataNode ResourceManager/NodeManager 19 ...
- 深入GraphQL 的使用语法
深入GraphQL 的使用语法 对于GraphQL 的使用语法在上一节中已经大概介绍了基本的使用方式了,这一篇将会对上一篇入门做拓展,努力将所有的使用语法都覆盖到. 1. 终端语法 首先是介绍在前端查 ...
- js实现0ms延时定时器的几种方式
这两天看到一篇介绍<如何实现准时的 setTimeout?>的文章,文章起源于一道面试题:有什么办法让setTimeout准时呀?具体文章内容可查看附录[1],看完之后,引起了我对setT ...
- xampp的Apache服务无法启动 Apache的443端口被占用解决方法
今天在使用本地的XAMPP的时候,发现Apache服务不能正常启动,根据以往的经验,可能是80端口或者443端口被占用导致的,所以对端口占用情况进行排查. 1. 执行xampp/apache/bin中 ...
- SpringBoot: 后台接口文档 - 基于Swagger3
目录 前言:什么是Swagger 起步:(只需简单的3步) 加载依赖 添加注解@EnableOpenApi 启动SpringBoot,访问Swagger后台界面 配置:基于Java的配置 注解:Swa ...
- odoo学习笔记create函数
@api.multi def create_order_sale(self): """""" stage_list = [] for ord ...
- 一台电脑安装两个不同版本的MySQL
背景: 本人电脑上已有mysql-8.0.12-winx64,并且可以使用.但由于工作需要,得使用mysql-5.5.59-winx64,已有mysql-5.5.59-winx64的解压好的安装包 参 ...
- Linux chgrp命令的使用
Linux chgrp(change group)命令用于变更文件或目录的所属群组. 语法 chgrp [-cfhRv][--help][--version][所属群组][文件或目录...] 或 ch ...
- Java基础——ArrayList方法全解(字典版)
引言 在使用集合 ArrayList 的时候,经常使用add.remove等,其他的没用过,甚至没听说过的还有很多.现在在这个教程中,简单的了解一下,不要求全都记下.相当于在你脑袋里建一个索引,就是有 ...