com.querydsl.core.types.OrderSpecifier Java Examples
The following examples show how to use
com.querydsl.core.types.OrderSpecifier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrderService.java From ZTuoExchange_framework with MIT License | 7 votes |
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){ List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); JPAQuery<OtcOrderVO> query = queryFactory.select( Projections.fields(OtcOrderVO.class, QOrder.order.id.as("id"), QOrder.order.orderSn.as("orderSn"), QOrder.order.advertiseType.as("advertiseType"), QOrder.order.createTime.as("createTime"), QOrder.order.memberName.as("memberName"), QOrder.order.customerName.as("customerName"), QOrder.order.coin.unit, QOrder.order.money, QOrder.order.number, QOrder.order.commission.as("fee"), QOrder.order.payMode.as("payMode"), QOrder.order.releaseTime.as("releaseTime"), QOrder.order.cancelTime.as("cancelTime"), QOrder.order.payTime.as("payTime"), QOrder.order.status.as("status")) ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()])); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount() ; return new PageImpl<>(list,pageModel.getPageable(),total); }
Example #2
Source File: BaseService.java From ZTuoExchange_framework with MIT License | 7 votes |
/** * @param expressions 查询列表 * @param entityPaths 查询表 * @param predicates 条件 * @param orderSpecifierList 排序 * @param pageNo 页码 * @param pageSize 页面大小 */ @Transactional(readOnly = true) public PageListMapResult queryDslForPageListResult( List<Expression> expressions, List<EntityPath> entityPaths, List<Predicate> predicates, List<OrderSpecifier> orderSpecifierList, Integer pageNo, Integer pageSize) { JPAQuery<Tuple> jpaQuery = queryFactory.select(expressions.toArray(new Expression[expressions.size()])) .from(entityPaths.toArray(new EntityPath[entityPaths.size()])) .where(predicates.toArray(new Predicate[predicates.size()])); List<Tuple> tuples = jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()])) .offset((pageNo - 1) * pageSize).limit(pageSize) .fetch(); List<Map<String, Object>> list = new LinkedList<>();//返回结果 //封装结果 for (int i = 0; i < tuples.size(); i++) { //遍历tuples Map<String, Object> map = new LinkedHashMap<>();//一条信息 for (Expression expression : expressions) { map.put(expression.toString().split(" as ")[1],//别名作为Key tuples.get(i).get(expression));//获取结果 } list.add(map); } PageListMapResult pageListMapResult = new PageListMapResult(list, pageNo, pageSize, jpaQuery.fetchCount());//分页封装 return pageListMapResult; }
Example #3
Source File: BaseService.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 查询列表 * * @param pageNo 分页参数 * @param pageSize 分页大小 * @param predicateList 查询条件 * @param entityPathBase 查询表 * @param orderSpecifierList 排序条件 * @return */ @Transactional(readOnly = true) public PageResult<T> queryDsl(Integer pageNo, Integer pageSize, List<Predicate> predicateList, EntityPathBase<T> entityPathBase, List<OrderSpecifier> orderSpecifierList) { List<T> list; //查询表 JPAQuery<T> jpaQuery = queryFactory.selectFrom(entityPathBase); //查询条件 if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } //排序方式 if (orderSpecifierList != null && orderSpecifierList.size() > 0) { jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()])); } //分页查询 if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, pageNo, pageSize, jpaQuery.fetchCount()); }
Example #4
Source File: AdminAccessLogService.java From ZTuoExchange_framework with MIT License | 6 votes |
public Page<AdminAccessLog> page(List<BooleanExpression> predicates, PageModel pageModel){ JPAQuery<AdminAccessLog> query = queryFactory.select( Projections.fields(AdminAccessLog.class, QAdminAccessLog.adminAccessLog.id.as("id"), QAdminAccessLog.adminAccessLog.accessIp.as("accessIp"), QAdminAccessLog.adminAccessLog.accessMethod.as("accessMethod"), QAdminAccessLog.adminAccessLog.accessTime.as("accessTime"), QAdminAccessLog.adminAccessLog.adminId.as("adminId"), QAdminAccessLog.adminAccessLog.uri.as("uri"), QAdminAccessLog.adminAccessLog.module.as("module"), QAdminAccessLog.adminAccessLog.operation.as("operation"), QAdmin.admin.username.as("adminName")) ).from(QAdminAccessLog.adminAccessLog,QAdmin.admin).where(predicates.toArray(new BooleanExpression[predicates.size()])) ; List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ; query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); long total = query.fetchCount() ; query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize()); List<AdminAccessLog> list = query.fetch() ; return new PageImpl<AdminAccessLog>(list,pageModel.getPageable(),total); }
Example #5
Source File: KeyValueQuerydslUtils.java From spring-data-keyvalue with Apache License 2.0 | 6 votes |
/** * Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}. * * @param sort must not be {@literal null}. * @param builder must not be {@literal null}. * @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}. */ static OrderSpecifier<?>[] toOrderSpecifier(Sort sort, PathBuilder<?> builder) { Assert.notNull(sort, "Sort must not be null."); Assert.notNull(builder, "Builder must not be null."); List<OrderSpecifier<?>> specifiers = null; if (sort instanceof QSort) { specifiers = ((QSort) sort).getOrderSpecifiers(); } else { specifiers = new ArrayList<>(); for (Order order : sort) { specifiers.add(toOrderSpecifier(order, builder)); } } return specifiers.toArray(new OrderSpecifier<?>[specifiers.size()]); }
Example #6
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<SysAdvertise> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)) .offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example #7
Source File: MemberTransactionService.java From ZTuoExchange_framework with MIT License | 6 votes |
public Page<MemberTransactionVO> joinFind(List<Predicate> predicates, PageModel pageModel){ List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ; JPAQuery<MemberTransactionVO> query = queryFactory.select(Projections.fields(MemberTransactionVO.class, QMemberTransaction.memberTransaction.address, QMemberTransaction.memberTransaction.amount, QMemberTransaction.memberTransaction.createTime.as("createTime"), QMemberTransaction.memberTransaction.fee, QMemberTransaction.memberTransaction.flag, QMemberTransaction.memberTransaction.id.as("id"), QMemberTransaction.memberTransaction.symbol, QMemberTransaction.memberTransaction.type, QMember.member.username.as("memberUsername"), QMember.member.mobilePhone.as("phone"), QMember.member.email, QMember.member.realName.as("memberRealName"), QMember.member.id.as("memberId"))) .from(QMemberTransaction.memberTransaction, QMember.member); predicates.add(QMemberTransaction.memberTransaction.memberId.eq(QMember.member.id)); query.where(predicates.toArray(new BooleanExpression[predicates.size()])); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<MemberTransactionVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount(); return new PageImpl<>(list, pageModel.getPageable(), total); }
Example #8
Source File: MemberDepositService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<MemberDepositVO> page(List<BooleanExpression> predicates,PageModel pageModel){ JPAQuery<MemberDepositVO> query = queryFactory.select(Projections.fields(MemberDepositVO.class, QMemberDeposit.memberDeposit.id.as("id"), QMember.member.username, QMember.member.id.as("memberId"), QMemberDeposit.memberDeposit.address, QMemberDeposit.memberDeposit.amount, QMemberDeposit.memberDeposit.createTime.as("createTime"), QMemberDeposit.memberDeposit.unit)).from(QMember.member,QMemberDeposit.memberDeposit) .where(predicates.toArray(new BooleanExpression[predicates.size()])); List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])) ; long total = query.fetchCount() ; query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize()); List<MemberDepositVO> list = query.fetch() ; return new PageImpl<MemberDepositVO>(list,pageModel.getPageable(),total); }
Example #9
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<SysAdvertise> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)) .offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example #10
Source File: QuerydslKeyValueRepository.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Override public Iterable<T> findAll(OrderSpecifier<?>... orders) { if (ObjectUtils.isEmpty(orders)) { return findAll(); } AbstractCollQuery<T, ?> query = prepareQuery(null); query.orderBy(orders); return query.fetchResults().getResults(); }
Example #11
Source File: OrderService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){ List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); JPAQuery<OtcOrderVO> query = queryFactory.select( Projections.fields(OtcOrderVO.class, QOrder.order.id.as("id"), QOrder.order.orderSn.as("orderSn"), QOrder.order.advertiseType.as("advertiseType"), QOrder.order.createTime.as("createTime"), QOrder.order.memberName.as("memberName"), QOrder.order.customerName.as("customerName"), QOrder.order.coin.unit, QOrder.order.money, QOrder.order.number, QOrder.order.commission.as("fee"), QOrder.order.payMode.as("payMode"), QOrder.order.releaseTime.as("releaseTime"), QOrder.order.cancelTime.as("cancelTime"), QOrder.order.payTime.as("payTime"), QOrder.order.status.as("status")) ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()])); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount() ; return new PageImpl<>(list,pageModel.getPageable(),total); }
Example #12
Source File: PageModel.java From ZTuoExchange_framework with MIT License | 5 votes |
public List<OrderSpecifier> getOrderSpecifiers(){ List<OrderSpecifier> orderSpecifiers = new ArrayList<>(); setSort(); if(this.getProperty()!=null){ for(int i = 0 ; i < this.getProperty().size() ;i++){ Path path = ExpressionUtils.path(Path.class,this.getProperty().get(i)); OrderSpecifier orderSpecifier = new OrderSpecifier(this.toOrders(this.getDirection()).get(i),path); orderSpecifiers.add(orderSpecifier); } } return orderSpecifiers ; }
Example #13
Source File: AnnouncementController.java From ZTuoExchange_framework with MIT License | 5 votes |
@PostMapping("page") public MessageResult page( @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize ) { //条件 ArrayList<Predicate> predicates = new ArrayList<>(); predicates.add(QAnnouncement.announcement.isShow.eq(true)); //排序 ArrayList<OrderSpecifier> orderSpecifiers = new ArrayList<>(); orderSpecifiers.add(QAnnouncement.announcement.sort.desc()); //查 PageResult<Announcement> pageResult = announcementService.queryDsl(pageNo, pageSize, predicates, QAnnouncement.announcement, orderSpecifiers); return success(pageResult); }
Example #14
Source File: MemberTransactionService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<MemberTransactionVO> joinFind(List<Predicate> predicates, PageModel pageModel){ List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ; JPAQuery<MemberTransactionVO> query = queryFactory.select(Projections.fields(MemberTransactionVO.class, QMemberTransaction.memberTransaction.address, QMemberTransaction.memberTransaction.amount, QMemberTransaction.memberTransaction.createTime.as("createTime"), QMemberTransaction.memberTransaction.fee, QMemberTransaction.memberTransaction.flag, QMemberTransaction.memberTransaction.id.as("id"), QMemberTransaction.memberTransaction.symbol, QMemberTransaction.memberTransaction.type, QMember.member.username.as("memberUsername"), QMember.member.mobilePhone.as("phone"), QMember.member.email, QMember.member.realName.as("memberRealName"), QMember.member.id.as("memberId"))) .from(QMemberTransaction.memberTransaction, QMember.member); predicates.add(QMemberTransaction.memberTransaction.memberId.eq(QMember.member.id)); query.where(predicates.toArray(new BooleanExpression[predicates.size()])); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<MemberTransactionVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount(); return new PageImpl<>(list, pageModel.getPageable(), total); }
Example #15
Source File: AdminAccessLogService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<AdminAccessLog> page(List<BooleanExpression> predicates, PageModel pageModel){ JPAQuery<AdminAccessLog> query = queryFactory.select( Projections.fields(AdminAccessLog.class, QAdminAccessLog.adminAccessLog.id.as("id"), QAdminAccessLog.adminAccessLog.accessIp.as("accessIp"), QAdminAccessLog.adminAccessLog.accessMethod.as("accessMethod"), QAdminAccessLog.adminAccessLog.accessTime.as("accessTime"), QAdminAccessLog.adminAccessLog.adminId.as("adminId"), QAdminAccessLog.adminAccessLog.uri.as("uri"), QAdminAccessLog.adminAccessLog.module.as("module"), QAdminAccessLog.adminAccessLog.operation.as("operation"), QAdmin.admin.username.as("adminName")) ).from(QAdminAccessLog.adminAccessLog,QAdmin.admin).where(predicates.toArray(new BooleanExpression[predicates.size()])) ; List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ; query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); long total = query.fetchCount() ; query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize()); List<AdminAccessLog> list = query.fetch() ; return new PageImpl<AdminAccessLog>(list,pageModel.getPageable(),total); }
Example #16
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
public List<SysAdvertise> findAll(List<Predicate> predicateList) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); return list; }
Example #17
Source File: MemberWalletService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<MemberWalletDTO> joinFind(List<Predicate> predicates,QMember qMember ,QMemberWallet qMemberWallet,PageModel pageModel) { List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); predicates.add(qMember.id.eq(qMemberWallet.memberId)); JPAQuery<MemberWalletDTO> query = queryFactory.select( Projections.fields(MemberWalletDTO.class, qMemberWallet.id.as("id"),qMemberWallet.memberId.as("memberId") ,qMember.username,qMember.realName.as("realName"), qMember.email,qMember.mobilePhone.as("mobilePhone"),qMemberWallet.balance,qMemberWallet.address,qMemberWallet.coin.unit ,qMemberWallet.frozenBalance.as("frozenBalance"),qMemberWallet.balance.add(qMemberWallet.frozenBalance).as("allBalance"))).from(QMember.member,QMemberWallet.memberWallet).where(predicates.toArray(new Predicate[predicates.size()])) .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<MemberWalletDTO> content = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount(); return new PageImpl<>(content, pageModel.getPageable(), total); }
Example #18
Source File: PageModel.java From ZTuoExchange_framework with MIT License | 5 votes |
public List<OrderSpecifier> getOrderSpecifiers(){ List<OrderSpecifier> orderSpecifiers = new ArrayList<>(); setSort(); if(this.getProperty()!=null){ for(int i = 0 ; i < this.getProperty().size() ;i++){ Path path = ExpressionUtils.path(Path.class,this.getProperty().get(i)); OrderSpecifier orderSpecifier = new OrderSpecifier(this.toOrders(this.getDirection()).get(i),path); orderSpecifiers.add(orderSpecifier); } } return orderSpecifiers ; }
Example #19
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
public List<SysAdvertise> findAll(List<Predicate> predicateList) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); return list; }
Example #20
Source File: UserService.java From codeway_service with GNU General Public License v3.0 | 5 votes |
public QueryResults<User> findByCondition(User user, QueryVO queryVO) { QUser qUser = QUser.user; com.querydsl.core.types.Predicate predicate = null; OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser); if (StringUtils.isNotEmpty(user.getUserName())) { predicate = ExpressionUtils.and(predicate, qUser.userName.like(user.getUserName())); } if (user.getStatus() != null) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getId())) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getUserName())) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getAccount())) { predicate = ExpressionUtils.and(predicate, qUser.account.eq(user.getAccount())); } if (StringUtils.isNotEmpty(user.getPhone())) { predicate = ExpressionUtils.and(predicate, qUser.phone.eq(user.getPhone())); } if (StringUtils.isNotEmpty(queryVO.getFieldSort())) { sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser, queryVO.getFieldSort()); } QueryResults<User> queryResults = jpaQueryFactory .selectFrom(qUser) .where(predicate) .offset(queryVO.getPageNum()) .limit(queryVO.getPageSize()) .orderBy(sortedColumn) .fetchResults(); return queryResults; }
Example #21
Source File: BaseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 查询列表 * * @param pageNo 分页参数 * @param pageSize 分页大小 * @param predicateList 查询条件 * @param entityPathBase 查询表 * @param orderSpecifierList 排序条件 * @return */ @Transactional(readOnly = true) public PageResult<T> queryDsl(Integer pageNo, Integer pageSize, List<Predicate> predicateList, EntityPathBase<T> entityPathBase, List<OrderSpecifier> orderSpecifierList) { List<T> list; //查询表 JPAQuery<T> jpaQuery = queryFactory.selectFrom(entityPathBase); //查询条件 if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } //排序方式 if (orderSpecifierList != null && orderSpecifierList.size() > 0) { jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()])); } //分页查询 if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, pageNo, pageSize, jpaQuery.fetchCount()); }
Example #22
Source File: MemberWalletService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<MemberWalletDTO> joinFind(List<Predicate> predicates,QMember qMember ,QMemberWallet qMemberWallet,PageModel pageModel) { List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); predicates.add(qMember.id.eq(qMemberWallet.memberId)); JPAQuery<MemberWalletDTO> query = queryFactory.select( Projections.fields(MemberWalletDTO.class, qMemberWallet.id.as("id"),qMemberWallet.memberId.as("memberId") ,qMember.username,qMember.realName.as("realName"), qMember.email,qMember.mobilePhone.as("mobilePhone"),qMemberWallet.balance,qMemberWallet.address,qMemberWallet.coin.unit ,qMemberWallet.frozenBalance.as("frozenBalance"),qMemberWallet.balance.add(qMemberWallet.frozenBalance).as("allBalance"))).from(QMember.member,QMemberWallet.memberWallet).where(predicates.toArray(new Predicate[predicates.size()])) .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<MemberWalletDTO> content = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount(); return new PageImpl<>(content, pageModel.getPageable(), total); }
Example #23
Source File: RoleService.java From codeway_service with GNU General Public License v3.0 | 5 votes |
/** * 条件查询角色 * * @param role : Role * @return IPage<Role> */ public QueryResults<Role> findRuleByCondition(Role role, QueryVO queryVO) { QRole qRole = QRole.role; com.querydsl.core.types.Predicate predicate = null; OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole); if (StringUtils.isNotEmpty(role.getRoleName())) { predicate = ExpressionUtils.and(predicate, qRole.roleName.like(role.getRoleName())); } if (StringUtils.isNotEmpty(queryVO.getFieldSort())) { sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole, queryVO.getFieldSort()); } QueryResults<Role> queryResults = jpaQueryFactory .selectFrom(qRole) .where(predicate) .offset(queryVO.getPageNum()) .limit(queryVO.getPageSize()) .orderBy(sortedColumn) .fetchResults(); return queryResults; }
Example #24
Source File: UserService.java From codeway_service with GNU General Public License v3.0 | 5 votes |
public QueryResults<User> findByCondition(User user, QueryVO queryVO) { QUser qUser = QUser.user; com.querydsl.core.types.Predicate predicate = null; OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser); if (StringUtils.isNotEmpty(user.getUserName())) { predicate = ExpressionUtils.and(predicate, qUser.userName.like(user.getUserName())); } if (user.getStatus() != null) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getId())) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getUserName())) { predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus())); } if (StringUtils.isNotEmpty(user.getAccount())) { predicate = ExpressionUtils.and(predicate, qUser.account.eq(user.getAccount())); } if (StringUtils.isNotEmpty(user.getPhone())) { predicate = ExpressionUtils.and(predicate, qUser.phone.eq(user.getPhone())); } if (StringUtils.isNotEmpty(queryVO.getFieldSort())) { sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser, queryVO.getFieldSort()); } QueryResults<User> queryResults = jpaQueryFactory .selectFrom(qUser) .where(predicate) .offset(queryVO.getPageNum()) .limit(queryVO.getPageSize()) .orderBy(sortedColumn) .fetchResults(); return queryResults; }
Example #25
Source File: QuerydslQueryBackend.java From crnk-framework with Apache License 2.0 | 5 votes |
public JPAQuery<T> getQuery() { JPAQueryBase finalQuery = querydslQuery; for (OrderSpecifier<?> order : orderList) { finalQuery = (JPAQueryBase) finalQuery.orderBy(order); } return (JPAQuery<T>) finalQuery; }
Example #26
Source File: QuerydslQueryBackend.java From crnk-framework with Apache License 2.0 | 5 votes |
@Override public OrderSpecifier<?> newSort(Expression<?> expr, Direction dir) { if (dir == Direction.ASC) { return new OrderSpecifier(Order.ASC, expr); } else { return new OrderSpecifier(Order.DESC, expr); } }
Example #27
Source File: QuerydslQueryBackend.java From katharsis-framework with Apache License 2.0 | 5 votes |
@Override public OrderSpecifier<?> newSort(Expression<?> expr, Direction dir) { if (dir == Direction.ASC) { return new OrderSpecifier(Order.ASC, expr); } else { return new OrderSpecifier(Order.DESC, expr); } }
Example #28
Source File: DashboardBoxRepository.java From SMSC with Apache License 2.0 | 5 votes |
@Override @EntityGraph(attributePaths = {"dashboardBoxType", "width", "height"}) @PreAuthorize("hasRole('POWER_ADMIN_USER') or hasAuthority('DASHBOARD_BOX_READ')") Iterable<DashboardBox> findAll(Predicate predicate, OrderSpecifier<?>[] orders);
Example #29
Source File: QuerydslUtil.java From eds-starter6-jpa with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static OrderSpecifier[] createOrderSpecifiers( ExtDirectStoreReadRequest request, Class<?> clazz, EntityPathBase<?> entityPathBase, Map<String, String> mapGuiColumn2Dbfield, Set<String> sortIgnoreProperties) { List<OrderSpecifier> orders; if (!request.getSorters().isEmpty()) { orders = new ArrayList<>(); PathBuilder<?> entityPath = new PathBuilder<>(clazz, entityPathBase.getMetadata()); for (SortInfo sortInfo : request.getSorters()) { if (!sortIgnoreProperties.contains(sortInfo.getProperty())) { Order order; if (sortInfo.getDirection() == SortDirection.ASCENDING) { order = Order.ASC; } else { order = Order.DESC; } String property = mapGuiColumn2Dbfield.get(sortInfo.getProperty()); if (property == null) { property = sortInfo.getProperty(); } orders.add(new OrderSpecifier(order, entityPath.get(property))); } } } else { orders = Collections.emptyList(); } return orders.toArray(new OrderSpecifier[orders.size()]); }
Example #30
Source File: QuerydslKeyValueRepository.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Override public Iterable<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) { AbstractCollQuery<T, ?> query = prepareQuery(predicate); query.orderBy(orders); return query.fetchResults().getResults(); }